2025-01-24 13:04:43 -08:00
|
|
|
use anyhow::Result;
|
2025-07-24 03:09:26 +02:00
|
|
|
use dotenvy::dotenv;
|
2025-08-06 22:06:13 -04:00
|
|
|
use goose::conversation::message::Message;
|
2026-01-27 13:43:05 +09:00
|
|
|
use goose::providers::create_with_named_model;
|
2025-10-10 19:31:50 -04:00
|
|
|
use goose::providers::databricks::DATABRICKS_DEFAULT_MODEL;
|
2025-01-24 13:04:43 -08:00
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
|
dotenv().ok();
|
|
|
|
|
|
|
|
|
|
std::env::remove_var("DATABRICKS_TOKEN");
|
|
|
|
|
|
2026-02-12 07:37:52 +08:00
|
|
|
let provider =
|
|
|
|
|
create_with_named_model("databricks", DATABRICKS_DEFAULT_MODEL, Vec::new()).await?;
|
2025-01-24 13:04:43 -08:00
|
|
|
|
|
|
|
|
let message = Message::user().with_text("Tell me a short joke about programming.");
|
|
|
|
|
|
2026-02-17 19:53:38 +01:00
|
|
|
let model_config = provider.get_model_config();
|
2026-01-27 13:43:05 +09:00
|
|
|
let (response, usage) = provider
|
2026-02-17 19:53:38 +01:00
|
|
|
.complete(
|
|
|
|
|
&model_config,
|
|
|
|
|
"",
|
2026-01-27 13:43:05 +09:00
|
|
|
"You are a helpful assistant.",
|
|
|
|
|
&[message],
|
|
|
|
|
&[],
|
|
|
|
|
)
|
2025-01-24 13:04:43 -08:00
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
println!("\nResponse from AI:");
|
|
|
|
|
println!("---------------");
|
2026-01-27 13:43:05 +09:00
|
|
|
println!("{:?}", response);
|
|
|
|
|
|
2025-01-24 13:04:43 -08:00
|
|
|
println!("\nToken Usage:");
|
|
|
|
|
println!("------------");
|
2026-01-27 13:43:05 +09:00
|
|
|
println!("Input tokens: {:?}", usage.usage.input_tokens);
|
|
|
|
|
println!("Output tokens: {:?}", usage.usage.output_tokens);
|
|
|
|
|
println!("Total tokens: {:?}", usage.usage.total_tokens);
|
2025-01-24 13:04:43 -08:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|