Skip to content

Refactor TypeScript API to use object-based parameters#52

Merged
hiyouga merged 9 commits intomainfrom
copilot/refactor-typescript-inputs
Jan 22, 2026
Merged

Refactor TypeScript API to use object-based parameters#52
hiyouga merged 9 commits intomainfrom
copilot/refactor-typescript-inputs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 22, 2026

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 type
  • All model-specific clients (Claude4_5Client, Gemini3Client, GPT5_2Client, GLM4_7Client, Qwen3Client): updated to accept inline options object

Public methods

  • streamingResponse: now accepts options object { messages, config }
  • streamingResponseStateful: now accepts options object { message, config }

Usage updates

  • Test suite
  • Playground integration
  • Documentation and examples (both root and TypeScript README)

API Changes

Constructor:

// Before
new AutoLLMClient('claude-sonnet-4-5-20250929', apiKey, baseUrl, clientType)

// After
new AutoLLMClient({ 
  model: 'claude-sonnet-4-5-20250929',
  apiKey,
  baseUrl,
  clientType 
})

Methods:

// Before
client.streamingResponseStateful(message, config)

// After
client.streamingResponseStateful({ message, config })

Breaking change: All existing code using the old API signatures will need to be updated.

Original prompt

把 typescript 的类和方法输入都改成对象类型,方便之后兼容更多的输入参数,修改以后可以使用 AutoLLMClient({model: 'claude-sonnet-4-5-20250929'}) 的方法调用(breaking-change but better API)


💡 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.

Copilot AI and others added 2 commits January 22, 2026 14:35
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
Copilot AI requested a review from hiyouga January 22, 2026 14:41
Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
Copilot AI requested a review from hiyouga January 22, 2026 14:55
@hiyouga hiyouga marked this pull request as ready for review January 22, 2026 16:29
Copilot AI review requested due to automatic review settings January 22, 2026 16:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 hiyouga merged commit 0abc806 into main Jan 22, 2026
2 checks passed
@hiyouga hiyouga deleted the copilot/refactor-typescript-inputs branch January 22, 2026 16:57
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.

3 participants