ci: run fmt, clippy and tests on the Gitea runner #18
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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![
|
||||||
.role(Role::User)
|
Content::builder()
|
||||||
.add_text_part("What is the airspeed of an unladen swallow?")
|
.role(Role::User)
|
||||||
.build()];
|
.add_text_part("What is the airspeed of an unladen swallow?")
|
||||||
|
.build(),
|
||||||
|
];
|
||||||
|
|
||||||
let request = GenerateContentRequest::builder()
|
let request = GenerateContentRequest::builder()
|
||||||
.contents(user_prompt)
|
.contents(user_prompt)
|
||||||
|
|||||||
@@ -1,34 +1,36 @@
|
|||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = gcp_auth::provider().await?;
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|
||||||
let gemini = GeminiClient::new(
|
let gemini = GeminiClient::new(
|
||||||
authentication_manager,
|
authentication_manager,
|
||||||
api_endpoint,
|
api_endpoint,
|
||||||
project_id,
|
project_id,
|
||||||
location_id,
|
location_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
let prompt = vec![Content::builder()
|
let prompt = vec![
|
||||||
.role(Role::User)
|
Content::builder()
|
||||||
.add_text_part("Tell me the story of the genesis of the universe as a bedtime story.")
|
.role(Role::User)
|
||||||
.build()];
|
.add_text_part("Tell me the story of the genesis of the universe as a bedtime story.")
|
||||||
|
.build(),
|
||||||
let request = GenerateContentRequest::builder().contents(prompt).build();
|
];
|
||||||
|
|
||||||
let mut queue = gemini
|
let request = GenerateContentRequest::builder().contents(prompt).build();
|
||||||
.stream_generate_content(&request, "gemini-2.0-flash-001")
|
|
||||||
.await?;
|
let mut queue = gemini
|
||||||
|
.stream_generate_content(&request, "gemini-2.0-flash-001")
|
||||||
while let Some(response) = queue.next().await {
|
.await?;
|
||||||
println!("Response: {:?}", response?);
|
|
||||||
}
|
while let Some(response) = queue.next().await {
|
||||||
|
println!("Response: {:?}", response?);
|
||||||
Ok(())
|
}
|
||||||
}
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = gcp_auth::provider().await?;
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|
||||||
let gemini = GeminiClient::new(
|
let gemini = GeminiClient::new(
|
||||||
authentication_manager,
|
authentication_manager,
|
||||||
api_endpoint,
|
api_endpoint,
|
||||||
project_id,
|
project_id,
|
||||||
location_id,
|
location_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
let prompt = vec![Content::builder()
|
let prompt = vec![
|
||||||
.role(Role::User)
|
Content::builder()
|
||||||
.add_text_part("What is the airspeed of an unladen swallow?")
|
.role(Role::User)
|
||||||
.build()];
|
.add_text_part("What is the airspeed of an unladen swallow?")
|
||||||
|
.build(),
|
||||||
let request = GenerateContentRequest::builder().contents(prompt).build();
|
];
|
||||||
let response = gemini.generate_content(&request, "gemini-pro").await?;
|
|
||||||
println!("Response: {:?}", response.candidates[0].get_text().unwrap());
|
let request = GenerateContentRequest::builder().contents(prompt).build();
|
||||||
|
let response = gemini.generate_content(&request, "gemini-pro").await?;
|
||||||
Ok(())
|
println!("Response: {:?}", response.candidates[0].get_text().unwrap());
|
||||||
}
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user