mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 08:00:59 +00:00
parent
575dcb2676
commit
0dbc1065ad
3 changed files with 30 additions and 0 deletions
|
|
@ -309,6 +309,20 @@ function createClient(model: Model<"openai-completions">, context: Context, apiK
|
|||
const isAgentCall = lastMessage ? lastMessage.role !== "user" : false;
|
||||
headers["X-Initiator"] = isAgentCall ? "agent" : "user";
|
||||
headers["Openai-Intent"] = "conversation-edits";
|
||||
|
||||
// Copilot requires this header when sending images
|
||||
const hasImages = messages.some((msg) => {
|
||||
if (msg.role === "user" && Array.isArray(msg.content)) {
|
||||
return msg.content.some((c) => c.type === "image");
|
||||
}
|
||||
if (msg.role === "toolResult" && Array.isArray(msg.content)) {
|
||||
return msg.content.some((c) => c.type === "image");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (hasImages) {
|
||||
headers["Copilot-Vision-Request"] = "true";
|
||||
}
|
||||
}
|
||||
|
||||
return new OpenAI({
|
||||
|
|
|
|||
|
|
@ -317,6 +317,20 @@ function createClient(model: Model<"openai-responses">, context: Context, apiKey
|
|||
const isAgentCall = lastMessage ? lastMessage.role !== "user" : false;
|
||||
headers["X-Initiator"] = isAgentCall ? "agent" : "user";
|
||||
headers["Openai-Intent"] = "conversation-edits";
|
||||
|
||||
// Copilot requires this header when sending images
|
||||
const hasImages = messages.some((msg) => {
|
||||
if (msg.role === "user" && Array.isArray(msg.content)) {
|
||||
return msg.content.some((c) => c.type === "image");
|
||||
}
|
||||
if (msg.role === "toolResult" && Array.isArray(msg.content)) {
|
||||
return msg.content.some((c) => c.type === "image");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (hasImages) {
|
||||
headers["Copilot-Vision-Request"] = "true";
|
||||
}
|
||||
}
|
||||
|
||||
return new OpenAI({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue