mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-22 15:15:34 +00:00
add tool role for ChatCompletionMessage
This commit is contained in:
@ -32,6 +32,7 @@ let req = ChatCompletionRequest::new(
|
|||||||
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
||||||
name: None,
|
name: None,
|
||||||
tool_calls: None,
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
@ -14,6 +14,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
||||||
name: None,
|
name: None,
|
||||||
tool_calls: None,
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -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?")),
|
content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
|
||||||
name: None,
|
name: None,
|
||||||
tool_calls: None,
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.tools(vec![chat_completion::Tool {
|
.tools(vec![chat_completion::Tool {
|
||||||
|
@ -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?")),
|
content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
|
||||||
name: None,
|
name: None,
|
||||||
tool_calls: None,
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.tools(vec![chat_completion::Tool {
|
.tools(vec![chat_completion::Tool {
|
||||||
@ -89,6 +90,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
"What is the price of Ethereum?",
|
"What is the price of Ethereum?",
|
||||||
)),
|
)),
|
||||||
name: None,
|
name: None,
|
||||||
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
},
|
},
|
||||||
chat_completion::ChatCompletionMessage {
|
chat_completion::ChatCompletionMessage {
|
||||||
role: chat_completion::MessageRole::function,
|
role: chat_completion::MessageRole::function,
|
||||||
@ -97,6 +100,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
format!("{{\"price\": {}}}", price)
|
format!("{{\"price\": {}}}", price)
|
||||||
}),
|
}),
|
||||||
name: Some(String::from("get_coin_price")),
|
name: Some(String::from("get_coin_price")),
|
||||||
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -29,6 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
]),
|
]),
|
||||||
name: None,
|
name: None,
|
||||||
tool_calls: None,
|
tool_calls: None,
|
||||||
|
tool_call_id: None,
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ pub enum MessageRole {
|
|||||||
system,
|
system,
|
||||||
assistant,
|
assistant,
|
||||||
function,
|
function,
|
||||||
|
tool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
|
||||||
@ -158,6 +159,8 @@ pub struct ChatCompletionMessage {
|
|||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub tool_calls: Option<Vec<ToolCall>>,
|
pub tool_calls: Option<Vec<ToolCall>>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub tool_call_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
Reference in New Issue
Block a user