-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ask prompt configurable #417
base: main
Are you sure you want to change the base?
Conversation
…ple under examples/writer-agent
context: Vec<String>, | ||
model: String, | ||
) -> Result<String, ShellError> { | ||
let config = aws_config::load_from_env().await; | ||
let client = aws_sdk_bedrockruntime::Client::new(&config); | ||
|
||
let tpl_value = template.unwrap_or( "Please answer this question: \\\"{}\\\". Using the following context: \\\"{}\\\"".to_string()); | ||
let mut rendered_tpl = tpl_value.replacen("{}", &*question, 1); | ||
rendered_tpl = rendered_tpl.replacen("{}", &*context.join(" "), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work, you'll just end up with the prompt without the question, since there are no "{}" to replace. You'd need to do something like:
let request_body = if let Some(tpl) = template {
format!("{} - {}", tpl, question)
} else {
format!(
"Please answer this question: \\\"{}\\\". Using the following context: \\\"{}\\\"",
question,
context.join(" ")
)
};
let question_with_ctx = if !context.is_empty() {
format!(
"{}. Using the following context: \\\"{}\\\"",
request_body,
context.join(" ")
)
} else {
request_body
};
And when using a custom prompt do we want to support users passing in context as well, or should they be mutually exclusive?
context: Vec<String>, | ||
model: String, | ||
) -> Result<String, ShellError> { | ||
let url = format!( | ||
"https://generativelanguage.googleapis.com/v1beta/models/{}:generateContent?key={}", | ||
model, self.api_key | ||
); | ||
|
||
let tpl_value = template.unwrap_or( "Please answer this question: \\\"{}\\\". Using the following context: \\\"{}\\\"".to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue with this as the bedrock client
Add a configurable prompt for each model in the ask command, add example under examples/writer-agent. This would enable ai agents creation with cbsh.
Here is an example that specify answers must always be in JSON format: