Merge branch 'main' into gemini-3-support
This commit is contained in:
commit
b024fa8d70
24 changed files with 529 additions and 203 deletions
|
|
@ -183,6 +183,7 @@ class CometAPI extends OpenAI {
|
|||
*/
|
||||
private static RECOMMENDED_MODELS = [
|
||||
// GPT series
|
||||
"gpt-5.1",
|
||||
"gpt-5-chat-latest",
|
||||
"chatgpt-4o-latest",
|
||||
"gpt-5-mini",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,14 @@ import {
|
|||
convertContinueToolToGeminiFunction,
|
||||
} from "./gemini-types";
|
||||
|
||||
interface GeminiToolCallDelta extends ToolCallDelta {
|
||||
extra_content?: {
|
||||
google?: {
|
||||
thought_signature?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class Gemini extends BaseLLM {
|
||||
static providerName = "gemini";
|
||||
|
||||
|
|
@ -266,18 +274,37 @@ class Gemini extends BaseLLM {
|
|||
? [{ text: msg.content }]
|
||||
: msg.content.map(this.continuePartToGeminiPart),
|
||||
};
|
||||
if (msg.toolCalls) {
|
||||
msg.toolCalls.forEach((toolCall) => {
|
||||
if (toolCall.function?.name) {
|
||||
assistantMsg.parts.push({
|
||||
functionCall: {
|
||||
name: toolCall.function.name,
|
||||
args: safeParseToolCallArgs(toolCall),
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (msg.toolCalls && msg.toolCalls.length) {
|
||||
(msg.toolCalls as GeminiToolCallDelta[]).forEach(
|
||||
(toolCall, index) => {
|
||||
if (toolCall.function?.name) {
|
||||
const signatureForCall =
|
||||
toolCall?.extra_content?.google?.thought_signature;
|
||||
|
||||
let thoughtSignature: string | undefined;
|
||||
if (index === 0) {
|
||||
if (typeof signatureForCall === "string") {
|
||||
thoughtSignature = signatureForCall;
|
||||
} else {
|
||||
// Fallback per https://ai.google.dev/gemini-api/docs/thought-signatures
|
||||
// for histories that were not generated by Gemini or are missing signatures.
|
||||
thoughtSignature = "skip_thought_signature_validator";
|
||||
}
|
||||
}
|
||||
|
||||
assistantMsg.parts.push({
|
||||
functionCall: {
|
||||
name: toolCall.function.name,
|
||||
args: safeParseToolCallArgs(toolCall),
|
||||
},
|
||||
...(thoughtSignature && { thoughtSignature }),
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return assistantMsg;
|
||||
}
|
||||
return {
|
||||
|
|
@ -370,6 +397,7 @@ class Gemini extends BaseLLM {
|
|||
if ("text" in part) {
|
||||
textParts.push({ type: "text", text: part.text });
|
||||
} else if ("functionCall" in part) {
|
||||
const thoughtSignature = part.thoughtSignature;
|
||||
toolCalls.push({
|
||||
type: "function",
|
||||
id: part.functionCall.id ?? uuidv4(),
|
||||
|
|
@ -380,6 +408,13 @@ class Gemini extends BaseLLM {
|
|||
? part.functionCall.args
|
||||
: JSON.stringify(part.functionCall.args),
|
||||
},
|
||||
...(thoughtSignature && {
|
||||
extra_content: {
|
||||
google: {
|
||||
thought_signature: thoughtSignature,
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
// Note: function responses shouldn't be streamed, images not supported
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ export type GeminiFunctionCallContentPart = {
|
|||
name: string;
|
||||
args: JSONSchema7Object;
|
||||
};
|
||||
thoughtSignature?: string;
|
||||
};
|
||||
|
||||
export type GeminiFunctionResponseContentPart = {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
|
|||
},
|
||||
xAI: (model) => {
|
||||
const lowerCaseModel = model.toLowerCase();
|
||||
return ["grok-3", "grok-4", "grok-code"].some((val) =>
|
||||
return ["grok-3", "grok-4", "grok-4-1", "grok-code"].some((val) =>
|
||||
lowerCaseModel.includes(val),
|
||||
);
|
||||
},
|
||||
|
|
@ -392,10 +392,11 @@ export function isRecommendedAgentModel(modelName: string): boolean {
|
|||
[/o[134]/],
|
||||
[/deepseek/, /r1|reasoner/],
|
||||
[/gemini/, /2\.5|3/, /pro/],
|
||||
[/gpt-5/],
|
||||
[/gpt/, /-5|5\.1/],
|
||||
[/claude/, /sonnet/, /3\.7|3-7|-4/],
|
||||
[/claude/, /opus/, /-4/],
|
||||
[/grok-code/],
|
||||
[/grok-4-1|grok-4\.1/],
|
||||
[/claude/, /4-5/],
|
||||
];
|
||||
for (const combo of recs) {
|
||||
|
|
|
|||
449
core/package-lock.json
generated
449
core/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -163,9 +163,9 @@ The `config.json` configuration format offers configuration options through `tab
|
|||
|
||||
## Autocomplete FAQs and Troubleshooting in Continue
|
||||
|
||||
### I want better completions, should I use GPT-4?
|
||||
### I want better completions, should I use GPT-5?
|
||||
|
||||
Perhaps surprisingly, the answer is no. The models that we suggest for autocomplete are trained with a highly specific prompt format, which allows them to respond to requests for completing code (see examples of these prompts [here](https://github.com/continuedev/continue/blob/main/core/autocomplete/templating/AutocompleteTemplate.ts)). Some of the best commercial models like GPT-4 or Claude are not trained with this prompt format, which means that they won't generate useful completions. Luckily, a huge model is not required for great autocomplete. Most of the state-of-the-art autocomplete models are no more than 10b parameters, and increasing beyond this does not significantly improve performance.
|
||||
Perhaps surprisingly, the answer is no. The models that we suggest for autocomplete are trained with a highly specific prompt format, which allows them to respond to requests for completing code (see examples of these prompts [here](https://github.com/continuedev/continue/blob/main/core/autocomplete/templating/AutocompleteTemplate.ts)). Some of the best commercial models like GPT-5 or Claude are not trained with this prompt format, which means that they won't generate useful completions. Luckily, a huge model is not required for great autocomplete. Most of the state-of-the-art autocomplete models are no more than 10b parameters, and increasing beyond this does not significantly improve performance.
|
||||
|
||||
### Autocomplete Not Working – How to Fix It
|
||||
|
||||
|
|
|
|||
|
|
@ -171,6 +171,8 @@ This matrix shows which models support tool use and image input capabilities. Co
|
|||
|
||||
| Model | Tool Use | Image Input | Context Window |
|
||||
| :------------ | -------- | ----------- | -------------- |
|
||||
| GPT-5.1 | Yes | No | 400k |
|
||||
| GPT-5 | Yes | No | 400k |
|
||||
| o3 | Yes | No | 128k |
|
||||
| o3-mini | Yes | No | 128k |
|
||||
| GPT-4o | Yes | Yes | 128k |
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ For example, you can say "Create a rule for this", and a rule will be created fo
|
|||
|
||||
Rules can also be created and managed on the Continue Mission Control:
|
||||
|
||||
1. **Browse existing rules**: [Explore available rules](https://hub.continue.dev/explore?type=rules)
|
||||
1. **Browse existing rules**: [Explore available rules](https://hub.continue.dev/hub?type=rules)
|
||||
2. **Create new rules**: [Create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub
|
||||
3. **Copy from local rules**: Copy/paste content from your `.continue/rules` files to create Hub rules
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ slug: ../asksage
|
|||
---
|
||||
|
||||
<Tip>
|
||||
**Discover Ask Sage models [here](https://hub.continue.dev/explore?q=Ask%20Sage)**
|
||||
**Discover Ask Sage models [here](https://hub.continue.dev/hub?q=Ask%20Sage)**
|
||||
</Tip>
|
||||
|
||||
<Info>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ slug: ../deepseek
|
|||
---
|
||||
|
||||
<Tip>
|
||||
**Discover DeepSeek models [here](https://hub.continue.dev/explore?q=DeepSeek)**
|
||||
**Discover DeepSeek models [here](https://hub.continue.dev/hub?q=DeepSeek)**
|
||||
</Tip>
|
||||
|
||||
<Info>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ sidebarTitle: "Gemini"
|
|||
---
|
||||
|
||||
<Tip>
|
||||
**Discover Google models [here](https://hub.continue.dev/explore?q=Gemini)**
|
||||
**Discover Google models [here](https://hub.continue.dev/hub?q=Gemini)**
|
||||
</Tip>
|
||||
|
||||
<Info>
|
||||
|
|
|
|||
|
|
@ -76,39 +76,39 @@ If you prefer to use an open-weight model, then the Gemma family of Models from
|
|||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### GPT-4o from OpenAI
|
||||
### GPT-5.1 from OpenAI
|
||||
|
||||
If you prefer to use a model from [OpenAI](../model-providers/top-level/openai), then we recommend GPT-4o.
|
||||
If you prefer to use a model from [OpenAI](../model-providers/top-level/openai), then we recommend GPT-5.1.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Hub">
|
||||
Add the [OpenAI GPT-4o block](https://hub.continue.dev/openai/gpt-4o) from the hub
|
||||
Add the [OpenAI GPT-5.1 block](https://hub.continue.dev/openai/gpt-5.1) from the hub
|
||||
</Tab>
|
||||
<Tab title="YAML">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: GPT-4o
|
||||
- name: GPT-5.1
|
||||
provider: openai
|
||||
model: ''
|
||||
model: gpt-5.1
|
||||
apiKey: <YOUR_OPENAI_API_KEY>
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Grok-2 from xAI
|
||||
### Grok-4 from xAI
|
||||
|
||||
If you prefer to use a model from [xAI](../model-providers/more/xAI), then we recommend Grok-2.
|
||||
If you prefer to use a model from [xAI](../model-providers/more/xAI), then we recommend Grok-4.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Hub">
|
||||
Add the [xAI Grok-2 block](https://hub.continue.dev/xai/grok-2) from the hub
|
||||
Add the [xAI Grok-4.1 block](https://hub.continue.dev/xai/grok-4-1-fast-non-reasoning) from the hub
|
||||
</Tab>
|
||||
<Tab title="YAML">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: Grok-2
|
||||
- name: Grok-4.1
|
||||
provider: xAI
|
||||
model: grok-2-latest
|
||||
model: grok-4-1-fast-non-reasoning
|
||||
apiKey: <YOUR_XAI_API_KEY>
|
||||
```
|
||||
</Tab>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ description: "These are the specialized instructions that shape how models and a
|
|||
|
||||
## Learn More
|
||||
|
||||
- [Explore prompts](https://hub.continue.dev/explore?type=prompts) on the Hub
|
||||
- [Explore prompts](https://hub.continue.dev/hub?type=prompts) on the Hub
|
||||
- Learn more in the [prompts deep dive](/customize/deep-dives/prompts)
|
||||
- View [`prompts`](/reference#prompts) in the YAML Reference for more details
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ models:
|
|||
|
||||
## How to Add MCP Tools
|
||||
|
||||
You can add MCP servers to your configuration to give Agent mode access to more tools. Explore [MCP Servers on Mission Control](https://hub.continue.dev/explore?type=mcpServers) and consult the [MCP guide](/customize/deep-dives/mcp) for more details.
|
||||
You can add MCP servers to your configuration to give Agent mode access to more tools. Explore [MCP Servers on Mission Control](https://hub.continue.dev/hub?type=mcpServers) and consult the [MCP guide](/customize/deep-dives/mcp) for more details.
|
||||
|
||||
## How to Configure Tool Policies
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ You can interact with configs in three main ways:
|
|||
|
||||
<Step title="Explore existing configs">
|
||||
|
||||
Browse the [Continue Mission Control](https://hub.continue.dev/explore?type=configs) to see what configs others have built
|
||||
Browse the [Continue Mission Control](https://hub.continue.dev/hub?type=configs) to see what configs others have built
|
||||
|
||||
</Step>
|
||||
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ export const MCPSelector: React.FC<MCPSelectorProps> = ({ onCancel }) => {
|
|||
case "explore-mcp-servers":
|
||||
// Open the MCP servers hub in the default browser
|
||||
const open = (await import("open")).default;
|
||||
await open("https://hub.continue.dev/explore?type=mcpServers");
|
||||
await open("https://hub.continue.dev/hub?type=mcpServers");
|
||||
setMessage("Opened MCP servers hub in browser");
|
||||
break;
|
||||
case "back":
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export function isModelCapable(
|
|||
const normalizedName = name.toLowerCase();
|
||||
const normalizedModel = model ? model.toLowerCase() : "";
|
||||
|
||||
const patterns = [/gemini/, /claude/, /gpt/, /o\d/, /kimi/, /qwen/];
|
||||
const patterns = [/gemini/, /claude/, /gpt/, /o\d/, /kimi/, /qwen/, /grok/];
|
||||
|
||||
// If either name OR model matches any of the patterns, consider it capable
|
||||
if (patterns.some((pattern) => pattern.test(normalizedName))) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.3.26",
|
||||
"version": "1.3.27",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
|
|
@ -1135,6 +1135,18 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
gpt5_1: {
|
||||
title: "GPT-5.1",
|
||||
description: "OpenAI's GPT-5.1 model for advanced reasoning and chat",
|
||||
params: {
|
||||
model: "gpt-5.1",
|
||||
contextLength: 400_000,
|
||||
title: "GPT-5.1",
|
||||
},
|
||||
providerOptions: ["openai"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
gpt5Codex: {
|
||||
title: "GPT-5 Codex",
|
||||
description:
|
||||
|
|
@ -1922,6 +1934,34 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok41FastReasoning: {
|
||||
title: "Grok 4.1 Fast Reasoning",
|
||||
description:
|
||||
"xAI's upgraded reasoning model offering strong performance in complex tasks.",
|
||||
refUrl: "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
params: {
|
||||
title: "Grok 4.1 Fast Reasoning",
|
||||
model: "grok-4-1-fast-reasoning",
|
||||
contextLength: 2_000_000,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok41FastNonReasoning: {
|
||||
title: "Grok 4.1 Fast Non-Reasoning",
|
||||
description:
|
||||
"xAI's upgraded non-reasoning model optimized for speed and efficiency.",
|
||||
refUrl: "https://docs.x.ai/docs/models/grok-4-1-fast-non-reasoning",
|
||||
params: {
|
||||
title: "Grok 4.1 Fast Non-Reasoning",
|
||||
model: "grok-4-1-fast-non-reasoning",
|
||||
contextLength: 2_000_000,
|
||||
},
|
||||
icon: "xAI.png",
|
||||
providerOptions: ["xAI"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
grok4: {
|
||||
title: "Grok 4",
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -111,13 +111,14 @@ export const providers: Partial<Record<string, ProviderInfo>> = {
|
|||
openai: {
|
||||
title: "OpenAI",
|
||||
provider: "openai",
|
||||
description: "Use gpt-5, gpt-4, or any other OpenAI model",
|
||||
description: "Use gpt-5.1, gpt-5, gpt-4, or any other OpenAI model",
|
||||
longDescription:
|
||||
"Use gpt-5, gpt-4, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.",
|
||||
"Use gpt-5.1, gpt-5, gpt-4, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.",
|
||||
icon: "openai.png",
|
||||
tags: [ModelProviderTags.RequiresApiKey],
|
||||
packages: [
|
||||
models.gpt5,
|
||||
models.gpt5_1,
|
||||
models.gpt5Codex,
|
||||
models.gpt4o,
|
||||
models.gpt4omini,
|
||||
|
|
@ -625,6 +626,8 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
models.grokCodeFast1,
|
||||
models.grok4FastReasoning,
|
||||
models.grok4FastNonReasoning,
|
||||
models.grok41FastReasoning,
|
||||
models.grok41FastNonReasoning,
|
||||
models.grok4,
|
||||
models.grok3,
|
||||
models.grok3Mini,
|
||||
|
|
|
|||
|
|
@ -182,10 +182,19 @@ export const CometAPI: ModelProvider = {
|
|||
},
|
||||
|
||||
// Grok Series
|
||||
{
|
||||
model: "grok-4-1-fast-reasoning",
|
||||
displayName: "Grok 4.1 Fast Reasoning",
|
||||
contextLength: 256000,
|
||||
maxCompletionTokens: 4096,
|
||||
description:
|
||||
"Latest Grok model with faster and improved reasoning and conversational abilities.",
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
{
|
||||
model: "grok-4-0709",
|
||||
displayName: "Grok 4 (07-09)",
|
||||
contextLength: 128000,
|
||||
contextLength: 256000,
|
||||
maxCompletionTokens: 4096,
|
||||
description:
|
||||
"Latest Grok model with improved reasoning and conversational abilities.",
|
||||
|
|
|
|||
|
|
@ -92,6 +92,14 @@ export const OpenAi: ModelProvider = {
|
|||
regex: /gpt-5-codex/,
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
{
|
||||
model: "gpt-5.1",
|
||||
displayName: "GPT-5.1",
|
||||
contextLength: 400000,
|
||||
maxCompletionTokens: 128000,
|
||||
regex: /^gpt-5\.1$/,
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
// gpt-4o
|
||||
{
|
||||
model: "gpt-4o",
|
||||
|
|
|
|||
|
|
@ -52,7 +52,21 @@ export const xAI: ModelProvider = {
|
|||
displayName: "Grok 4 Fast",
|
||||
contextLength: 256000,
|
||||
recommendedFor: ["chat"],
|
||||
regex: /grok-4/,
|
||||
regex: /^grok-4$/,
|
||||
},
|
||||
{
|
||||
model: "grok-4-1-fast-reasoning",
|
||||
displayName: "Grok 4.1 Fast Reasoning",
|
||||
contextLength: 256000,
|
||||
recommendedFor: ["chat"],
|
||||
regex: /grok-4-1-fast-reasoning/,
|
||||
},
|
||||
{
|
||||
model: "grok-4-1-fast-non-reasoning",
|
||||
displayName: "Grok 4.1 Fast Non Reasoning",
|
||||
contextLength: 256000,
|
||||
recommendedFor: ["chat"],
|
||||
regex: /grok-4-1-fast-non-reasoning/,
|
||||
},
|
||||
{
|
||||
model: "grok-code-fast-1",
|
||||
|
|
|
|||
|
|
@ -44,6 +44,24 @@ type UsageInfo = Pick<
|
|||
"total_tokens" | "completion_tokens" | "prompt_tokens"
|
||||
>;
|
||||
|
||||
interface GeminiToolCall
|
||||
extends OpenAI.Chat.Completions.ChatCompletionMessageFunctionToolCall {
|
||||
extra_content?: {
|
||||
google?: {
|
||||
thought_signature?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface GeminiToolDelta
|
||||
extends OpenAI.Chat.Completions.ChatCompletionChunk.Choice.Delta {
|
||||
extra_content?: {
|
||||
google?: {
|
||||
thought_signature?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export class GeminiApi implements BaseLlmApi {
|
||||
apiBase: string = "https://generativelanguage.googleapis.com/v1beta/";
|
||||
|
||||
|
|
@ -143,25 +161,43 @@ export class GeminiApi implements BaseLlmApi {
|
|||
|
||||
return {
|
||||
role: "model" as const,
|
||||
parts: msg.tool_calls.map((toolCall) => {
|
||||
// Type guard for function tool calls
|
||||
if (toolCall.type === "function" && "function" in toolCall) {
|
||||
return {
|
||||
functionCall: {
|
||||
id: includeToolCallIds ? toolCall.id : undefined,
|
||||
name: toolCall.function.name,
|
||||
args: safeParseArgs(
|
||||
toolCall.function.arguments,
|
||||
`Call: ${toolCall.function.name} ${toolCall.id}`,
|
||||
),
|
||||
},
|
||||
};
|
||||
} else {
|
||||
parts: (msg.tool_calls as GeminiToolCall[]).map(
|
||||
(toolCall, index) => {
|
||||
if (toolCall.type === "function" && "function" in toolCall) {
|
||||
let thoughtSignature: string | undefined;
|
||||
if (index === 0) {
|
||||
const rawSignature =
|
||||
toolCall?.extra_content?.google?.thought_signature;
|
||||
|
||||
if (
|
||||
typeof rawSignature === "string" &&
|
||||
rawSignature.length > 0
|
||||
) {
|
||||
thoughtSignature = rawSignature;
|
||||
} else {
|
||||
// Fallback per https://ai.google.dev/gemini-api/docs/thought-signatures
|
||||
// for histories that were not generated by Gemini or are missing signatures.
|
||||
thoughtSignature = "skip_thought_signature_validator";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
functionCall: {
|
||||
id: includeToolCallIds ? toolCall.id : undefined,
|
||||
name: toolCall.function.name,
|
||||
args: safeParseArgs(
|
||||
toolCall.function.arguments,
|
||||
`Call: ${toolCall.function.name} ${toolCall.id}`,
|
||||
),
|
||||
},
|
||||
...(thoughtSignature && { thoughtSignature }),
|
||||
};
|
||||
}
|
||||
throw new Error(
|
||||
`Unsupported tool call type in Gemini: ${toolCall.type}`,
|
||||
);
|
||||
}
|
||||
}),
|
||||
},
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -328,11 +364,27 @@ export class GeminiApi implements BaseLlmApi {
|
|||
if (contentParts) {
|
||||
for (const part of contentParts) {
|
||||
if ("text" in part) {
|
||||
const thoughtSignature = part?.thoughtSignature;
|
||||
if (thoughtSignature) {
|
||||
yield chatChunkFromDelta({
|
||||
model,
|
||||
delta: {
|
||||
role: "assistant",
|
||||
extra_content: {
|
||||
google: {
|
||||
thought_signature: thoughtSignature,
|
||||
},
|
||||
},
|
||||
} as GeminiToolDelta,
|
||||
});
|
||||
}
|
||||
|
||||
yield chatChunk({
|
||||
content: part.text,
|
||||
model,
|
||||
});
|
||||
} else if ("functionCall" in part) {
|
||||
const thoughtSignature = part?.thoughtSignature;
|
||||
yield chatChunkFromDelta({
|
||||
model,
|
||||
delta: {
|
||||
|
|
@ -345,6 +397,13 @@ export class GeminiApi implements BaseLlmApi {
|
|||
name: part.functionCall.name,
|
||||
arguments: JSON.stringify(part.functionCall.args),
|
||||
},
|
||||
...(thoughtSignature && {
|
||||
extra_content: {
|
||||
google: {
|
||||
thought_signature: thoughtSignature,
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue