@lobehub/chat 0.129.1 → 0.129.3

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +154 -85
  3. package/README.zh-CN.md +155 -80
  4. package/contributing/Basic/Add-New-Authentication-Providers.md +108 -0
  5. package/contributing/Basic/Add-New-Authentication-Providers.zh-CN.md +109 -0
  6. package/docs/self-hosting/examples/ollama.mdx +21 -0
  7. package/docs/self-hosting/examples/ollama.zh-CN.mdx +21 -0
  8. package/docs/usage/features/agent-market.mdx +9 -3
  9. package/docs/usage/features/agent-market.zh-CN.mdx +7 -1
  10. package/docs/usage/features/local-llm.mdx +5 -1
  11. package/docs/usage/features/local-llm.zh-CN.mdx +5 -1
  12. package/docs/usage/features/mobile.mdx +5 -1
  13. package/docs/usage/features/mobile.zh-CN.mdx +5 -1
  14. package/docs/usage/features/multi-ai-providers.mdx +5 -1
  15. package/docs/usage/features/multi-ai-providers.zh-CN.mdx +5 -1
  16. package/docs/usage/features/plugin-system.mdx +8 -7
  17. package/docs/usage/features/plugin-system.zh-CN.mdx +8 -7
  18. package/docs/usage/features/pwa.mdx +5 -1
  19. package/docs/usage/features/pwa.zh-CN.mdx +5 -1
  20. package/docs/usage/features/text-to-image.mdx +7 -1
  21. package/docs/usage/features/text-to-image.zh-CN.mdx +7 -1
  22. package/docs/usage/features/theme.mdx +5 -1
  23. package/docs/usage/features/theme.zh-CN.mdx +5 -1
  24. package/docs/usage/features/tts.mdx +7 -1
  25. package/docs/usage/features/tts.zh-CN.mdx +7 -1
  26. package/docs/usage/features/vision.mdx +7 -1
  27. package/docs/usage/features/vision.zh-CN.mdx +7 -1
  28. package/docs/usage/plugins/basic-usage.mdx +3 -10
  29. package/docs/usage/plugins/basic-usage.zh-CN.mdx +1 -7
  30. package/docs/usage/plugins/custom-plugin.mdx +2 -9
  31. package/docs/usage/plugins/custom-plugin.zh-CN.mdx +1 -7
  32. package/docs/usage/providers/ollama.mdx +80 -0
  33. package/docs/usage/providers/ollama.zh-CN.mdx +80 -0
  34. package/package.json +4 -4
  35. package/src/app/api/auth/next-auth.ts +28 -0
  36. package/src/components/ModelIcon/index.tsx +2 -0
  37. package/src/components/ModelTag/ModelIcon.tsx +2 -0
  38. package/src/config/modelProviders/ollama.ts +22 -0
