Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lobehub/lobe-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 16, 2024
2 parents 9fb8a78 + e715709 commit 433586d
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 10 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

# Changelog

### [Version 1.17.7](https://github.com/lobehub/lobe-chat/compare/v1.17.6...v1.17.7)

<sup>Released on **2024-09-16**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix a corner case of `tools_call` with empty object.

#### 💄 Styles

- **misc**: Delete duplicate models in ollama.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

- **misc**: Fix a corner case of `tools_call` with empty object, closes [#3955](https://github.com/lobehub/lobe-chat/issues/3955) ([d3fabdc](https://github.com/lobehub/lobe-chat/commit/d3fabdc))

#### Styles

- **misc**: Delete duplicate models in ollama, closes [#3989](https://github.com/lobehub/lobe-chat/issues/3989) ([ece60ee](https://github.com/lobehub/lobe-chat/commit/ece60ee))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.17.6](https://github.com/lobehub/lobe-chat/compare/v1.17.5...v1.17.6)

<sup>Released on **2024-09-15**</sup>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.17.6",
"version": "1.17.7",
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
"keywords": [
"framework",
Expand Down
8 changes: 0 additions & 8 deletions src/config/modelProviders/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,6 @@ const Ollama: ModelProviderCard = {
tokens: 4096,
vision: true,
},
{
description: 'MiniCPM-V 是 OpenBMB 推出的新一代多模态大模型,具备卓越的 OCR 识别和多模态理解能力,支持广泛的应用场景。',
displayName: 'MiniCPM-V 8B',
enabled: true,
id: 'minicpm-v:8b',
tokens: 128_000,
vision:true,
},
{
description: 'MiniCPM-V 是 OpenBMB 推出的新一代多模态大模型,具备卓越的 OCR 识别和多模态理解能力,支持广泛的应用场景。',
displayName: 'MiniCPM-V 8B',
Expand Down
43 changes: 43 additions & 0 deletions src/libs/agent-runtime/utils/streams/openai.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,49 @@ describe('OpenAIStream', () => {
);
});

it('should handle content with tool_calls but is an empty object', async () => {
// data: {"id":"chatcmpl-A7pokGUqSov0JuMkhiHhWU9GRtAgJ", "object":"chat.completion.chunk", "created":1726430846, "model":"gpt-4o-2024-05-13", "choices":[{"index":0, "delta":{"content":" today", "role":"", "tool_calls":[]}, "finish_reason":"", "logprobs":""}], "prompt_annotations":[{"prompt_index":0, "content_filter_results":null}]}
const mockOpenAIStream = new ReadableStream({
start(controller) {
controller.enqueue({
choices: [
{
"index": 0,
"delta": {
"content": "Some contents",
"role": "",
"tool_calls": []
},
"finish_reason": "",
"logprobs": ""
}
],
id: '456',
});

controller.close();
},
});

const onToolCallMock = vi.fn();

const protocolStream = OpenAIStream(mockOpenAIStream, {
onToolCall: onToolCallMock,
});

const decoder = new TextDecoder();
const chunks = [];

// @ts-ignore
for await (const chunk of protocolStream) {
chunks.push(decoder.decode(chunk, { stream: true }));
}

expect(chunks).toEqual(
['id: 456', 'event: text', `data: "Some contents"\n`].map((i) => `${i}\n`),
);
});

it('should handle other delta data', async () => {
const mockOpenAIStream = new ReadableStream({
start(controller) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/utils/streams/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const transformOpenAIStream = (
return { data: chunk, id: chunk.id, type: 'data' };
}

if (item.delta?.tool_calls) {
if (typeof item.delta?.tool_calls === 'object' && item.delta.tool_calls?.length > 0) {
return {
data: item.delta.tool_calls.map((value, index): StreamToolCallChunkData => {
if (stack && !stack.tool) {
Expand Down

0 comments on commit 433586d

Please sign in to comment.