swiftide_core/chat_completion/
chat_completion_response.rsuse derive_builder::Builder;
use super::tools::ToolCall;
#[derive(Clone, Builder, Debug)]
#[builder(setter(strip_option, into), build_fn(error = anyhow::Error))]
pub struct ChatCompletionResponse {
pub message: Option<String>,
#[builder(default)]
pub tool_calls: Option<Vec<ToolCall>>,
}
impl ChatCompletionResponse {
pub fn builder() -> ChatCompletionResponseBuilder {
ChatCompletionResponseBuilder::default()
}
pub fn message(&self) -> Option<&str> {
self.message.as_deref()
}
pub fn tool_calls(&self) -> Option<&[ToolCall]> {
self.tool_calls.as_deref()
}
}
impl ChatCompletionResponseBuilder {
pub fn maybe_message<T: Into<Option<String>>>(&mut self, message: T) -> &mut Self {
self.message = Some(message.into());
self
}
pub fn maybe_tool_calls<T: Into<Option<Vec<ToolCall>>>>(&mut self, tool_calls: T) -> &mut Self {
self.tool_calls = Some(tool_calls.into());
self
}
}