🐛 fix(groq): Enable streaming for tool calls and add Kimi K2 model (#8510)

This commit is contained in:
afon
2025-07-21 23:45:30 +08:00
committed by GitHub
parent 75273d5497
commit 60739bc903
3 changed files with 21 additions and 23 deletions
+17
View File
@@ -23,6 +23,23 @@ const groqChatModels: AIChatModelCard[] = [
maxOutput: 8192,
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description:
'kimi-k2 是一款具备超强代码和 Agent 能力的 MoE 架构基础模型,总参数 1T,激活参数 32B。在通用知识推理、编程、数学、Agent 等主要类别的基准性能测试中,K2 模型的性能超过其他主流开源模型。',
displayName: 'Kimi K2 Instruct',
enabled: true,
id: 'moonshotai/kimi-k2-instruct',
pricing: {
input: 1,
output: 3,
},
releasedAt: '2025-07-11',
type: 'chat',
},
{
contextWindowTokens: 131_072,
displayName: 'Llama 4 Scout (17Bx16E)',
+3 -21
View File
@@ -34,25 +34,7 @@ afterEach(() => {
describe('LobeGroqAI Temperature Tests', () => {
describe('handlePayload option', () => {
it('should set stream to false when payload contains tools', async () => {
const mockCreateMethod = vi
.spyOn(instance['client'].chat.completions, 'create')
.mockResolvedValue({
id: 'chatcmpl-8xDx5AETP8mESQN7UB30GxTN2H1SO',
object: 'chat.completion',
created: 1709125675,
model: 'mistralai/mistral-7b-instruct:free',
system_fingerprint: 'fp_86156a94a0',
choices: [
{
index: 0,
message: { role: 'assistant', content: 'hello', refusal: null },
logprobs: null,
finish_reason: 'stop',
},
],
});
it('should not set stream to false when payload contains tools', async () => {
await instance.chat({
messages: [{ content: 'Hello', role: 'user' }],
model: 'mistralai/mistral-7b-instruct:free',
@@ -65,8 +47,8 @@ describe('LobeGroqAI Temperature Tests', () => {
],
});
expect(mockCreateMethod).toHaveBeenCalledWith(
expect.objectContaining({ stream: false }),
expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
expect.objectContaining({ stream: true }),
expect.anything(),
);
});
+1 -2
View File
@@ -21,8 +21,7 @@ export const LobeGroq = createOpenAICompatibleRuntime({
const { temperature, ...restPayload } = payload;
return {
...restPayload,
// disable stream for tools due to groq dont support
stream: !payload.tools,
stream: payload.stream ?? true,
temperature: temperature <= 0 ? undefined : temperature,
} as any;