pub struct ChatMessage {
pub role: String,
pub content: String,
pub tool_call_id: Option<String>,
pub tool_calls: Option<Vec<Value>>,
}Expand description
OpenAI-compatible chat message.
Why: Both trusty-memory’s chat subcommand and trusty-search’s /chat
endpoint speak the OpenRouter format. Sharing the struct keeps them in
step (and lets callers compose chat histories without re-defining types).
Tool-use additions (tool_call_id, tool_calls) follow the OpenAI
function-calling shape: assistant messages set tool_calls when the model
requests tool invocations; subsequent role: "tool" messages echo the
matching tool_call_id with the tool’s result in content.
What: role is one of "system" | "user" | "assistant" | "tool".
content is the message text. tool_call_id is the id of the tool call
this message is replying to (only set when role == "tool"). tool_calls
is the raw OpenAI tool_calls array on an assistant message that asked
to invoke tools — kept as serde_json::Value so we don’t drop any fields
the upstream may add.
Test: serde round-trip in chat_message_round_trips.
Fields§
§role: String§content: String§tool_call_id: Option<String>§tool_calls: Option<Vec<Value>>Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more