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;
|
2026-07-02 09:18:57 -07: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-06-23 19:18:07 -04:00
|
|
|
let provider = create_with_named_model("databricks", 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-06-23 19:18:07 -04:00
|
|
|
let model_config =
|
|
|
|
|
goose::model_config::model_config_from_user_config("databricks", DATABRICKS_DEFAULT_MODEL)?;
|
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(())
|
|
|
|
|
}
|