Add an openai-compatible provider type and registerProvider() for custom providers
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with packages/core/src/providers/base.ts and openai.ts, then review types.ts and the provider config and OpenAI tests named in the issue. Add the compatible provider options and custom provider registry while preserving the built-in provider behavior. Done means the listed acceptance tests pass, pnpm test:coverage and pnpm lint pass, and the @chatcops/core minor changeset is included.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Pointing ChatCops at Ollama, LM Studio, vLLM, Groq or OpenRouter works today through type: 'openai' with a baseURL, but it's awkward. You need an API key even when the server doesn't use one, it sends max_completion_tokens, which many of those servers don't know, and there's no way to turn tools off for a model that can't call them. A provider that isn't OpenAI-shaped can't be plugged in at all: createProvider only knows three types (packages/core/src/providers/base.ts, lines 10 to 27).
What to do
- A built-in
openai-compatibletype:provider: { type: 'openai-compatible', baseURL: 'http://localhost:11434/v1', // required model: 'llama3.2', // required, no default apiKey: process.env.GROQ_API_KEY, // optional headers: { 'HTTP-Referer': 'https://acme.com' }, // optional, sent on every request supportsTools: false, // optional, default true }- It runs on the OpenAI SDK, like the
openaitype. GiveOpenAIProvider's constructor (packages/core/src/providers/openai.ts, line 42) a small options argument rather than copying the class.nameis'openai-compatible', andheadersbecomes the SDK'sdefaultHeaders. maxTokensParamdefaults to'max_tokens'for this type.- Without
apiKey, pass a placeholder to the SDK, since it refuses to start with none. - With
supportsTools: false, don't sendtools, and log one warning if the server config has tools. - Throw a clear error at setup when
baseURLormodelis missing.
- It runs on the OpenAI SDK, like the
registerProvider(type, factory)in a newpackages/core/src/providers/registry.ts, exported from@chatcops/core:registerProvider('my-llm', async (config) => new MyProvider(config));createProviderlooks up registered types before the built-in switch.- Registering a built-in name (
claude,openai,gemini,openai-compatible) throws. - Registering the same custom name twice replaces it, so hot reload works.
ProviderConfig.type(packages/core/src/types.ts) widens to the four built-ins plus(string & {}), so editors still suggest the built-ins.apiKeybecomes optional in the type. The three hosted providers throw a clear error at setup when it's missing, which the server already reports nicely since #216.
Where to look
packages/core/src/providers/base.ts(createProvider)packages/core/src/providers/openai.ts(constructor andrequest())packages/core/tests/providers/provider-config.test.ts,openai.test.tswebsite/src/content/docs/core/providers.mdx(a separate issue updates the docs page once this lands)
Acceptance criteria
-
openai-compatibleworks without an API key, sendsmax_tokens, sends the extra headers, and leaves outtoolswhensupportsToolsis false (tests with a fake client or a fakefetch) - A missing
baseURLormodelgives a clear setup error -
registerProviderworks for a custom type, refuses built-in names, and replaces on a second register - An unknown, unregistered type still gives
Unknown provider type: ... - If you have Ollama or LM Studio running locally, say in the PR whether a real request worked (optional, but it helps)
- Changeset for
@chatcops/core(minor) -
pnpm test:coverageandpnpm lintpass
Please get this merged by Nov 3. I rewrite openai.ts after that.
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.
- Ngôn ngữ chính
- TypeScript
- Star
- 13
- Fork
- 7
- Merge trung bình
- 4 giờ 11 phút
- Pull request đã merge (30 ngày)
- 122
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codercops/chatcops
-
enhancement hacktoberfest help wanted server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Document the pre-chat formCó thể đã có người làm @masyarakatai đã nhận 4 ngày trước. Đang mởdocumentation good first issue hacktoberfest widget
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
codercops/chatcops#70 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Create @chatcops/store-redis for Upstash and other Redis clientsCó thể đã có người làm @bhushan4work đã nhận 1 ngày trước. Đang mởenhancement hacktoberfest help wanted server
codercops/chatcops#248 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/chatcops
Issue tương tự
-
frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ranxianglei/billion-context#4172 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
awslabs/threat-composer#362 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Area/Cloud Needs Triage Type/Bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
wso2/product-integrator#2847 ·
Maintainer thường phản hồi trong vòng 1 ngày