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 13, 2024
2 parents 0558da9 + d5cd070 commit e785a40
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 91 deletions.
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,89 @@

# Changelog

## [Version 1.17.0](https://github.com/lobehub/lobe-chat/compare/v1.16.14...v1.17.0)

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

#### ✨ Features

- **misc**: Support openai new OpenAI o1-preview/o1-mini models.

#### 💄 Styles

- **misc**: Support Google Model List.

<br/>

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

#### What's improved

- **misc**: Support openai new OpenAI o1-preview/o1-mini models, closes [#3943](https://github.com/lobehub/lobe-chat/issues/3943) ([61bfeb2](https://github.com/lobehub/lobe-chat/commit/61bfeb2))

#### Styles

- **misc**: Support Google Model List, closes [#3938](https://github.com/lobehub/lobe-chat/issues/3938) ([be4efc7](https://github.com/lobehub/lobe-chat/commit/be4efc7))

</details>

<div align="right">

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

</div>

### [Version 1.16.14](https://github.com/lobehub/lobe-chat/compare/v1.16.13...v1.16.14)

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

#### 💄 Styles

- **model**: Remove `OpenAI` deprecated model.

<br/>

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

#### Styles

- **model**: Remove `OpenAI` deprecated model, closes [#3465](https://github.com/lobehub/lobe-chat/issues/3465) ([68a4fb2](https://github.com/lobehub/lobe-chat/commit/68a4fb2))

</details>

<div align="right">

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

</div>

### [Version 1.16.13](https://github.com/lobehub/lobe-chat/compare/v1.16.12...v1.16.13)

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

#### 💄 Styles

- **misc**: Update siliconcloud model.

<br/>

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

#### Styles

- **misc**: Update siliconcloud model, closes [#3935](https://github.com/lobehub/lobe-chat/issues/3935) ([882e981](https://github.com/lobehub/lobe-chat/commit/882e981))

</details>

<div align="right">

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

</div>

### [Version 1.16.12](https://github.com/lobehub/lobe-chat/compare/v1.16.11...v1.16.12)

<sup>Released on **2024-09-12**</sup>
Expand Down
1 change: 0 additions & 1 deletion docs/usage/agents/model.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tags:
## ChatGPT

- **gpt-3.5-turbo**: Currently the fastest generating ChatGPT model, it is faster but may sacrifice some text quality, with a context length of 4k.
- **gpt-3.5-turbo-16k**: Similar to gpt-4, the context limit is increased to 16k tokens, with a higher cost.
- **gpt-4**: ChatGPT 4.0 has improved language understanding and generation capabilities compared to 3.5. It can better understand context and context, and generate more accurate and natural responses. This is thanks to improvements in the GPT-4 model, including better language modeling and deeper semantic understanding, but it may be slower than other models, with a context length of 8k.
- **gpt-4-32k**: Similar to gpt-4, the context limit is increased to 32k tokens, with a higher cost.

Expand Down
1 change: 0 additions & 1 deletion docs/usage/agents/model.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ tags:
## ChatGPT

- **gpt-3.5-turbo**:目前最生成速度最快的 chatgpt 模型更快,但可能会牺牲一些生成文本的质量,上下文长度为 4k。
- **gpt-3.5-turbo-16k**:同 gpt-4,上下文限制增加到 16k token,同时费率更高。
- **gpt-4**:ChatGPT 4.0 在语言理解和生成能力方面相对于 3.5 有所提升。它可以更好地理解上下文和语境,并生成更准确、自然的回答。这得益于 GPT-4 模型的改进,包括更好的语言建模和更深入的语义理解,但它的速度可能比其他模型慢,上下文长度为 8k。
- **gpt-4-32k**:同 gpt-4,上下文限制增加到 32k token,同时费率更高。

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.16.12",
"version": "1.17.0",
"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
2 changes: 2 additions & 0 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const getLLMConfig = () => {
ENABLED_GOOGLE: z.boolean(),
GOOGLE_API_KEY: z.string().optional(),
GOOGLE_PROXY_URL: z.string().optional(),
GOOGLE_MODEL_LIST: z.string().optional(),

ENABLED_MOONSHOT: z.boolean(),
MOONSHOT_API_KEY: z.string().optional(),
Expand Down Expand Up @@ -134,6 +135,7 @@ export const getLLMConfig = () => {
ENABLED_GOOGLE: !!process.env.GOOGLE_API_KEY,
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY,
GOOGLE_PROXY_URL: process.env.GOOGLE_PROXY_URL,
GOOGLE_MODEL_LIST: process.env.GOOGLE_MODEL_LIST,

ENABLED_PERPLEXITY: !!process.env.PERPLEXITY_API_KEY,
PERPLEXITY_API_KEY: process.env.PERPLEXITY_API_KEY,
Expand Down
65 changes: 28 additions & 37 deletions src/config/modelProviders/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@ import { ModelProviderCard } from '@/types/llm';
// ref: https://platform.openai.com/docs/deprecations
const OpenAI: ModelProviderCard = {
chatModels: [
{
description:
'o1-mini是一款针对编程、数学和科学应用场景而设计的快速、经济高效的推理模型。该模型具有128K上下文和2023年10月的知识截止日期。',
displayName: 'OpenAI o1-mini',
enabled: true,
id: 'o1-mini',
maxOutput: 65_536,
pricing: {
input: 3,
output: 12,
},
releasedAt: '2024-09-12',
tokens: 128_000,
},
{
description:
'o1是OpenAI新的推理模型,适用于需要广泛通用知识的复杂任务。该模型具有128K上下文和2023年10月的知识截止日期。',
displayName: 'OpenAI o1-preview',
enabled: true,
id: 'o1-preview',
maxOutput: 32_768,
pricing: {
input: 15,
output: 60,
},
releasedAt: '2024-09-12',
tokens: 128_000,
},
{
description:
'GPT-4o mini是OpenAI在GPT-4 Omni之后推出的最新模型,支持图文输入并输出文本。作为他们最先进的小型模型,它比其他近期的前沿模型便宜很多,并且比GPT-3.5 Turbo便宜超过60%。它保持了最先进的智能,同时具有显著的性价比。GPT-4o mini在MMLU测试中获得了 82% 的得分,目前在聊天偏好上排名高于 GPT-4。',
Expand Down Expand Up @@ -253,43 +281,6 @@ const OpenAI: ModelProviderCard = {
},
tokens: 4096,
},
{
description:
'GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125', // Will be discontinued on September 13, 2024

displayName: 'GPT-3.5 Turbo 16K',
id: 'gpt-3.5-turbo-16k',
legacy: true,
pricing: {
input: 3,
output: 4,
},
tokens: 16_385,
},
{
description:
'GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。',
displayName: 'GPT-3.5 Turbo 0613',
// Will be discontinued on September 13, 2024
id: 'gpt-3.5-turbo-0613',
legacy: true,
pricing: {
input: 1.5,
output: 2,
},
tokens: 4096,
},
{
description:
'GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。', // Will be discontinued on September 13, 2024
id: 'gpt-3.5-turbo-16k-0613',
legacy: true,
pricing: {
input: 3,
output: 4,
},
tokens: 16_385,
},
],
checkModel: 'gpt-4o-mini',
description:
Expand Down
18 changes: 6 additions & 12 deletions src/config/modelProviders/siliconcloud.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ModelProviderCard } from '@/types/llm';

// ref :https://siliconflow.cn/zh-cn/models
// ref :https://siliconflow.cn/zh-cn/pricing
const SiliconCloud: ModelProviderCard = {
chatModels: [
{
Expand Down Expand Up @@ -161,48 +161,42 @@ const SiliconCloud: ModelProviderCard = {
tokens: 32_768,
},
{
description: 'LLaMA 3.1 405B 是预训练和指令调整的强大机型。',
description: 'LLaMA 3.1 405B 指令微调模型针对多语言对话场景进行了优化。',
displayName: 'Llama 3.1 405B',
enabled: true,
id: 'meta-llama/Meta-Llama-3.1-405B-Instruct',
tokens: 32_768,
},
{
description: 'Reflection Llama 3.1 通过Reflection-Tuning技术提升推理能力。',
displayName: 'Reflection Llama 3.1 70B',
id: 'mattshumer/Reflection-Llama-3.1-70B',
tokens: 32_768,
},
{
description: 'LLaMA 3 支持大容量文本生成和指令解析。',
displayName: 'Llama 3 70B',
id: 'meta-llama/Meta-Llama-3-70B-Instruct',
tokens: 8192,
},
{
description: 'Mistral 7B 是按需 fine-tuning的模型,为任务提供优化解答。',
description: 'Mistral 7B 指令微调模型针对对话场景进行了优化,可用于文本生成和对话任务。',
displayName: 'Mistral 7B',
id: 'mistralai/Mistral-7B-Instruct-v0.2',
tokens: 32_768,
},
{
description: 'Mixtral 8x7B 是预训练的稀疏混合专家模型,用于通用性文本任务。',
description: 'Mixtral 8x7B 模型支持多语言输入和输出,可用于文本生成和对话任务。',
displayName: 'Mistral 8x7B',
id: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
tokens: 32_768,
},
],
checkModel: 'Qwen/Qwen2-1.5B-Instruct',
description:
'SiliconFlow 致力于加速 AGI,以惠及人类,通过易用与成本低的 GenAI 堆栈提升大规模 AI 效率。',
'SiliconCloud,基于优秀开源基础模型的高性价比 GenAI 云服务',
id: 'siliconcloud',
modelList: { showModelFetcher: true },
modelsUrl: 'https://siliconflow.cn/zh-cn/models',
name: 'SiliconCloud',
proxyUrl: {
placeholder: 'https://api.siliconflow.cn/v1',
},
url: 'https://siliconflow.cn',
url: 'https://siliconflow.cn/zh-cn/siliconcloud',
};

export default SiliconCloud;
23 changes: 0 additions & 23 deletions src/libs/agent-runtime/openai/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,10 @@ exports[`LobeOpenAI > models > should get models 1`] = `
"tokens": 16385,
},
{
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
"displayName": "GPT-3.5 Turbo 16K",
"id": "gpt-3.5-turbo-16k",
"legacy": true,
"pricing": {
"input": 3,
"output": 4,
},
"tokens": 16385,
},
{
"description": "GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。",
"id": "gpt-3.5-turbo-16k-0613",
"legacy": true,
"pricing": {
"input": 3,
"output": 4,
},
"tokens": 16385,
},
{
"description": "最新的 GPT-4 Turbo 模型具备视觉功能。现在,视觉请求可以使用 JSON 模式和函数调用。 GPT-4 Turbo 是一个增强版本,为多模态任务提供成本效益高的支持。它在准确性和效率之间找到平衡,适合需要进行实时交互的应用程序场景。",
Expand Down Expand Up @@ -83,15 +68,7 @@ exports[`LobeOpenAI > models > should get models 1`] = `
"id": "gpt-3.5-turbo-0301",
},
{
"description": "GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。",
"displayName": "GPT-3.5 Turbo 0613",
"id": "gpt-3.5-turbo-0613",
"legacy": true,
"pricing": {
"input": 1.5,
"output": 2,
},
"tokens": 4096,
},
{
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
Expand Down
28 changes: 27 additions & 1 deletion src/libs/agent-runtime/openai/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
import { ModelProvider } from '../types';
import { ChatStreamPayload, ModelProvider, OpenAIChatMessage } from '../types';
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';

// TODO: 临时写法,后续要重构成 model card 展示配置
const o1Models = new Set(['o1-preview', 'o1-mini']);
const truneO1Payload = (payload: ChatStreamPayload) => ({
...payload,
frequency_penalty: 0,
messages: payload.messages.map((message: OpenAIChatMessage) => ({
...message,
role: message.role === 'system' ? 'user' : message.role,
})),
presence_penalty: 0,
stream: false,
temperature: 1,
top_p: 1,
});

export const LobeOpenAI = LobeOpenAICompatibleFactory({
baseURL: 'https://api.openai.com/v1',
chatCompletion: {
handlePayload: (payload) => {
const { model } = payload;

if (o1Models.has(model)) {
return truneO1Payload(payload) as any;
}

return { ...payload, stream: payload.stream ?? true };
},
},
debug: {
chatCompletion: () => process.env.DEBUG_OPENAI_CHAT_COMPLETION === '1',
},
Expand Down
11 changes: 10 additions & 1 deletion src/server/globalConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getLLMConfig } from '@/config/llm';
import {
BedrockProviderCard,
FireworksAIProviderCard,
GoogleProviderCard,
GroqProviderCard,
NovitaProviderCard,
OllamaProviderCard,
Expand Down Expand Up @@ -39,6 +40,7 @@ export const getServerGlobalConfig = () => {
AWS_BEDROCK_MODEL_LIST,

ENABLED_GOOGLE,
GOOGLE_MODEL_LIST,

ENABLED_GROQ,
GROQ_MODEL_LIST,
Expand Down Expand Up @@ -128,7 +130,14 @@ export const getServerGlobalConfig = () => {
}),
},

google: { enabled: ENABLED_GOOGLE },
google: {
enabled: ENABLED_GOOGLE,
enabledModels: extractEnabledModels(GOOGLE_MODEL_LIST),
serverModelCards: transformToChatModelCards({
defaultChatModels: GoogleProviderCard.chatModels,
modelString: GOOGLE_MODEL_LIST,
}),
},
groq: {
enabled: ENABLED_GROQ,
enabledModels: extractEnabledModels(GROQ_MODEL_LIST),
Expand Down
12 changes: 0 additions & 12 deletions src/server/routers/edge/config/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
},
"tokens": 16385,
},
{
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
"displayName": "GPT-3.5 Turbo 16K",
"enabled": true,
"id": "gpt-3.5-turbo-16k",
"legacy": true,
"pricing": {
"input": 3,
"output": 4,
},
"tokens": 16385,
},
{
"description": "GPT-4 提供了一个更大的上下文窗口,能够处理更长的文本输入,适用于需要广泛信息整合和数据分析的场景。",
"displayName": "GPT-4",
Expand Down
Loading

0 comments on commit e785a40

Please sign in to comment.