tools: delete ToolDef and FunctionDef
ToolDef and FunctionDef are gone. Tool definitions are static strings on the Tool struct. The API layer builds JSON from Tool::to_json(). - ChatRequest.tools is now Option<serde_json::Value> - start_stream takes &[Tool] instead of Option<&[ToolDef]> - openai::stream_events takes &serde_json::Value for tools - memory_and_journal_tools() returns Vec<Tool> for subconscious agents - Subconscious agents filter by t.name instead of t.function.name No more runtime JSON construction for tool definitions. No more ToolDef::new(). No more FunctionDef. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
d195160b1e
commit
51e632c997
7 changed files with 33 additions and 78 deletions
|
|
@ -8,7 +8,6 @@ use anyhow::Result;
|
|||
use reqwest::Client;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::agent::tools::ToolDef;
|
||||
use super::types::*;
|
||||
use crate::user::ui_channel::{UiMessage, UiSender};
|
||||
use super::StreamEvent;
|
||||
|
|
@ -22,18 +21,19 @@ pub(super) async fn stream_events(
|
|||
api_key: &str,
|
||||
model: &str,
|
||||
messages: &[Message],
|
||||
tools: Option<&[ToolDef]>,
|
||||
tools_json: &serde_json::Value,
|
||||
tx: &mpsc::UnboundedSender<StreamEvent>,
|
||||
ui_tx: &UiSender,
|
||||
reasoning_effort: &str,
|
||||
sampling: super::SamplingParams,
|
||||
priority: Option<i32>,
|
||||
) -> Result<()> {
|
||||
let has_tools = tools_json.as_array().map_or(false, |a| !a.is_empty());
|
||||
let request = ChatRequest {
|
||||
model: model.to_string(),
|
||||
messages: messages.to_vec(),
|
||||
tool_choice: tools.map(|_| "auto".to_string()),
|
||||
tools: tools.map(|t| t.to_vec()),
|
||||
tool_choice: if has_tools { Some("auto".to_string()) } else { None },
|
||||
tools: if has_tools { Some(tools_json.clone()) } else { None },
|
||||
max_tokens: Some(16384),
|
||||
temperature: Some(sampling.temperature),
|
||||
top_p: Some(sampling.top_p),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue