mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 06:04:51 +00:00
Release v0.23.2
Fixed Claude models via GitHub Copilot re-answering all previous prompts. fixes #209
This commit is contained in:
parent
b5c3d77219
commit
4894fa411c
18 changed files with 268 additions and 198 deletions
|
|
@ -364,6 +364,23 @@ export const MODELS = {
|
|||
} satisfies Model<"anthropic-messages">,
|
||||
},
|
||||
"google": {
|
||||
"gemini-3-flash-preview": {
|
||||
id: "gemini-3-flash-preview",
|
||||
name: "Gemini 3 Flash Preview",
|
||||
api: "google-generative-ai",
|
||||
provider: "google",
|
||||
baseUrl: "https://generativelanguage.googleapis.com/v1beta",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
cost: {
|
||||
input: 0.15,
|
||||
output: 0.6,
|
||||
cacheRead: 0.0375,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
maxTokens: 65536,
|
||||
} satisfies Model<"google-generative-ai">,
|
||||
"gemini-2.5-flash-preview-05-20": {
|
||||
id: "gemini-2.5-flash-preview-05-20",
|
||||
name: "Gemini 2.5 Flash Preview 05-20",
|
||||
|
|
@ -2805,6 +2822,23 @@ export const MODELS = {
|
|||
} satisfies Model<"openai-completions">,
|
||||
},
|
||||
"openrouter": {
|
||||
"google/gemini-3-flash-preview": {
|
||||
id: "google/gemini-3-flash-preview",
|
||||
name: "Google: Gemini 3 Flash Preview",
|
||||
api: "openai-completions",
|
||||
provider: "openrouter",
|
||||
baseUrl: "https://openrouter.ai/api/v1",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
cost: {
|
||||
input: 0.5,
|
||||
output: 3,
|
||||
cacheRead: 0.049999999999999996,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
maxTokens: 65535,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"mistralai/mistral-small-creative": {
|
||||
id: "mistralai/mistral-small-creative",
|
||||
name: "Mistral: Mistral Small Creative",
|
||||
|
|
|
|||
|
|
@ -302,13 +302,11 @@ function createClient(model: Model<"openai-completions">, context: Context, apiK
|
|||
const headers = { ...model.headers };
|
||||
if (model.provider === "github-copilot") {
|
||||
// Copilot expects X-Initiator to indicate whether the request is user-initiated
|
||||
// or agent-initiated (e.g. follow-up after assistant/tool messages). If there is
|
||||
// no prior message, default to user-initiated.
|
||||
// or agent-initiated. It's an agent call if ANY message in history has assistant/tool role.
|
||||
const messages = context.messages || [];
|
||||
const lastMessage = messages[messages.length - 1];
|
||||
const isAgentCall = lastMessage ? lastMessage.role !== "user" : false;
|
||||
const initiatorValue = isAgentCall ? "agent" : "user";
|
||||
headers["X-Initiator"] = initiatorValue;
|
||||
const isAgentCall = messages.some((msg) => msg.role === "assistant" || msg.role === "toolResult");
|
||||
headers["X-Initiator"] = isAgentCall ? "agent" : "user";
|
||||
headers["Openai-Intent"] = "conversation-edits";
|
||||
}
|
||||
|
||||
return new OpenAI({
|
||||
|
|
@ -431,9 +429,15 @@ function convertMessages(
|
|||
|
||||
const textBlocks = msg.content.filter((b) => b.type === "text") as TextContent[];
|
||||
if (textBlocks.length > 0) {
|
||||
assistantMsg.content = textBlocks.map((b) => {
|
||||
return { type: "text", text: sanitizeSurrogates(b.text) };
|
||||
});
|
||||
// GitHub Copilot requires assistant content as a string, not an array.
|
||||
// Sending as array causes Claude models to re-answer all previous prompts.
|
||||
if (model.provider === "github-copilot") {
|
||||
assistantMsg.content = textBlocks.map((b) => sanitizeSurrogates(b.text)).join("");
|
||||
} else {
|
||||
assistantMsg.content = textBlocks.map((b) => {
|
||||
return { type: "text", text: sanitizeSurrogates(b.text) };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Handle thinking blocks
|
||||
|
|
|
|||
|
|
@ -310,13 +310,11 @@ function createClient(model: Model<"openai-responses">, context: Context, apiKey
|
|||
const headers = { ...model.headers };
|
||||
if (model.provider === "github-copilot") {
|
||||
// Copilot expects X-Initiator to indicate whether the request is user-initiated
|
||||
// or agent-initiated (e.g. follow-up after assistant/tool messages). If there is
|
||||
// no prior message, default to user-initiated.
|
||||
// or agent-initiated. It's an agent call if ANY message in history has assistant/tool role.
|
||||
const messages = context.messages || [];
|
||||
const lastMessage = messages[messages.length - 1];
|
||||
const isAgentCall = lastMessage ? lastMessage.role !== "user" : false;
|
||||
const initiatorValue = isAgentCall ? "agent" : "user";
|
||||
headers["X-Initiator"] = initiatorValue;
|
||||
const isAgentCall = messages.some((msg) => msg.role === "assistant" || msg.role === "toolResult");
|
||||
headers["X-Initiator"] = isAgentCall ? "agent" : "user";
|
||||
headers["Openai-Intent"] = "conversation-edits";
|
||||
}
|
||||
|
||||
return new OpenAI({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue