mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-15 20:16:02 +00:00
🐛 fix(groq): Enable streaming for tool calls and add Kimi K2 model (#8510)
This commit is contained in:
@@ -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)',
|
||||
|
||||
@@ -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(),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user