-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
560 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Databricks OAuth Configuration | ||
DATABRICKS_HOST=https://your-workspace.cloud.databricks.com | ||
DATABRICKS_MODEL=your-model-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use anyhow::Result; | ||
use dotenv::dotenv; | ||
use goose::{ | ||
models::message::Message, | ||
providers::{ | ||
configs::{DatabricksProviderConfig, ProviderConfig}, | ||
factory::get_provider, | ||
}, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Load environment variables from .env file | ||
dotenv().ok(); | ||
|
||
// Get required environment variables | ||
let host = | ||
std::env::var("DATABRICKS_HOST").expect("DATABRICKS_HOST environment variable is required"); | ||
let model = std::env::var("DATABRICKS_MODEL") | ||
.expect("DATABRICKS_MODEL environment variable is required"); | ||
|
||
// Create the Databricks provider configuration with OAuth | ||
let config = ProviderConfig::Databricks(DatabricksProviderConfig::with_oauth(host, model)); | ||
|
||
// Create the provider | ||
let provider = get_provider(config)?; | ||
|
||
// Create a simple message | ||
let message = Message::user().with_text("Tell me a short joke about programming."); | ||
|
||
// Get a response | ||
let (response, usage) = provider | ||
.complete("You are a helpful assistant.", &[message], &[]) | ||
.await?; | ||
|
||
// Print the response and usage statistics | ||
println!("\nResponse from AI:"); | ||
println!("---------------"); | ||
for content in response.content { | ||
dbg!(content); | ||
} | ||
println!("\nToken Usage:"); | ||
println!("------------"); | ||
println!("Input tokens: {:?}", usage.input_tokens); | ||
println!("Output tokens: {:?}", usage.output_tokens); | ||
println!("Total tokens: {:?}", usage.total_tokens); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.