Skip to content

Commit 60739bc

Browse files
authored
🐛 fix(groq): Enable streaming for tool calls and add Kimi K2 model (#8510)
1 parent 75273d5 commit 60739bc

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

src/config/aiModels/groq.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ const groqChatModels: AIChatModelCard[] = [
2323
maxOutput: 8192,
2424
type: 'chat',
2525
},
26+
{
27+
abilities: {
28+
functionCall: true,
29+
},
30+
contextWindowTokens: 131_072,
31+
description:
32+
'kimi-k2 是一款具备超强代码和 Agent 能力的 MoE 架构基础模型,总参数 1T,激活参数 32B。在通用知识推理、编程、数学、Agent 等主要类别的基准性能测试中,K2 模型的性能超过其他主流开源模型。',
33+
displayName: 'Kimi K2 Instruct',
34+
enabled: true,
35+
id: 'moonshotai/kimi-k2-instruct',
36+
pricing: {
37+
input: 1,
38+
output: 3,
39+
},
40+
releasedAt: '2025-07-11',
41+
type: 'chat',
42+
},
2643
{
2744
contextWindowTokens: 131_072,
2845
displayName: 'Llama 4 Scout (17Bx16E)',

src/libs/model-runtime/groq/index.test.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,7 @@ afterEach(() => {
3434

3535
describe('LobeGroqAI Temperature Tests', () => {
3636
describe('handlePayload option', () => {
37-
it('should set stream to false when payload contains tools', async () => {
38-
const mockCreateMethod = vi
39-
.spyOn(instance['client'].chat.completions, 'create')
40-
.mockResolvedValue({
41-
id: 'chatcmpl-8xDx5AETP8mESQN7UB30GxTN2H1SO',
42-
object: 'chat.completion',
43-
created: 1709125675,
44-
model: 'mistralai/mistral-7b-instruct:free',
45-
system_fingerprint: 'fp_86156a94a0',
46-
choices: [
47-
{
48-
index: 0,
49-
message: { role: 'assistant', content: 'hello', refusal: null },
50-
logprobs: null,
51-
finish_reason: 'stop',
52-
},
53-
],
54-
});
55-
37+
it('should not set stream to false when payload contains tools', async () => {
5638
await instance.chat({
5739
messages: [{ content: 'Hello', role: 'user' }],
5840
model: 'mistralai/mistral-7b-instruct:free',
@@ -65,8 +47,8 @@ describe('LobeGroqAI Temperature Tests', () => {
6547
],
6648
});
6749

68-
expect(mockCreateMethod).toHaveBeenCalledWith(
69-
expect.objectContaining({ stream: false }),
50+
expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
51+
expect.objectContaining({ stream: true }),
7052
expect.anything(),
7153
);
7254
});

src/libs/model-runtime/groq/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ export const LobeGroq = createOpenAICompatibleRuntime({
2121
const { temperature, ...restPayload } = payload;
2222
return {
2323
...restPayload,
24-
// disable stream for tools due to groq dont support
25-
stream: !payload.tools,
24+
stream: payload.stream ?? true,
2625

2726
temperature: temperature <= 0 ? undefined : temperature,
2827
} as any;

0 commit comments

Comments
 (0)