@lobehub/chat 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/docs/self-hosting/advanced/model-list.mdx +1 -1
- package/docs/self-hosting/advanced/model-list.zh-CN.mdx +1 -1
- package/package.json +1 -1
- package/src/libs/agent-runtime/google/index.test.ts +3 -33
- package/src/libs/agent-runtime/google/index.ts +1 -16
- package/src/utils/parseModels.test.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 1.4.2](https://github.com/lobehub/lobe-chat/compare/v1.4.1...v1.4.2)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-07-13**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Remove code related to `gemini-pro-vision`.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Remove code related to `gemini-pro-vision`, closes [#2860](https://github.com/lobehub/lobe-chat/issues/2860) ([e2ba302](https://github.com/lobehub/lobe-chat/commit/e2ba302))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 1.4.1](https://github.com/lobehub/lobe-chat/compare/v1.4.0...v1.4.1)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-07-13**</sup>
|
|
@@ -36,7 +36,7 @@ Examples are as follows:
|
|
|
36
36
|
|
|
37
37
|
- `chatglm-6b=ChatGLM 6B<4096>`: ChatGLM 6B, maximum context of 4k, no advanced capabilities;
|
|
38
38
|
- `spark-v3.5=讯飞星火 v3.5<8192:fc>`: Xunfei Spark 3.5 model, maximum context of 8k, supports Function Call;
|
|
39
|
-
- `gemini-
|
|
39
|
+
- `gemini-1.5-flash-latest=Gemini 1.5 Flash<16000:vision>`: Google Vision model, maximum context of 16k, supports image recognition;
|
|
40
40
|
- `gpt-4-all=ChatGPT Plus<128000:fc:vision:file>`, hacked version of ChatGPT Plus web, context of 128k, supports image recognition, Function Call, file upload.
|
|
41
41
|
|
|
42
42
|
Currently supported extension capabilities are:
|
|
@@ -35,7 +35,7 @@ id=displayName<maxToken:vision:fc:file>
|
|
|
35
35
|
|
|
36
36
|
- `chatglm-6b=ChatGLM 6B<4096>`:ChatGLM 6B,最大上下文 4k,没有高阶能力;
|
|
37
37
|
- `spark-v3.5=讯飞星火 v3.5<8192:fc>`:讯飞星火 3.5 模型,最大上下文 8k,支持 Function Call;
|
|
38
|
-
- `gemini-
|
|
38
|
+
- `gemini-1.5-flash-latest=Gemini 1.5 Flash<16000:vision>`:Google 视觉模型,最大上下文 16k,支持图像识别;
|
|
39
39
|
- `gpt-4-all=ChatGPT Plus<128000:fc:vision:file>`,hack 的 ChatGPT Plus 网页版,上下 128k ,支持图像识别、Function Call、文件上传
|
|
40
40
|
|
|
41
41
|
目前支持的扩展能力有:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"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.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { FunctionDeclarationSchemaType, FunctionDeclarationsTool } from '@google/generative-ai';
|
|
3
3
|
import { JSONSchema7 } from 'json-schema';
|
|
4
4
|
import OpenAI from 'openai';
|
|
5
|
-
import {
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { OpenAIChatMessage } from '@/libs/agent-runtime';
|
|
8
8
|
|
|
9
9
|
import * as debugStreamModule from '../utils/debugStream';
|
|
10
10
|
import { LobeGoogleAI } from './index';
|
|
@@ -383,7 +383,7 @@ describe('LobeGoogleAI', () => {
|
|
|
383
383
|
role: 'user',
|
|
384
384
|
},
|
|
385
385
|
];
|
|
386
|
-
const model = 'gemini-
|
|
386
|
+
const model = 'gemini-1.5-flash-latest';
|
|
387
387
|
|
|
388
388
|
// 调用 buildGoogleMessages 方法
|
|
389
389
|
const contents = instance['buildGoogleMessages'](messages, model);
|
|
@@ -398,36 +398,6 @@ describe('LobeGoogleAI', () => {
|
|
|
398
398
|
});
|
|
399
399
|
});
|
|
400
400
|
|
|
401
|
-
describe('convertModel', () => {
|
|
402
|
-
it('should use default text model when no images are included in messages', () => {
|
|
403
|
-
const messages: OpenAIChatMessage[] = [
|
|
404
|
-
{ content: 'Hello', role: 'user' },
|
|
405
|
-
{ content: 'Hi', role: 'assistant' },
|
|
406
|
-
];
|
|
407
|
-
|
|
408
|
-
// 调用 buildGoogleMessages 方法
|
|
409
|
-
const model = instance['convertModel']('gemini-pro-vision', messages);
|
|
410
|
-
|
|
411
|
-
expect(model).toEqual('gemini-pro'); // 假设 'gemini-pro' 是默认文本模型
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it('should use specified model when images are included in messages', () => {
|
|
415
|
-
const messages: OpenAIChatMessage[] = [
|
|
416
|
-
{
|
|
417
|
-
content: [
|
|
418
|
-
{ type: 'text', text: 'Hello' },
|
|
419
|
-
{ type: 'image_url', image_url: { url: 'data:image/png;base64,...' } },
|
|
420
|
-
],
|
|
421
|
-
role: 'user',
|
|
422
|
-
},
|
|
423
|
-
];
|
|
424
|
-
|
|
425
|
-
const model = instance['convertModel']('gemini-pro-vision', messages);
|
|
426
|
-
|
|
427
|
-
expect(model).toEqual('gemini-pro-vision');
|
|
428
|
-
});
|
|
429
|
-
});
|
|
430
|
-
|
|
431
401
|
describe('buildGoogleTools', () => {
|
|
432
402
|
it('should return undefined when tools is undefined or empty', () => {
|
|
433
403
|
expect(instance['buildGoogleTools'](undefined)).toBeUndefined();
|
|
@@ -50,7 +50,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {
|
|
|
50
50
|
|
|
51
51
|
async chat(payload: ChatStreamPayload, options?: ChatCompetitionOptions) {
|
|
52
52
|
try {
|
|
53
|
-
const model =
|
|
53
|
+
const model = payload.model;
|
|
54
54
|
|
|
55
55
|
const contents = this.buildGoogleMessages(payload.messages, model);
|
|
56
56
|
|
|
@@ -197,21 +197,6 @@ export class LobeGoogleAI implements LobeRuntimeAI {
|
|
|
197
197
|
return contents;
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
private convertModel = (model: string, messages: OpenAIChatMessage[]) => {
|
|
201
|
-
let finalModel: string = model;
|
|
202
|
-
|
|
203
|
-
if (model.includes('pro-vision')) {
|
|
204
|
-
// if message are all text message, use vision will return an error:
|
|
205
|
-
// "[400 Bad Request] Add an image to use models/gemini-pro-vision, or switch your model to a text model."
|
|
206
|
-
const noNeedVision = messages.every((m) => typeof m.content === 'string');
|
|
207
|
-
|
|
208
|
-
// so we need to downgrade to gemini-pro
|
|
209
|
-
if (noNeedVision) finalModel = 'gemini-pro';
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return finalModel;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
200
|
private parseErrorMessage(message: string): {
|
|
216
201
|
error: any;
|
|
217
202
|
errorType: ILobeAgentRuntimeErrorType;
|
|
@@ -49,14 +49,14 @@ describe('parseModelString', () => {
|
|
|
49
49
|
|
|
50
50
|
it('multi models', () => {
|
|
51
51
|
const result = parseModelString(
|
|
52
|
-
'gemini-
|
|
52
|
+
'gemini-1.5-flash-latest=Gemini 1.5 Flash<16000:vision>,gpt-4-all=ChatGPT Plus<128000:fc:vision:file>',
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
expect(result.add).toEqual([
|
|
56
56
|
{
|
|
57
|
-
displayName: 'Gemini
|
|
57
|
+
displayName: 'Gemini 1.5 Flash',
|
|
58
58
|
vision: true,
|
|
59
|
-
id: 'gemini-
|
|
59
|
+
id: 'gemini-1.5-flash-latest',
|
|
60
60
|
tokens: 16000,
|
|
61
61
|
},
|
|
62
62
|
{
|