2 Commits

Author SHA1 Message Date
6d49f9939c ci: install Rust on the Gitea runner and check fmt and clippy
All checks were successful
Rust / check (pull_request) Successful in 5m14s
The Gitea runner image doesn't include Rust, so every job failed at
'cargo: command not found'. Install the stable toolchain, cache the
build, and run cargo fmt --check and clippy alongside the tests.
2026-10-26 20:34:40 +00:00
c911fc382e style: run cargo fmt on examples 2026-10-26 20:34:40 +00:00
5 changed files with 84 additions and 72 deletions

View File

@@ -10,13 +10,19 @@ env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
jobs: jobs:
build: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build # The Gitea runner image doesn't ship with Rust, unlike GitHub's.
run: cargo build --verbose - uses: dtolnay/rust-toolchain@stable
- name: Run tests with:
run: cargo test --verbose components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Test
run: cargo test

View File

@@ -1,5 +1,5 @@
use console::style; use console::style;
use dialoguer::{theme::ColorfulTheme, Input}; use dialoguer::{Input, theme::ColorfulTheme};
use gemini_rs::prelude::*; use gemini_rs::prelude::*;
use std::time::Duration; use std::time::Duration;

View File

@@ -19,10 +19,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.add_text_part("Answer as if you were Yoda") .add_text_part("Answer as if you were Yoda")
.build(); .build();
let user_prompt = vec![Content::builder() let user_prompt = vec![
Content::builder()
.role(Role::User) .role(Role::User)
.add_text_part("What is the airspeed of an unladen swallow?") .add_text_part("What is the airspeed of an unladen swallow?")
.build()]; .build(),
];
let request = GenerateContentRequest::builder() let request = GenerateContentRequest::builder()
.contents(user_prompt) .contents(user_prompt)

View File

@@ -15,10 +15,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
location_id, location_id,
); );
let prompt = vec![Content::builder() let prompt = vec![
Content::builder()
.role(Role::User) .role(Role::User)
.add_text_part("Tell me the story of the genesis of the universe as a bedtime story.") .add_text_part("Tell me the story of the genesis of the universe as a bedtime story.")
.build()]; .build(),
];
let request = GenerateContentRequest::builder().contents(prompt).build(); let request = GenerateContentRequest::builder().contents(prompt).build();

View File

@@ -14,10 +14,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
location_id, location_id,
); );
let prompt = vec![Content::builder() let prompt = vec![
Content::builder()
.role(Role::User) .role(Role::User)
.add_text_part("What is the airspeed of an unladen swallow?") .add_text_part("What is the airspeed of an unladen swallow?")
.build()]; .build(),
];
let request = GenerateContentRequest::builder().contents(prompt).build(); let request = GenerateContentRequest::builder().contents(prompt).build();
let response = gemini.generate_content(&request, "gemini-pro").await?; let response = gemini.generate_content(&request, "gemini-pro").await?;