Add base code and examples for the Vertex API
- Add base code for the Vertex API with types and a client with helper methods for prompting text and conversation. - Add examples for prompting text and conversation.
This commit is contained in:
26
examples/text-from-text.rs
Normal file
26
examples/text-from-text.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use gemini_rs::prelude::*;
|
||||
|
||||
use gcp_auth::AuthenticationManager;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||
let project_id = std::env::var("PROJECT_ID")?;
|
||||
let location_id = std::env::var("LOCATION_ID")?;
|
||||
|
||||
let vertex_client = VertexClient::new(
|
||||
authentication_manager,
|
||||
api_endpoint,
|
||||
project_id,
|
||||
location_id,
|
||||
);
|
||||
|
||||
let prompt = "What is the airspeed of an unladen swallow?";
|
||||
let result = vertex_client.prompt_text(prompt, None).await?;
|
||||
println!("Response: {}", result);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user