Closed sloganking closed 9 months ago
Here is an example of how to use it meanwhile:
let tool = ChatCompletionToolArgs::default()
.r#type(async_openai::types::ChatCompletionToolType::Function)
.function(ChatCompletionFunctions {
name: "get_current_weather".to_string(),
description: Some("Get weather in location".to_string()),
parameters: json!({
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
"required": ["location", "format"],
})
}).build()?;
and for the tool choice
.tool_choice(ChatCompletionToolChoiceOption::Auto)
Though I am not sure it is working right now!
Error: ApiError(ApiError { message: "'$.tool_choice' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference.", type: Some("invalid_request_error"), param: None, code: None })
Okay thanks, I will continue using the deprecated option for now and maybe come back to this when it has been tested further. or test it some on my own later.
When leaving out
.tool_choice(ChatCompletionToolChoiceOption::Auto)
it should work
An example was added in #153. And the bug was fixed in #158
Seems like everything is resolved, hence closing the issue.
https://github.com/64bit/async-openai/blob/main/examples/function-call/src/main.rs
The current function call example uses the now deprecated
ChatCompletionResponseMessage::function_call
field. It was deprecated in favor ofChatCompletionResponseMessage::tool_calls
. Can an example be provided using the newtool_calls
method?