You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(openai): add tool_choice and parallel_tool_calls to request model
- Add tool_choice and parallel_tool_calls fields to ChatCompletionRequest
- Implement _preprocess_tools() for tool filtering based on tool_choice
- Update convert_messages_to_prompt() signature with new params
- Update route.py call site to pass new parameters
- Add degradation logging for tool_choice mismatches
* feat(openai): add JSON Schema block, Strict Mode paragraph, and dynamic REMINDER assembly
* tests(openai): add TDD tests for tool_choice, parallel_tool_calls, and strict mode
* docs: document tool_choice, parallel_tool_calls, and strict in OpenAI adapter README
* smoke(openai): add smoke tests for tool_choice, parallel_tool_calls, and strict mode
* fix(logging): move security warnings to FastAPI startup event to avoid duplicate logs in reload mode
|`tools`| array | Tool definitions for function calling |
121
+
|`tool_choice`| string \| object | Controls which tools the model may call. Values: `"auto"` (default), `"none"` (disable tools), `"required"` (must call at least one tool), or `{"type": "function", "function": {"name": "..."}}` (call a specific tool). This parameter is proxy-layer only and not forwarded to DeepSeek. |
122
+
|`parallel_tool_calls`| bool | Whether to allow parallel tool calls. Default `true`. When `false`, the model is instructed to call only one tool at a time. This parameter is proxy-layer only and not forwarded to DeepSeek. |
121
123
|`extra_body`| dict | DeepSeek-specific parameters (see below) |
122
124
125
+
> **Note on `tools`**: Each tool supports a `strict` property inside `function` (e.g., `{"type": "function", "function": {"name": "...", "strict": true}}`). When `strict: true`, the model is instructed to strictly follow the JSON Schema — do not add undefined fields, do not omit required fields, do not use values outside enum lists. Both natural language description and JSON Schema block are included in the prompt for maximum constraint fidelity.
126
+
123
127
**DeepSeek-specific parameters via `extra_body`**:
strict_notice="\n**Strict Mode**: Function calls MUST exactly match the specified schema. Do NOT add fields not defined, do not omit required fields, do not use values outside enum list."
# Add separator and REMINDER before Assistant output if tools are available
131
-
iftools:
132
-
prompt_parts.append("\n---\nAbove is our conversation history.\n\n[REMINDER] When you need to call tools, you MUST use the [TOOL🛠️]...[/TOOL🛠️] tags. For multiple tool calls, wrap them in a JSON array: [TOOL🛠️][{\"name\": \"func1\", \"arguments\": {...}}, {\"name\": \"func2\", \"arguments\": {...}}][/TOOL🛠️].")
205
+
# Add separator and REMINDER before Assistant output
206
+
ifeffective_toolsisnotNone:
207
+
reminder_parts= ["When you need to call tools, you MUST use the [TOOL🛠️]...[/TOOL🛠️] tags."]
208
+
209
+
iftool_choice=="required":
210
+
reminder_parts.append("**You MUST call at least one tool before responding.**")
prompt_parts.append("\n---\nAbove is our conversation history.\n\n[REMINDER] The requested tool operation requires available tools, but none were provided. Inform the user that no tools are available.")
222
+
elifreason=="tool_not_found":
223
+
missing=tool_choice_info.get("missing_name", "the requested tool")
224
+
prompt_parts.append(f"\n---\nAbove is our conversation history.\n\n[REMINDER] The requested tool \"{missing}\" is not available. Inform the user that this tool is not available.")
0 commit comments