Skip to content

Conversation

@joshuacoles
Copy link

@joshuacoles joshuacoles commented Mar 8, 2025

This is a combined PR for structural generation and OpenAI spec compatible function calling. A description of its contents can be found in: #771 (comment).

This builds off #734 and contains those commits

joshuacoles and others added 30 commits March 7, 2025 15:49
This removes direct references the internals of BufferedOutput to allow for better abstraction
…, read from the ChatCompletionRequest, along with tests
@joshuacoles joshuacoles force-pushed the structural-generation-and-function-calling branch from 51db6af to f95eb91 Compare March 13, 2025 17:53
@joshuacoles joshuacoles force-pushed the structural-generation-and-function-calling branch 2 times, most recently from 45a647e to 9371027 Compare March 13, 2025 18:21
@joshuacoles joshuacoles force-pushed the structural-generation-and-function-calling branch from 9371027 to 664e70f Compare March 13, 2025 18:23
@joshuacoles
Copy link
Author

I am going to continue to cleanup the git history to make it easier to review commit wise but I would say this is now feature complete. There are more things to add but you've got to stop somewhere and this is enough for our immediate use case.

palios-taey added a commit to palios-taey/exo that referenced this pull request Oct 20, 2025
Implements complete server-side parsing and formatting of tool calls
to match OpenAI API specification. Fixes exo-explore#293.

Changes:
- Add parse_tool_calls() function to parse <tool_call> XML tags from model output
- Modify generate_completion() to detect and format tool calls in responses
- Return proper tool_calls array with OpenAI-compliant structure
- Set finish_reason to "tool_calls" when tools are invoked
- Support both streaming and non-streaming responses
- Handle parallel tool calling (multiple tools in one response)
- Generate unique call IDs server-side (call_<random>)
- Ensure arguments field is always a JSON string (not object)

Implementation details:
- Reuses existing XML tag pattern from examples/function_calling.py
- Minimal changes to chatgpt_api.py (focused on response generation)
- Backwards compatible (no changes when tools not provided)
- Works with all existing tokenizer chat templates that support tools

Testing:
- Added comprehensive unit tests in test_parse_simple.py
- All 5 tests pass (single/parallel/no tools/dict conversion/OpenAI format)
- Added new example: examples/function_calling_openai_compliant.py

This implementation is cleaner and more focused than the stalled PR exo-explore#771
(59 commits, 35 files). We achieve the same functionality with minimal
changes to core API logic.
@AlexCheema AlexCheema force-pushed the main branch 2 times, most recently from a39f85b to 56f783b Compare October 21, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants