Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bentwnghk committed Feb 5, 2024
2 parents a0f7d31 + 6fc3ae9 commit 1dd058d
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 347 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ENV HOSTNAME "0.0.0.0"
ENV PORT=3210

# General Variables
ENV ACCESS_CODE "lobe66"
ENV ACCESS_CODE ""
ENV CUSTOM_MODELS ""

# OpenAI
Expand All @@ -69,4 +69,10 @@ ENV USE_AZURE_OPENAI ""
ENV AZURE_API_KEY ""
ENV AZURE_API_VERSION ""

# Google
ENV GOOGLE_API_KEY ""

# Zhipu
ENV Zhipu_API_KEY ""

CMD ["node", "server.js"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ e-commerce platform data access, and various third-party services.
| [TokenInsights](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **feednews** on **2024-01-27**</sup> | Get realtime crypto price, BTC, ETH, BNB, and the latest insights.The latest coin news and airdrop opportunities.<br/>`crypto` `btc` `eth` `bnb` |
| [Bilibili](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **LobeHub** on **2024-01-27**</sup> | Dive into Bilibili's vast content with features like keyword video search, replay access, interactive danmaku, trending video recommendations, and hot-search insights, all at your fingertips.<br/>`video` `bilibili` `search` |

> 📊 Total plugins: [<kbd>**62**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
> 📊 Total plugins: [<kbd>**61**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
<!-- PLUGIN LIST -->

Expand Down Expand Up @@ -601,7 +601,7 @@ This project is [MIT](./LICENSE) licensed.
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
[codespaces-shield]: https://github.com/codespaces/badge.svg
[deploy-button-image]: https://vercel.com/button
[deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
[deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY,ACCESS_CODE&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.%20%7C%20Access%20Code%20can%20protect%20your%20website&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
[deploy-on-sealos-button-image]: https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg
[deploy-on-sealos-link]: https://cloud.sealos.io/?openapp=system-template%3FtemplateName%3Dlobe-chat
[deploy-on-zeabur-button-image]: https://zeabur.com/button.svg
Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
| [TokenInsights](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **feednews** on **2024-01-27**</sup> | 获取实时加密货币价格,BTC,ETH,BNB 和最新见解。最新的币新闻和空投机会。<br/>`加密货币` `btc` `eth` `bnb` |
| [哔哩哔哩](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **LobeHub** on **2024-01-27**</sup> | 通过关键词视频搜索、回放访问、互动弹幕、热门视频推荐和热搜洞察等功能,深入体验哔哩哔哩丰富的内容,尽在您的指尖。<br/>`视频` `哔哩哔哩` `搜索` |

> 📊 Total plugins: [<kbd>**62**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
> 📊 Total plugins: [<kbd>**61**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
<!-- PLUGIN LIST -->

Expand Down Expand Up @@ -617,7 +617,7 @@ This project is [MIT](./LICENSE) licensed.
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
[codespaces-shield]: https://github.com/codespaces/badge.svg
[deploy-button-image]: https://vercel.com/button
[deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
[deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY,ACCESS_CODE&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.%20%7C%20Access%20Code%20can%20protect%20your%20website&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
[deploy-on-sealos-button-image]: https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg
[deploy-on-sealos-link]: https://cloud.sealos.io/?openapp=system-template%3FtemplateName%3Dlobe-chat
[deploy-on-zeabur-button-image]: https://zeabur.com/button.svg
Expand Down
2 changes: 1 addition & 1 deletion docs/Deployment/Docker-Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ docker run -d -p 3210:3210 \
>
> - The default mapped port is `3210`. Make sure it is not occupied or manually change the port mapping.
> - Replace `sk-xxxx` in the above command with your own OpenAI API Key.
> - The password set in the official Docker image is `lobe66` by default. Replace it with your own password to improve security.
> - The official Docker doesn't set password by default. Please add your own password to improve security.
> - For a complete list of environment variables supported by LobeChat, please refer to the [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN) section.
> \[!WARNING]
Expand Down
2 changes: 1 addition & 1 deletion docs/Deployment/Docker-Deployment.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ docker run -d -p 3210:3210 \
>
> - 默认映射端口为 `3210`, 请确保未被占用或手动更改端口映射
> - 使用你的 OpenAI API Key 替换上述命令中的 `sk-xxxx`
> - 官方 Docker 镜像中设定的密码默认为 `lobe66`,请将其替换为自己的密码以提升安全性
> - 官方 Docker 镜像中未设定密码,强烈建议添加密码以提升安全性,否则你可能会遇到 [My API Key was stolen!!!](https://github.com/lobehub/lobe-chat/issues/1123) 这样的情况
> - LobeChat 支持的完整环境变量列表请参考 [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN) 部分
> \[!WARNING]
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"@lobehub/icons": "^1.10.2",
"@lobehub/tts": "latest",
"@vercel/analytics": "^1",
"ahooks": "3.7.8",
"ai": "^2",
"antd": "^5",
"antd-style": "^3",
Expand Down
5 changes: 4 additions & 1 deletion src/app/api/plugin/gateway/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { ChatErrorType, ErrorType } from '@/types/fetch';
import { parserPluginSettings } from './settings';

const checkAuth = (accessCode: string | null) => {
const { ACCESS_CODES } = getServerConfig();
const { ACCESS_CODES, PLUGIN_SETTINGS } = getServerConfig();

// if there is no plugin settings, just skip the auth
if (!PLUGIN_SETTINGS) return { auth: true };

// if accessCode doesn't exist
if (!ACCESS_CODES.length) return { auth: true };
Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Footer = memo<{ setExpand?: (expand: boolean) => void }>(({ setExpand }) =
]);

const model = useSessionStore(agentSelectors.currentAgentModel);
const canUpload = useGlobalStore(modelProviderSelectors.modelEnabledVision(model));
const canUpload = useGlobalStore(modelProviderSelectors.modelEnabledUpload(model));

const sendMessage = useSendMessage();

Expand Down
8 changes: 8 additions & 0 deletions src/config/modelProviders/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ const OpenAI: ModelProviderCard = {
id: 'gpt-4-32k-0613',
tokens: 32_768,
},
{
files: true,
functionCall: true,
hidden: true,
id: 'gpt-4-all',
tokens: 32_768,
vision: true,
},
],
enabled: true,
id: 'openai',
Expand Down
7 changes: 5 additions & 2 deletions src/features/ChatInput/ActionBar/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ const FileUpload = memo(() => {
const upload = useFileStore((s) => s.uploadFile);

const model = useSessionStore(agentSelectors.currentAgentModel);
const canUpload = useGlobalStore(modelProviderSelectors.modelEnabledVision(model));
const [canUpload, enabledFiles] = useGlobalStore((s) => [
modelProviderSelectors.modelEnabledUpload(model)(s),
modelProviderSelectors.modelEnabledFiles(model)(s),
]);

return (
<Upload
accept="image/*"
accept={enabledFiles ? undefined : 'image/*'}
beforeUpload={async (file) => {
setLoading(true);

Expand Down
2 changes: 1 addition & 1 deletion src/features/ChatInput/useChatInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useChatInput = () => {
const onSend = useSendMessage();

const model = useSessionStore(agentSelectors.currentAgentModel);
const canUpload = useGlobalStore(modelProviderSelectors.modelEnabledVision(model));
const canUpload = useGlobalStore(modelProviderSelectors.modelEnabledUpload(model));

const [loading, value, onInput, onStop] = useChatStore((s) => [
!!s.chatLoadingId,
Expand Down
6 changes: 4 additions & 2 deletions src/services/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ class ChatService {

if (imageList.length === 0) return m.content;

const hasVision = modelProviderSelectors.modelEnabledVision(model)(useGlobalStore.getState());
const canUploadFile = modelProviderSelectors.modelEnabledUpload(model)(
useGlobalStore.getState(),
);

if (!hasVision) {
if (!canUploadFile) {
return m.content;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,235 +30,3 @@ exports[`modelProviderSelectors > CUSTOM_MODELS > custom deletion, addition, and
},
]
`;

exports[`modelProviderSelectors > CUSTOM_MODELS > duplicate naming model 1`] = `
[
{
"chatModels": [
{
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务",
"displayName": "GPT-3.5 Turbo",
"functionCall": true,
"id": "gpt-3.5-turbo",
"tokens": 4096,
},
{
"displayName": "GPT-3.5 Turbo (0125)",
"functionCall": true,
"id": "gpt-3.5-turbo-0125",
"tokens": 16385,
},
{
"displayName": "GPT-3.5 Turbo (1106)",
"functionCall": true,
"hidden": true,
"id": "gpt-3.5-turbo-1106",
"tokens": 16385,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-instruct",
"tokens": 4096,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-16k",
"tokens": 16385,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-0613",
"legacy": true,
"tokens": 4096,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-16k-0613",
"legacy": true,
"tokens": 4096,
},
{
"displayName": "GPT-4 Turbo Preview",
"functionCall": true,
"id": "gpt-4-turbo-preview",
"tokens": 128000,
},
{
"displayName": "gpt-4-32k",
"functionCall": true,
"id": "gpt-4-0125-preview",
"tokens": 128000,
},
{
"description": "GPT-4 视觉预览版,支持视觉任务",
"displayName": "GPT-4 Turbo Vision (Preview)",
"id": "gpt-4-vision-preview",
"tokens": 128000,
"vision": true,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-1106-preview",
"tokens": 128000,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4",
"tokens": 8192,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-0613",
"tokens": 8192,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-32k",
"tokens": 32768,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-32k-0613",
"tokens": 32768,
},
],
"enabled": true,
"id": "openai",
},
]
`;

exports[`modelProviderSelectors > CUSTOM_MODELS > only add the model 1`] = `
[
{
"chatModels": [
{
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务",
"displayName": "GPT-3.5 Turbo",
"functionCall": true,
"id": "gpt-3.5-turbo",
"tokens": 4096,
},
{
"displayName": "GPT-3.5 Turbo (0125)",
"functionCall": true,
"id": "gpt-3.5-turbo-0125",
"tokens": 16385,
},
{
"displayName": "GPT-3.5 Turbo (1106)",
"functionCall": true,
"hidden": true,
"id": "gpt-3.5-turbo-1106",
"tokens": 16385,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-instruct",
"tokens": 4096,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-16k",
"tokens": 16385,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-0613",
"legacy": true,
"tokens": 4096,
},
{
"hidden": true,
"id": "gpt-3.5-turbo-16k-0613",
"legacy": true,
"tokens": 4096,
},
{
"displayName": "GPT-4 Turbo Preview",
"functionCall": true,
"id": "gpt-4-turbo-preview",
"tokens": 128000,
},
{
"displayName": "GPT-4 Turbo Preview (0125)",
"functionCall": true,
"id": "gpt-4-0125-preview",
"tokens": 128000,
},
{
"description": "GPT-4 视觉预览版,支持视觉任务",
"displayName": "GPT-4 Turbo Vision (Preview)",
"id": "gpt-4-vision-preview",
"tokens": 128000,
"vision": true,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-1106-preview",
"tokens": 128000,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4",
"tokens": 8192,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-0613",
"tokens": 8192,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-32k",
"tokens": 32768,
},
{
"functionCall": true,
"hidden": true,
"id": "gpt-4-32k-0613",
"tokens": 32768,
},
{
"displayName": "model1",
"functionCall": true,
"id": "model1",
"isCustom": true,
"vision": true,
},
{
"displayName": "model2",
"functionCall": true,
"id": "model2",
"isCustom": true,
"vision": true,
},
{
"displayName": "model3",
"functionCall": true,
"id": "model3",
"isCustom": true,
"vision": true,
},
{
"displayName": "model4",
"functionCall": true,
"id": "model4",
"isCustom": true,
"vision": true,
},
],
"enabled": true,
"id": "openai",
},
]
`;
Loading

0 comments on commit 1dd058d

Please sign in to comment.