Refactor TypeScript API to use object-based parameters#52
Merged
Conversation
Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
…tent Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor TypeScript classes and methods to use object types
Refactor TypeScript API to use object-based parameters
Jan 22, 2026
hiyouga
reviewed
Jan 22, 2026
Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the TypeScript SDK’s public API to use object-based parameters (constructors + streaming methods), and updates downstream usage (tests, playground, docs). Also extends tracing to persist the model name and adds additional OpenAI Responses streaming event handling.
Changes:
- Switch TypeScript client constructors and
streamingResponse*methods from positional args to{ ... }options objects. - Update TypeScript tests and playground integration to the new call signatures.
- Extend tracer output to include the model in both TS and Python implementations.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src_ts/verify_gemini3.cjs | Removes a legacy Gemini verification script. |
| src_ts/tsconfig.json | Enables .d.ts and declaration maps for the TS build output. |
| src_ts/tests/tracer.test.ts | Updates tracer tests for new saveHistory(model, ...) behavior and stored config. |
| src_ts/tests/client.test.ts | Updates client tests for object-based constructors and streaming method params. |
| src_ts/src/qwen3/client.ts | Updates Qwen3 client constructor + streaming method to accept options objects. |
| src_ts/src/integration/tracer.ts | Updates tracer saveHistory signature and persists model in saved config/text. |
| src_ts/src/integration/playground.ts | Updates playground server to use new AutoLLMClient + streaming method signatures. |
| src_ts/src/gpt5_2/client.ts | Updates GPT-5.2 client constructor + streaming method signature; expands streaming event handling. |
| src_ts/src/glm4_7/client.ts | Updates GLM client constructor + streaming method signature to options objects. |
| src_ts/src/gemini3/client.ts | Updates Gemini client constructor + streaming method signature to options objects. |
| src_ts/src/claude4_5/client.ts | Updates Claude client constructor + streaming method signature to options objects. |
| src_ts/src/baseClient.ts | Refactors base streaming APIs to accept options objects; adds model tracking for tracing. |
| src_ts/src/autoClient.ts | Refactors AutoLLMClient constructor + streaming APIs to accept options objects and delegate accordingly. |
| src_ts/README.md | Updates TS README imports and examples (but tracer snippet still needs API update). |
| src_py/tests/test_tracer.py | Updates tracer tests for new save_history(model, ...) signature; adjusts integration skips/models. |
| src_py/examples/trace_example.py | Updates example defaults (model/config) to newer defaults. |
| src_py/examples/tool_use_example.py | Updates example default model. |
| src_py/examples/stateless_example.py | Updates example defaults and removes unsupported temperature config for the chosen model. |
| src_py/examples/stateful_example.py | Updates example default model. |
| src_py/examples/image_understanding_example.py | Updates example default model/config and image URL. |
| src_py/agenthub/integration/tracer.py | Updates tracer save_history signature and persists model in saved config/text. |
| src_py/agenthub/integration/playground.py | Adjusts playground default model ordering/selection in the UI and server. |
| src_py/agenthub/gpt5_2/client.py | Adds handling for an additional OpenAI Responses streaming event type. |
| src_py/agenthub/base_client.py | Passes model into tracer on stateful streaming trace writes. |
| src_py/README.md | Updates Python README examples to newer defaults and usage. |
| README.md | Updates root README examples to new TypeScript object-based API and env var usage. |
hiyouga
approved these changes
Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors all TypeScript client constructors and public methods from positional parameters to object-based configuration for better extensibility and future parameter additions.
Changes
Client constructors
AutoLLMClient: now accepts options object with inline typeClaude4_5Client,Gemini3Client,GPT5_2Client,GLM4_7Client,Qwen3Client): updated to accept inline options objectPublic methods
streamingResponse: now accepts options object{ messages, config }streamingResponseStateful: now accepts options object{ message, config }Usage updates
API Changes
Constructor:
Methods:
Breaking change: All existing code using the old API signatures will need to be updated.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.