feat: add tool call support to chat completions endpoint

- Accept tools and tool_choice fields in CompletionRequest
- Convert OpenAI tools to Gemini format and store in MitmStore
- Detect MITM-captured function calls in streaming poll loop
- Emit tool_calls delta chunks in OpenAI streaming format
- Finish with 'tool_calls' reason instead of 'stop' when tools used
- Only clear tools when request has none (prevents stale state leak)
This commit is contained in:
Nikketryhard
2026-02-14 23:47:23 -06:00
parent 19090b79f0
commit 3303ce38de
2 changed files with 71 additions and 4 deletions

View File

@@ -49,6 +49,10 @@ pub(crate) struct CompletionRequest {
pub stream: bool,
#[serde(default = "default_timeout")]
pub timeout: u64,
/// OpenAI-format tool definitions
pub tools: Option<Vec<serde_json::Value>>,
/// Tool choice: "auto", "none", "required", or {"type":"function","function":{"name":"..."}}
pub tool_choice: Option<serde_json::Value>,
}
#[derive(Deserialize)]