add tool role for ChatCompletionMessage

This commit is contained in:
hansel
2024-07-17 10:03:54 +08:00
parent 7e10e3a293
commit 4a11c78393
6 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
name: None,
tool_calls: None,
tool_call_id: None,
}],
);

View File

@ -35,6 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
name: None,
tool_calls: None,
tool_call_id: None,
}],
)
.tools(vec![chat_completion::Tool {

View File

@ -35,6 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
name: None,
tool_calls: None,
tool_call_id: None,
}],
)
.tools(vec![chat_completion::Tool {
@ -89,6 +90,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
"What is the price of Ethereum?",
)),
name: None,
tool_calls: None,
tool_call_id: None,
},
chat_completion::ChatCompletionMessage {
role: chat_completion::MessageRole::function,
@ -97,6 +100,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
format!("{{\"price\": {}}}", price)
}),
name: Some(String::from("get_coin_price")),
tool_calls: None,
tool_call_id: None,
},
],
);

View File

@ -29,6 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
]),
name: None,
tool_calls: None,
tool_call_id: None,
}],
);