@@ -0,0 +1,80 @@
1
+ import { Callout, Steps, Tabs } from 'nextra/components';
2
+
3
+ # Using Ollama in LobeChat
4
+
5
+ <Image
6
+ alt={'Using Ollama in LobeChat'}
7
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/a2a091b8-ac45-4679-b5e0-21d711e17fef'}
8
+ cover
9
+ />
10
+
11
+ Ollama is a powerful framework for running large language models (LLMs) locally, supporting various language models including Llama 2, Mistral, and more. Now, LobeChat supports integration with Ollama, meaning you can easily use the language models provided by Ollama to enhance your application within LobeChat.
12
+
13
+ This document will guide you on how to use Ollama in LobeChat:
14
+
15
+ <Steps>
16
+ ### Local Installation of Ollama
17
+
18
+ First, you need to install Ollama, which supports macOS, Windows, and Linux systems. Depending on your operating system, choose one of the following installation methods:
19
+
20
+ <Tabs items={['macOS', 'Linux', 'Windows (Preview)', 'Docker']}>
21
+ <Tabs.Tab>[Download Ollama for macOS](https://ollama.com/download) and unzip it.</Tabs.Tab>
22
+ <Tabs.Tab>
23
+
24
+ ````bash
25
+ Install using the following command:
26
+
27
+ ```bash
28
+ curl -fsSL https://ollama.com/install.sh | sh
29
+ ````
30
+
31
+ Alternatively, you can refer to the [Linux manual installation guide](https://github.com/jmorganca/ollama/blob/main/docs/linux.md).
32
+
33
+ </Tabs.Tab>
34
+ <Tabs.Tab>[Download Ollama for Windows](https://ollama.com/download) and install it.</Tabs.Tab>
35
+ <Tabs.Tab>
36
+
37
+ If you prefer using Docker, Ollama also provides an official Docker image, which you can pull using the following command:
38
+
39
+ ```bash
40
+ docker pull ollama/ollama
41
+ ```
42
+
43
+ </Tabs.Tab>
44
+ </Tabs>
45
+
46
+ ### Pulling Models to Local with Ollama
47
+
48
+ After installing Ollama, you can install models locally, for example, llama2:
49
+
50
+ ```bash
51
+ ollama pull llama2
52
+ ```
53
+
54
+ Ollama supports various models, and you can view the available model list in the [Ollama Library](https://ollama.com/library) and choose the appropriate model based on your needs.
55
+
56
+ </Steps>
57
+
58
+ Next, you can start conversing with the local LLM using LobeChat.
59
+
60
+ <Video
61
+ width={832}
62
+ height={468}
63
+ src="https://github.com/lobehub/lobe-chat/assets/28616219/063788c8-9fef-4c6b-b837-96668ad6bc41"
64
+ />
65
+
66
+ <Callout type={'info'}>
67
+ You can visit [Integrating with Ollama](/en/self-hosting/examples/ollama) to learn how to deploy
68
+ LobeChat to meet the integration requirements with Ollama.
69
+ </Callout>
70
+
71
+ ## Custom Configuration
72
+
73
+ You can find Ollama's configuration options in `Settings` -> `Language Model`, where you can configure Ollama's proxy, model name, and more.
74
+
75
+ <Image
76
+ alt={'Ollama Service Provider Settings'}
77
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/da0db930-78ce-4262-b648-2b9e43c565c3'}
78
+ width={832}
79
+ height={274}
80
+ />
@@ -0,0 +1,80 @@
1
+ import { Callout, Steps, Tabs } from 'nextra/components';
2
+
3
+ # 在 LobeChat 中使用 Ollama
4
+
5
+ <Image
6
+ alt={'在 LobeChat 中使用 Ollama'}
7
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/a2a091b8-ac45-4679-b5e0-21d711e17fef'}
8
+ cover
9
+ />
10
+
11
+ Ollama 是一款强大的本地运行大型语言模型(LLM)的框架,支持多种语言模型,包括 Llama 2, Mistral 等。现在,LobeChat 已经支持与 Ollama 的集成,这意味着你可以在 LobeChat 中轻松使用 Ollama 提供的语言模型来增强你的应用。
12
+
13
+ 本文档将指导你如何在 LobeChat 中使用 Ollama:
14
+
15
+ <Steps>
16
+ ### 本地安装 Ollama
17
+
18
+ 首先,你需要安装 Ollama,Ollama 支持 macOS、Windows 和 Linux 系统。 根据你的操作系统,选择以下安装方式之一:
19
+
20
+ <Tabs items={['macOS', 'Linux','Windows (预览版)','Docker']}>
21
+ <Tabs.Tab>[下载 Ollama for macOS](https://ollama.com/download) 并解压。</Tabs.Tab>
22
+ <Tabs.Tab>
23
+
24
+ 通过以下命令安装:
25
+
26
+ ```bash
27
+ curl -fsSL https://ollama.com/install.sh | sh
28
+ ```
29
+
30
+ 或者,你也可以参考 [Linux 手动安装指南](https://github.com/ollama/ollama/blob/main/docs/linux.md)。
31
+
32
+ </Tabs.Tab>
33
+ <Tabs.Tab>[下载 Ollama for Windows](https://ollama.com/download) 并安装。</Tabs.Tab>
34
+ <Tabs.Tab>
35
+
36
+ 如果你更倾向于使用 Docker,Ollama 也提供了官方 Docker 镜像,你可以通过以下命令拉取:
37
+
38
+ ```bash
39
+ docker pull ollama/ollama
40
+ ```
41
+
42
+ </Tabs.Tab>
43
+
44
+ </Tabs>
45
+
46
+ ### 用 Ollama 拉取模型到本地
47
+
48
+ 在安装完成 Ollama 后,你可以通过以下命安装模型,以 llama2 为例:
49
+
50
+ ```bash
51
+ ollama pull llama2
52
+ ```
53
+
54
+ Ollama 支持多种模型,你可以在 [Ollama Library](https://ollama.com/library) 中查看可用的模型列表,并根据需求选择合适的模型。
55
+
56
+ </Steps>
57
+
58
+ 接下来,你就可以使用 LobeChat 与本地 LLM 对话了。
59
+
60
+ <Video
61
+ width={832}
62
+ height={468}
63
+ src="https://github.com/lobehub/lobe-chat/assets/28616219/95828c11-0ae5-4dfa-84ed-854124e927a6"
64
+ />
65
+
66
+ <Callout type={'info'}>
67
+ 你可以前往 [与 Ollama 集成](/zh/self-hosting/examples/ollama) 了解如何部署 LobeChat ,以满足与
68
+ Ollama 的集成需求。
69
+ </Callout>
70
+
71
+ ## 自定义配置
72
+
73
+ 你可以在 `设置` -> `语言模型` 中找到 Ollama 的配置选项,你可以在这里配置 Ollama 的代理、模型名称等。
74
+
75
+ <Image
76
+ alt={'Ollama 服务商设置'}
77
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/da0db930-78ce-4262-b648-2b9e43c565c3'}
78
+ width={832}
79
+ height={274}
80
+ />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.129.1",
3
+ "version": "0.129.3",
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",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@ant-design/icons": "^5",
77
- "@auth/core": "^0.26.3",
77
+ "@auth/core": "^0.27.0",
78
78
  "@aws-sdk/client-bedrock-runtime": "^3.503.1",
79
79
  "@azure/openai": "^1.0.0-beta.11",
80
80
  "@cfworker/json-schema": "^1",
@@ -82,7 +82,7 @@
82
82
  "@icons-pack/react-simple-icons": "^9",
83
83
  "@lobehub/chat-plugin-sdk": "latest",
84
84
  "@lobehub/chat-plugins-gateway": "latest",
85
- "@lobehub/icons": "^1.11.1",
85
+ "@lobehub/icons": "^1.11.2",
86
86
  "@lobehub/tts": "latest",
87
87
  "@lobehub/ui": "^1.129.2",
88
88
  "@vercel/analytics": "^1",
@@ -107,7 +107,7 @@
107
107
  "modern-screenshot": "^4",
108
108
  "nanoid": "^5",
109
109
  "next": "^14.1",
110
- "next-auth": "5.0.0-beta.11",
110
+ "next-auth": "beta",
111
111
  "next-sitemap": "^4.2.3",
112
112
  "numeral": "^2.0.6",
113
113
  "nuqs": "^1.15.4",
@@ -6,10 +6,38 @@ import { getServerConfig } from '@/config/server';
6
6
  const { AUTH0_CLIENT_ID, ENABLE_OAUTH_SSO, AUTH0_CLIENT_SECRET, AUTH0_ISSUER, NEXTAUTH_SECRET } =
7
7
  getServerConfig();
8
8
 
9
+ declare module '@auth/core/jwt' {
10
+ // Returned by the `jwt` callback and `auth`, when using JWT sessions
11
+ interface JWT {
12
+ userId?: string;
13
+ }
14
+ }
15
+
9
16
  const nextAuth = NextAuth({
17
+ callbacks: {
18
+ // Note: Data processing order of callback: authorize --> jwt --> session
19
+ async jwt({ token, account }) {
20
+ // Auth.js will process the `providerAccountId` automatically
21
+ // ref: https://authjs.dev/reference/core/types#provideraccountid
22
+ if (account) {
23
+ token.userId = account.providerAccountId;
24
+ }
25
+ return token;
26
+ },
27
+ async session({ session, token }) {
28
+ // Pick userid from token
29
+ if (session.user) {
30
+ session.user.id = token.userId ?? session.user.id;
31
+ }
32
+ return session;
33
+ },
34
+ },
10
35
  providers: ENABLE_OAUTH_SSO
11
36
  ? [
12
37
  Auth0({
38
+ // Specify auth scope, at least include 'openid email'
39
+ // all scopes in Auth0 ref: https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes#standard-claims
40
+ authorization: { params: { scope: 'openid email profile' } },
13
41
  clientId: AUTH0_CLIENT_ID,
14
42
  clientSecret: AUTH0_CLIENT_SECRET,
15
43
  issuer: AUTH0_ISSUER,
@@ -4,6 +4,7 @@ import {
4
4
  Baichuan,
5
5
  ChatGLM,
6
6
  Gemini,
7
+ Gemma,
7
8
  Meta,
8
9
  Minimax,
9
10
  Mistral,
@@ -29,6 +30,7 @@ const ModelIcon = memo<ModelProviderIconProps>(({ model, size = 12 }) => {
29
30
  if (model.includes('titan')) return <Aws.Avatar size={size} />;
30
31
  if (model.includes('llama')) return <Meta.Avatar size={size} />;
31
32
  if (model.includes('gemini')) return <Gemini.Avatar size={size} />;
33
+ if (model.includes('gemma')) return <Gemma.Avatar size={size} />;
32
34
  if (model.includes('qwen')) return <Tongyi.Avatar background={Tongyi.colorPrimary} size={size} />;
33
35
  if (model.includes('minmax')) return <Minimax.Avatar size={size} />;
34
36
  if (model.includes('moonshot')) return <Moonshot.Avatar size={size} />;
@@ -4,6 +4,7 @@ import {
4
4
  Baichuan,
5
5
  ChatGLM,
6
6
  Gemini,
7
+ Gemma,
7
8
  Meta,
8
9
  Minimax,
9
10
  Mistral,
@@ -28,6 +29,7 @@ const ModelIcon = memo<ModelIconProps>(({ model, size = 12 }) => {
28
29
  if (model.includes('titan')) return <Aws size={size} />;
29
30
  if (model.includes('llama')) return <Meta size={size} />;
30
31
  if (model.includes('gemini')) return <Gemini size={size} />;
32
+ if (model.includes('gemma')) return <Gemma.Simple size={size} />;
31
33
  if (model.includes('moonshot')) return <Moonshot size={size} />;
32
34
  if (model.includes('qwen')) return <Tongyi size={size} />;
33
35
  if (model.includes('minmax')) return <Minimax size={size} />;
@@ -2,6 +2,28 @@ import { ModelProviderCard } from '@/types/llm';
2
2
 
3
3
  const Ollama: ModelProviderCard = {
4
4
  chatModels: [
5
+ {
6
+ displayName: 'Gemma 7B',
7
+ functionCall: false,
8
+ id: 'gemma:7b',
9
+ tokens: 4000,
10
+ vision: false,
11
+ },
12
+ {
13
+ displayName: 'Gemma 2B',
14
+ functionCall: false,
15
+ id: 'gemma',
16
+ tokens: 4000,
17
+ vision: false,
18
+ },
19
+ {
20
+ displayName: 'Llama2 Chat 13B',
21
+ functionCall: false,
22
+ hidden: true,
23
+ id: 'llama2:13b',
24
+ tokens: 4000,
25
+ vision: false,
26
+ },
5
27
  {
6
28
  displayName: 'Llama2 Chat 7B',
7
29
  functionCall: false,