-
Notifications
You must be signed in to change notification settings - Fork 77
ai: Support tool calls in RAG methods #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive support for tool calling functionality to the AI package, expanding its capabilities to handle OpenAI-style function calls in both streaming and non-streaming modes. The changes include extensive test infrastructure improvements, new API types, and detailed documentation.
Key changes:
- Implements OpenAI-style tool calling support with proper streaming and non-streaming handling
- Adds comprehensive test coverage for tool calling scenarios
- Refactors test infrastructure with better debugging and shared setup utilities
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
packages/ai/test/test-setup.ts | New shared test environment setup utility |
packages/ai/test/mockHttpServer.ts | Enhanced mock server with tool calling support and debug logging |
packages/ai/test/globalSetup.ts | Added performance timing for test setup |
packages/ai/test/core.test.ts | Refactored tests and added tool calling test cases |
packages/ai/src/utils.ts | Improved error message formatting |
packages/ai/src/types.ts | Added tool definition types and streaming message types |
packages/ai/src/core.ts | Updated to return AssistantMessage objects with tool call support |
packages/ai/package.json | Added debug dependency |
packages/ai/jest.config.js | Added test concurrency limits and timeout configuration |
packages/ai/README.md | Added comprehensive tool calling documentation with examples |
Comments suppressed due to low confidence (1)
packages/ai/src/types.ts:110
- The property name 'args' is ambiguous and inconsistent with the function calling convention. Consider renaming to 'arguments' to match the OpenAI API standard used elsewhere in the codebase.
args?: Record<string, unknown> | null;
Even for Anthropic, we translate their tool calls into our own consistent format, but we were accidentally passing through a possible Anthropic style and documentating _that_.
Our previous methods only supported returning text that was generated by an assistant, but if you provide tools, we were never returning a rich enough object that would allow you to call the tools with the provided arguments.
This is a breaking change because instead of returning
string | null
, we now return a wholeAssistantMessage
from the main methods. See the updated README for additional details.