[goose-llm] system prompt override (#2791)

This commit is contained in:
Salman Mohammed
2025-06-05 12:51:51 -04:00
committed by GitHub
parent c04373fdb2
commit 0bcea3d130
8 changed files with 132 additions and 14 deletions
@@ -0,0 +1,48 @@
use std::vec;
use anyhow::Result;
use goose_llm::{
completion,
types::completion::{CompletionRequest, CompletionResponse},
Message, ModelConfig,
};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<()> {
let provider = "databricks";
let provider_config = json!({
"host": std::env::var("DATABRICKS_HOST").expect("Missing DATABRICKS_HOST"),
"token": std::env::var("DATABRICKS_TOKEN").expect("Missing DATABRICKS_TOKEN"),
});
// let model_name = "goose-gpt-4-1"; // parallel tool calls
let model_name = "claude-3-5-haiku";
let model_config = ModelConfig::new(model_name.to_string());
let system_prompt_override = "You are a helpful assistant. Talk in the style of pirates.";
for text in ["How was your day?"] {
println!("\n---------------\n");
println!("User Input: {text}");
let messages = vec![
Message::user().with_text("Hi there!"),
Message::assistant().with_text("How can I help?"),
Message::user().with_text(text),
];
let completion_response: CompletionResponse = completion(CompletionRequest::new(
provider.to_string(),
provider_config.clone(),
model_config.clone(),
None,
Some(system_prompt_override.to_string()),
messages.clone(),
vec![],
))
.await?;
// Print the response
println!("\nCompletion Response:");
println!("{}", serde_json::to_string_pretty(&completion_response)?);
}
Ok(())
}
+2 -1
View File
@@ -106,7 +106,8 @@ async fn main() -> Result<()> {
provider.to_string(),
provider_config.clone(),
model_config.clone(),
system_preamble.to_string(),
Some(system_preamble.to_string()),
None,
messages.clone(),
extensions.clone(),
))