Commit f08c3d5
authored
feat: unified tools= parameter for tool calling (#199)
* feat: unified tools= parameter for tool calling (#191)
Replace individual boolean parameters (web_search, x_search, code_execution)
with a single tools= list parameter that accepts Tool instances, user-defined
dicts, and raw passthrough dicts.
- Add Tool, WebSearch, XSearch, CodeExecution classes with provider-specific
ToolMappers that translate to wire format
- Add ToolCall on Output and ToolResult(Message) for multi-turn tool use
- Add ToolSupport constraint for model-level tool validation
- Add _parse_tool_calls to all providers (Anthropic, OpenAI, xAI, Google,
OpenResponses) for non-streaming tool call extraction
- Add _aggregate_tool_calls to streaming for all providers
- Update templates for new tools parameter pattern
* test: add integration tests for tools= parameter
- WebSearch (non-streaming + streaming) across all 4 providers
- User-defined function tool with ToolCall parsing across all 4 providers
- xAI XSearch server-side tool
- Fix grok-3-mini model config: remove server-side tool support
(xAI API only supports server-side tools on grok-4+ family)
* feat: add multi-turn tool calling support
* feat: shared tool call parsing for Chat Completions and OpenResponses protocols
Add protocol-level shared helpers so providers don't duplicate parsing logic:
- Chat Completions: parse_tool_calls, serialize_messages, ToolsMapper, streaming tool call deltas
- OpenResponses: parse_tool_calls, parse_text_content, serialize_messages
- ToolCall extra="allow" for provider-specific fields (e.g. Google thoughtSignature)
- Accept ToolResult in message lists for multi-turn tool conversations
* refactor: add ChatCompletionsTextClient protocol base class
Mirrors OpenResponsesTextClient — shared generate(), analyze(),
_init_request(), _parse_content(), _parse_tool_calls() for all Chat
Completions providers. DeepSeek, Groq, HuggingFace, Mistral, Moonshot
now inherit from it, keeping only parameter_mappers() and _stream_class()
overrides (Mistral also keeps _parse_content for thinking models).
Also renames parse_text_content → parse_content in OpenResponses tools.
* fix: correct Groq WebSearch wire format and add model tool support
Map WebSearch to browser_search (Groq's native format) and add
ToolSupport constraints to all Groq models. GPT-OSS models support
WebSearch and CodeExecution; others support user-defined function tools only.
* feat: add tool calling support for DeepSeek, Groq, HuggingFace, Mistral, Moonshot
Add ToolSupport constraints to all models and ToolsMapper parameter
mappers for the 5 Chat Completions providers. Groq GPT-OSS models
support WebSearch + CodeExecution, Moonshot models support WebSearch,
all others support user-defined function tools only.
* feat: tool call serialization, deprecated param shims, and OpenResponses protocol
* fix: use serialize_messages in OpenResponses provider _init_request methods
* refactor: remove provider-level OpenResponses text client, use protocol (#229)
OpenResponses is a protocol, not a provider. The provider-level
`modalities/text/providers/openresponses/` was a parallel hierarchy
that reimplemented tool call parsing inline instead of delegating to
the canonical `parse_tool_calls()` from the protocol layer. The inline
versions were also less robust (KeyError vs .get() with fallback).
OpenAI, xAI, and Ollama now inherit from the protocol-level
`OpenResponsesTextClient`, matching the ChatCompletions pattern where
DeepSeek, Groq, Mistral etc. inherit from `ChatCompletionsTextClient`.
Fixes #219
* fix: raise InvalidToolError for non-dict/non-Tool items in tools list (#218) (#228)
ToolsMapper.map() silently dropped items that were neither Tool instances
nor dicts (e.g. tools=[WebSearch] without ()). Add InvalidToolError and
else clause in all 4 ToolsMapper implementations.
* fix: add ToolSupport declarations to legacy OpenAI and xAI models (#232)
gpt-4-turbo, gpt-4, gpt-3.5-turbo, and grok-2-vision-1212 all support
tool calling but were missing TextParameter.TOOLS in their parameter
constraints. Added ToolSupport(tools=[]) so they properly advertise
tool support in model metadata.
Fixes #225
* fix: improve tool error messages (#226) (#234)
- Name the protocol in ChatCompletions error: "not supported by Chat Completions"
- ToolSupport with empty tools list now says "not supported by this model"
instead of "Supported: []"
* fix: warn when WebSearch config fields are dropped by provider (#235)
Tool mappers now emit UnsupportedParameterWarning when a non-None
WebSearch field (e.g. blocked_domains, max_uses) is not supported by
the target provider. Each mapper declares _supported_fields so new
WebSearch fields automatically trigger warnings on providers that
don't map them.
Closes #231
* chore: bump version to 0.11.0
Unified tool calling across all providers — the bridge between LLM
reasoning and real-world action.
This release adds a single tools= parameter that works across 11
providers, replacing web_search/x_search/code_execution booleans.
Three tool shapes: built-in (WebSearch, XSearch, CodeExecution),
user-defined function dicts, and raw passthrough for provider-specific
tools. Streaming tool call deltas, multi-turn via ToolResult, and
full backward compatibility with deprecated param shims.
68 files changed, 8 new types, 2 protocol implementations.1 parent 380d179 commit f08c3d5
66 files changed
Lines changed: 1724 additions & 724 deletions
File tree
- src/celeste
- modalities/text
- protocols
- chatcompletions
- openresponses
- providers
- anthropic
- cohere
- deepseek
- google
- groq
- huggingface
- mistral
- moonshot
- ollama
- openai
- xai
- protocols
- chatcompletions
- openresponses
- providers
- anthropic/messages
- google/generate_content
- groq/chat
- moonshot/chat
- templates
- modalities/{modality_slug}
- providers/{provider_slug}/{api_slug}
- tests
- integration_tests/text
- unit_tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| |||
271 | 273 | | |
272 | 274 | | |
273 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
274 | 279 | | |
275 | 280 | | |
276 | 281 | | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
| 286 | + | |
281 | 287 | | |
282 | 288 | | |
| 289 | + | |
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
| 216 | + | |
214 | 217 | | |
215 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
216 | 223 | | |
217 | 224 | | |
218 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
370 | 394 | | |
371 | 395 | | |
372 | 396 | | |
| |||
382 | 406 | | |
383 | 407 | | |
384 | 408 | | |
| 409 | + | |
385 | 410 | | |
386 | 411 | | |
387 | 412 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
| |||
253 | 262 | | |
254 | 263 | | |
255 | 264 | | |
| 265 | + | |
256 | 266 | | |
257 | 267 | | |
258 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
28 | 38 | | |
29 | 39 | | |
30 | 40 | | |
31 | 41 | | |
32 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
33 | 69 | | |
34 | 70 | | |
35 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
20 | | - | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| |||
46 | 54 | | |
47 | 55 | | |
48 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
49 | 66 | | |
50 | 67 | | |
51 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | | - | |
| 54 | + | |
50 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments