async-openai
async-openai copied to clipboard
【help】Could you please give me an example of defining multiple functions?
Why do I execute one function every time and not multiple functions?
let request = CreateChatCompletionRequestArgs::default()
.max_tokens(512u16)
.model("gpt-3.5-turbo-0125")
.messages("Can you tell me which doctors will be available the day after tomorrow?")
.tools(vec![ChatCompletionToolArgs::default()
.r#type(ChatCompletionToolType::Function)
.function(
FunctionObjectArgs::default()
.name("register_list")
.description("Query the doctor’s consultation registration information on a certain day")
.parameters(json!({
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "visit date,format:yyyy-MM-dd,e.g:2024-01-01",
},
},
"required": ["date"],
}))
.build()?,
)
.build()?,
ChatCompletionToolArgs::default()
.r#type(ChatCompletionToolType::Function)
.function(
FunctionObjectArgs::default()
.name("now_time")
.description("this is test, don't execute")
.build()?,
)
.build()?
])
.build()?;
if let Some(tool_calls) = res_msg.tool_calls {
println!("{:?}", tool_calls);
// always execute now_time, omitting part of the code
}
fn calc_now_time() -> String {
Local::now().naive_local().format("%Y-%m-%d %H:%M:%S").to_string()
}
fn erp_register_list(args: &str) -> String {
"doctor one".to_string()
}
I want, now_time should be executed first to convert the date and then register_list