mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
feat(provider): add CodeBuddy CN provider (copilot.tencent.com)
Add Tencent CodeBuddy CN (codebuddy-cn) OAuth provider with full support: OAuth login (GET poll with state query param), token refresh, 15-model catalog, /v2 inference endpoint, forced streaming, OpenAI-style reasoning, and per-model capabilities. Renamed from codebuddy to codebuddy-cn to allow a future codebuddy-ai variant. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
db4499d6df
commit
efd20be8d8
@@ -0,0 +1,36 @@
|
||||
import { DefaultExecutor } from "./default.js";
|
||||
|
||||
/**
|
||||
* CodeBuddyExecutor — talks to https://copilot.tencent.com/v2/chat/completions
|
||||
*
|
||||
* CodeBuddy is OpenAI-compatible but rejects non-stream chat requests
|
||||
* (HTTP 400, code 11101 "Non-stream chat request is currently not supported").
|
||||
* The same-format (openai→openai) translator path leaves body.stream as the
|
||||
* client sent it, so we force it true here — 9router still re-aggregates the
|
||||
* SSE into a JSON response for non-streaming clients.
|
||||
*/
|
||||
export class CodeBuddyExecutor extends DefaultExecutor {
|
||||
constructor() {
|
||||
super("codebuddy-cn");
|
||||
}
|
||||
|
||||
transformRequest(model, body, stream, credentials) {
|
||||
const transformed = super.transformRequest(model, body, stream, credentials);
|
||||
transformed.stream = true;
|
||||
|
||||
// CodeBuddy only surfaces model reasoning when the request carries the CLI's
|
||||
// OpenAI-style params: reasoning_effort + reasoning_summary:"auto". 9router's
|
||||
// thinking pipeline sets reasoning_effort only when the client asks, and never
|
||||
// sets reasoning_summary — so reasoning never shows. Mirror the CLI here.
|
||||
const eff = transformed.reasoning_effort;
|
||||
if (eff === "none" || eff === "off") {
|
||||
delete transformed.reasoning_effort; // gateway has no "none" — just omit
|
||||
} else {
|
||||
if (!eff) transformed.reasoning_effort = "medium";
|
||||
transformed.reasoning_summary = "auto";
|
||||
}
|
||||
return transformed;
|
||||
}
|
||||
}
|
||||
|
||||
export default CodeBuddyExecutor;
|
||||
Reference in New Issue
Block a user