@lobehub/chat 1.18.1 → 1.19.0
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.
Potentially problematic release.
This version of @lobehub/chat might be problematic. Click here for more details.
- package/CHANGELOG.md +52 -0
- package/Dockerfile +2 -0
- package/Dockerfile.database +2 -0
- package/locales/ar/chat.json +6 -0
- package/locales/ar/error.json +1 -0
- package/locales/ar/modelProvider.json +7 -0
- package/locales/ar/portal.json +16 -0
- package/locales/bg-BG/chat.json +6 -0
- package/locales/bg-BG/error.json +1 -0
- package/locales/bg-BG/modelProvider.json +7 -0
- package/locales/bg-BG/portal.json +16 -0
- package/locales/de-DE/chat.json +6 -0
- package/locales/de-DE/error.json +1 -0
- package/locales/de-DE/modelProvider.json +7 -0
- package/locales/de-DE/portal.json +16 -0
- package/locales/en-US/chat.json +6 -0
- package/locales/en-US/error.json +1 -0
- package/locales/en-US/modelProvider.json +7 -0
- package/locales/en-US/portal.json +16 -0
- package/locales/es-ES/chat.json +6 -0
- package/locales/es-ES/error.json +1 -0
- package/locales/es-ES/modelProvider.json +7 -0
- package/locales/es-ES/portal.json +16 -0
- package/locales/fr-FR/chat.json +6 -0
- package/locales/fr-FR/error.json +1 -0
- package/locales/fr-FR/modelProvider.json +7 -0
- package/locales/fr-FR/portal.json +16 -0
- package/locales/it-IT/chat.json +6 -0
- package/locales/it-IT/error.json +1 -0
- package/locales/it-IT/modelProvider.json +7 -0
- package/locales/it-IT/portal.json +16 -0
- package/locales/ja-JP/chat.json +6 -0
- package/locales/ja-JP/error.json +1 -0
- package/locales/ja-JP/modelProvider.json +7 -0
- package/locales/ja-JP/portal.json +16 -0
- package/locales/ko-KR/chat.json +6 -0
- package/locales/ko-KR/error.json +1 -0
- package/locales/ko-KR/modelProvider.json +7 -0
- package/locales/ko-KR/portal.json +16 -0
- package/locales/nl-NL/chat.json +6 -0
- package/locales/nl-NL/error.json +1 -0
- package/locales/nl-NL/modelProvider.json +7 -0
- package/locales/nl-NL/portal.json +16 -0
- package/locales/pl-PL/chat.json +6 -0
- package/locales/pl-PL/error.json +1 -0
- package/locales/pl-PL/modelProvider.json +7 -0
- package/locales/pl-PL/portal.json +16 -0
- package/locales/pt-BR/chat.json +6 -0
- package/locales/pt-BR/error.json +1 -0
- package/locales/pt-BR/modelProvider.json +7 -0
- package/locales/pt-BR/portal.json +16 -0
- package/locales/ru-RU/chat.json +6 -0
- package/locales/ru-RU/error.json +1 -0
- package/locales/ru-RU/modelProvider.json +7 -0
- package/locales/ru-RU/portal.json +16 -0
- package/locales/tr-TR/chat.json +6 -0
- package/locales/tr-TR/error.json +1 -0
- package/locales/tr-TR/modelProvider.json +7 -0
- package/locales/tr-TR/portal.json +16 -0
- package/locales/vi-VN/chat.json +6 -0
- package/locales/vi-VN/error.json +1 -0
- package/locales/vi-VN/modelProvider.json +7 -0
- package/locales/vi-VN/portal.json +16 -0
- package/locales/zh-CN/chat.json +6 -0
- package/locales/zh-CN/error.json +2 -1
- package/locales/zh-CN/modelProvider.json +7 -0
- package/locales/zh-CN/portal.json +17 -1
- package/locales/zh-TW/chat.json +6 -0
- package/locales/zh-TW/error.json +1 -0
- package/locales/zh-TW/modelProvider.json +7 -0
- package/locales/zh-TW/portal.json +16 -0
- package/package.json +4 -1
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/HTML.tsx +25 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React.tsx +30 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/SVG.tsx +114 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/index.tsx +25 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/index.tsx +79 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/Header.tsx +69 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/index.ts +10 -0
- package/src/app/(main)/chat/(workspace)/@portal/Artifacts/useEnable.ts +4 -0
- package/src/app/(main)/chat/(workspace)/@portal/FilePreview/index.ts +2 -1
- package/src/app/(main)/chat/(workspace)/@portal/Home/Body/{Artifacts → Plugins}/index.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@portal/Home/Body/index.tsx +2 -2
- package/src/app/(main)/chat/(workspace)/@portal/MessageDetail/index.ts +2 -1
- package/src/app/(main)/chat/(workspace)/@portal/Plugins/Body/ToolRender.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@portal/Plugins/Body/index.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@portal/Plugins/Footer.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@portal/Plugins/index.ts +2 -1
- package/src/app/(main)/chat/(workspace)/@portal/Plugins/useEnable.ts +1 -1
- package/src/app/(main)/chat/(workspace)/@portal/_layout/Desktop.tsx +2 -4
- package/src/app/(main)/chat/(workspace)/@portal/features/Body.tsx +27 -0
- package/src/app/(main)/chat/(workspace)/@portal/router.tsx +3 -1
- package/src/app/(main)/chat/(workspace)/@portal/type.ts +7 -0
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/Portal.tsx +3 -2
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/index.tsx +5 -8
- package/src/app/(main)/discover/(detail)/features/Back.tsx +0 -5
- package/src/app/(main)/discover/(detail)/features/DetailLayout.tsx +2 -34
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/index.tsx +3 -6
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/ProviderItem.tsx +14 -15
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/index.tsx +3 -6
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/index.tsx +3 -6
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ModelList/ModelItem.tsx +14 -11
- package/src/app/(main)/discover/(list)/(home)/features/AssistantList.tsx +5 -11
- package/src/app/(main)/discover/(list)/(home)/features/ModelList.tsx +3 -3
- package/src/app/(main)/discover/(list)/(home)/features/PluginList.tsx +3 -6
- package/src/app/(main)/discover/(list)/assistants/features/List.tsx +7 -16
- package/src/app/(main)/discover/(list)/models/features/List.tsx +5 -11
- package/src/app/(main)/discover/(list)/plugins/features/List.tsx +7 -16
- package/src/app/(main)/discover/(list)/providers/features/List.tsx +5 -11
- package/src/app/(main)/discover/_layout/Desktop/index.tsx +3 -0
- package/src/app/(main)/discover/_layout/Mobile/index.tsx +8 -1
- package/src/app/(main)/settings/llm/ProviderList/Github/index.tsx +53 -0
- package/src/app/(main)/settings/llm/ProviderList/providers.tsx +6 -1
- package/src/app/api/chat/agentRuntime.ts +14 -0
- package/src/app/layout.tsx +2 -1
- package/src/components/NProgress/index.tsx +12 -0
- package/src/components/SidebarHeader/index.tsx +1 -1
- package/src/config/llm.ts +14 -0
- package/src/config/modelProviders/ai21.ts +37 -0
- package/src/config/modelProviders/anthropic.ts +4 -0
- package/src/config/modelProviders/github.ts +209 -0
- package/src/config/modelProviders/index.ts +8 -0
- package/src/const/layoutTokens.ts +1 -1
- package/src/const/plugin.test.ts +80 -0
- package/src/const/plugin.ts +12 -0
- package/src/const/settings/llm.ts +10 -0
- package/src/features/Conversation/Error/APIKeyForm/index.tsx +4 -0
- package/src/features/Conversation/Messages/Tool/Inspector/index.tsx +1 -1
- package/src/features/Conversation/Messages/Tool/index.tsx +1 -1
- package/src/features/Conversation/components/ChatItem/index.tsx +24 -2
- package/src/features/Conversation/components/ChatItem/utils.test.ts +150 -0
- package/src/features/Conversation/components/ChatItem/utils.ts +28 -0
- package/src/features/Conversation/components/InboxWelcome/AgentsSuggest.tsx +3 -6
- package/src/features/Conversation/components/MarkdownElements/LobeArtifact/Render/Icon.tsx +96 -0
- package/src/features/Conversation/components/MarkdownElements/LobeArtifact/Render/index.tsx +129 -0
- package/src/features/Conversation/components/MarkdownElements/LobeArtifact/index.ts +10 -0
- package/src/features/Conversation/components/MarkdownElements/LobeArtifact/rehypePlugin.ts +74 -0
- package/src/features/Conversation/components/MarkdownElements/LobeThinking/Render.tsx +86 -0
- package/src/features/Conversation/components/MarkdownElements/LobeThinking/index.ts +12 -0
- package/src/features/Conversation/components/MarkdownElements/LobeThinking/rehypePlugin.test.ts +124 -0
- package/src/features/Conversation/components/MarkdownElements/LobeThinking/rehypePlugin.ts +51 -0
- package/src/features/Conversation/components/MarkdownElements/index.ts +4 -0
- package/src/features/Conversation/components/MarkdownElements/type.ts +7 -0
- package/src/hooks/useInterceptingRoutes.ts +1 -16
- package/src/libs/agent-runtime/AgentRuntime.ts +14 -0
- package/src/libs/agent-runtime/ai21/index.test.ts +255 -0
- package/src/libs/agent-runtime/ai21/index.ts +18 -0
- package/src/libs/agent-runtime/error.ts +2 -0
- package/src/libs/agent-runtime/github/index.test.ts +246 -0
- package/src/libs/agent-runtime/github/index.ts +15 -0
- package/src/libs/agent-runtime/openrouter/__snapshots__/index.test.ts.snap +2215 -28
- package/src/libs/agent-runtime/openrouter/fixtures/models.json +3345 -37
- package/src/libs/agent-runtime/openrouter/index.ts +2 -1
- package/src/libs/agent-runtime/types/type.ts +2 -0
- package/src/locales/default/chat.ts +7 -0
- package/src/locales/default/error.ts +3 -0
- package/src/locales/default/modelProvider.ts +7 -0
- package/src/locales/default/portal.ts +17 -1
- package/src/server/globalConfig/index.ts +14 -0
- package/src/store/chat/slices/message/selectors.ts +30 -28
- package/src/store/chat/slices/portal/action.ts +15 -2
- package/src/store/chat/slices/portal/initialState.ts +11 -0
- package/src/store/chat/slices/portal/selectors.test.ts +29 -7
- package/src/store/chat/slices/portal/selectors.ts +56 -12
- package/src/styles/loading.ts +28 -0
- package/src/tools/artifacts/index.ts +13 -0
- package/src/tools/artifacts/systemRole.ts +338 -0
- package/src/tools/index.ts +6 -0
- package/src/types/user/settings/keyVaults.ts +2 -0
- package/src/utils/clipboard.ts +53 -0
- package/src/app/@modal/(.)discover/assistant/[slug]/page.tsx +0 -1
- package/src/app/@modal/(.)discover/layout.tsx +0 -29
- package/src/app/@modal/(.)discover/loading.tsx +0 -3
- package/src/app/@modal/(.)discover/model/[...slugs]/page.tsx +0 -1
- package/src/app/@modal/(.)discover/plugin/[slug]/page.tsx +0 -1
- package/src/app/@modal/(.)discover/provider/[slug]/page.tsx +0 -1
- package/src/app/redirect/page.tsx +0 -15
- package/src/components/InterceptingLink/index.tsx +0 -27
- /package/src/app/(main)/chat/(workspace)/@portal/Home/Body/{Artifacts → Plugins}/ArtifactList/Item/index.tsx +0 -0
- /package/src/app/(main)/chat/(workspace)/@portal/Home/Body/{Artifacts → Plugins}/ArtifactList/Item/style.ts +0 -0
- /package/src/app/(main)/chat/(workspace)/@portal/Home/Body/{Artifacts → Plugins}/ArtifactList/index.tsx +0 -0
@@ -0,0 +1,246 @@
|
|
1
|
+
// @vitest-environment node
|
2
|
+
import OpenAI from 'openai';
|
3
|
+
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
4
|
+
|
5
|
+
import { LobeOpenAICompatibleRuntime } from '@/libs/agent-runtime';
|
6
|
+
import { ModelProvider } from '@/libs/agent-runtime';
|
7
|
+
import { AgentRuntimeErrorType } from '@/libs/agent-runtime';
|
8
|
+
|
9
|
+
import * as debugStreamModule from '../utils/debugStream';
|
10
|
+
import { LobeGithubAI } from './index';
|
11
|
+
|
12
|
+
const provider = ModelProvider.Github;
|
13
|
+
const defaultBaseURL = 'https://models.inference.ai.azure.com';
|
14
|
+
const bizErrorType = AgentRuntimeErrorType.ProviderBizError;
|
15
|
+
const invalidErrorType = AgentRuntimeErrorType.InvalidGithubToken;
|
16
|
+
|
17
|
+
// Mock the console.error to avoid polluting test output
|
18
|
+
vi.spyOn(console, 'error').mockImplementation(() => {});
|
19
|
+
|
20
|
+
let instance: LobeOpenAICompatibleRuntime;
|
21
|
+
|
22
|
+
beforeEach(() => {
|
23
|
+
instance = new LobeGithubAI({ apiKey: 'test' });
|
24
|
+
|
25
|
+
// Use vi.spyOn to mock the chat.completions.create method
|
26
|
+
vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(
|
27
|
+
new ReadableStream() as any,
|
28
|
+
);
|
29
|
+
});
|
30
|
+
|
31
|
+
afterEach(() => {
|
32
|
+
vi.clearAllMocks();
|
33
|
+
});
|
34
|
+
|
35
|
+
describe('LobeGithubAI', () => {
|
36
|
+
describe('init', () => {
|
37
|
+
it('should correctly initialize with an API key', async () => {
|
38
|
+
const instance = new LobeGithubAI({ apiKey: 'test_api_key' });
|
39
|
+
expect(instance).toBeInstanceOf(LobeGithubAI);
|
40
|
+
expect(instance.baseURL).toEqual(defaultBaseURL);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
|
44
|
+
describe('chat', () => {
|
45
|
+
describe('Error', () => {
|
46
|
+
it('should return GithubBizError with an openai error response when OpenAI.APIError is thrown', async () => {
|
47
|
+
// Arrange
|
48
|
+
const apiError = new OpenAI.APIError(
|
49
|
+
400,
|
50
|
+
{
|
51
|
+
status: 400,
|
52
|
+
error: {
|
53
|
+
message: 'Bad Request',
|
54
|
+
},
|
55
|
+
},
|
56
|
+
'Error message',
|
57
|
+
{},
|
58
|
+
);
|
59
|
+
|
60
|
+
vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(apiError);
|
61
|
+
|
62
|
+
// Act
|
63
|
+
try {
|
64
|
+
await instance.chat({
|
65
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
66
|
+
model: 'meta-llama-3-70b-instruct',
|
67
|
+
temperature: 0.7,
|
68
|
+
});
|
69
|
+
} catch (e) {
|
70
|
+
expect(e).toEqual({
|
71
|
+
endpoint: defaultBaseURL,
|
72
|
+
error: {
|
73
|
+
error: { message: 'Bad Request' },
|
74
|
+
status: 400,
|
75
|
+
},
|
76
|
+
errorType: bizErrorType,
|
77
|
+
provider,
|
78
|
+
});
|
79
|
+
}
|
80
|
+
});
|
81
|
+
|
82
|
+
it('should throw AgentRuntimeError with InvalidGithubToken if no apiKey is provided', async () => {
|
83
|
+
try {
|
84
|
+
new LobeGithubAI({});
|
85
|
+
} catch (e) {
|
86
|
+
expect(e).toEqual({ errorType: invalidErrorType });
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
it('should return GithubBizError with the cause when OpenAI.APIError is thrown with cause', async () => {
|
91
|
+
// Arrange
|
92
|
+
const errorInfo = {
|
93
|
+
stack: 'abc',
|
94
|
+
cause: {
|
95
|
+
message: 'api is undefined',
|
96
|
+
},
|
97
|
+
};
|
98
|
+
const apiError = new OpenAI.APIError(400, errorInfo, 'module error', {});
|
99
|
+
|
100
|
+
vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(apiError);
|
101
|
+
|
102
|
+
// Act
|
103
|
+
try {
|
104
|
+
await instance.chat({
|
105
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
106
|
+
model: 'meta-llama-3-70b-instruct',
|
107
|
+
temperature: 0.7,
|
108
|
+
});
|
109
|
+
} catch (e) {
|
110
|
+
expect(e).toEqual({
|
111
|
+
endpoint: defaultBaseURL,
|
112
|
+
error: {
|
113
|
+
cause: { message: 'api is undefined' },
|
114
|
+
stack: 'abc',
|
115
|
+
},
|
116
|
+
errorType: bizErrorType,
|
117
|
+
provider,
|
118
|
+
});
|
119
|
+
}
|
120
|
+
});
|
121
|
+
|
122
|
+
it('should return GithubBizError with an cause response with desensitize Url', async () => {
|
123
|
+
// Arrange
|
124
|
+
const errorInfo = {
|
125
|
+
stack: 'abc',
|
126
|
+
cause: { message: 'api is undefined' },
|
127
|
+
};
|
128
|
+
const apiError = new OpenAI.APIError(400, errorInfo, 'module error', {});
|
129
|
+
|
130
|
+
instance = new LobeGithubAI({
|
131
|
+
apiKey: 'test',
|
132
|
+
baseURL: 'https://api.abc.com/v1',
|
133
|
+
});
|
134
|
+
|
135
|
+
vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(apiError);
|
136
|
+
|
137
|
+
// Act
|
138
|
+
try {
|
139
|
+
await instance.chat({
|
140
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
141
|
+
model: 'meta-llama-3-70b-instruct',
|
142
|
+
temperature: 0.7,
|
143
|
+
});
|
144
|
+
} catch (e) {
|
145
|
+
expect(e).toEqual({
|
146
|
+
endpoint: 'https://api.***.com/v1',
|
147
|
+
error: {
|
148
|
+
cause: { message: 'api is undefined' },
|
149
|
+
stack: 'abc',
|
150
|
+
},
|
151
|
+
errorType: bizErrorType,
|
152
|
+
provider,
|
153
|
+
});
|
154
|
+
}
|
155
|
+
});
|
156
|
+
|
157
|
+
it('should throw an InvalidGithubToken error type on 401 status code', async () => {
|
158
|
+
// Mock the API call to simulate a 401 error
|
159
|
+
const error = new Error('InvalidApiKey') as any;
|
160
|
+
error.status = 401;
|
161
|
+
vi.mocked(instance['client'].chat.completions.create).mockRejectedValue(error);
|
162
|
+
|
163
|
+
try {
|
164
|
+
await instance.chat({
|
165
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
166
|
+
model: 'meta-llama-3-70b-instruct',
|
167
|
+
temperature: 0.7,
|
168
|
+
});
|
169
|
+
} catch (e) {
|
170
|
+
expect(e).toEqual({
|
171
|
+
endpoint: defaultBaseURL,
|
172
|
+
error: new Error('InvalidApiKey'),
|
173
|
+
errorType: invalidErrorType,
|
174
|
+
provider,
|
175
|
+
});
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
it('should return AgentRuntimeError for non-OpenAI errors', async () => {
|
180
|
+
// Arrange
|
181
|
+
const genericError = new Error('Generic Error');
|
182
|
+
|
183
|
+
vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(genericError);
|
184
|
+
|
185
|
+
// Act
|
186
|
+
try {
|
187
|
+
await instance.chat({
|
188
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
189
|
+
model: 'meta-llama-3-70b-instruct',
|
190
|
+
temperature: 0.7,
|
191
|
+
});
|
192
|
+
} catch (e) {
|
193
|
+
expect(e).toEqual({
|
194
|
+
endpoint: defaultBaseURL,
|
195
|
+
errorType: 'AgentRuntimeError',
|
196
|
+
provider,
|
197
|
+
error: {
|
198
|
+
name: genericError.name,
|
199
|
+
cause: genericError.cause,
|
200
|
+
message: genericError.message,
|
201
|
+
stack: genericError.stack,
|
202
|
+
},
|
203
|
+
});
|
204
|
+
}
|
205
|
+
});
|
206
|
+
});
|
207
|
+
|
208
|
+
describe('DEBUG', () => {
|
209
|
+
it('should call debugStream and return StreamingTextResponse when DEBUG_GITHUB_CHAT_COMPLETION is 1', async () => {
|
210
|
+
// Arrange
|
211
|
+
const mockProdStream = new ReadableStream() as any;
|
212
|
+
const mockDebugStream = new ReadableStream({
|
213
|
+
start(controller) {
|
214
|
+
controller.enqueue('Debug stream content');
|
215
|
+
controller.close();
|
216
|
+
},
|
217
|
+
}) as any;
|
218
|
+
mockDebugStream.toReadableStream = () => mockDebugStream;
|
219
|
+
|
220
|
+
// mock
|
221
|
+
(instance['client'].chat.completions.create as Mock).mockResolvedValue({
|
222
|
+
tee: () => [mockProdStream, { toReadableStream: () => mockDebugStream }],
|
223
|
+
});
|
224
|
+
|
225
|
+
const originalDebugValue = process.env.DEBUG_GITHUB_CHAT_COMPLETION;
|
226
|
+
|
227
|
+
process.env.DEBUG_GITHUB_CHAT_COMPLETION = '1';
|
228
|
+
vi.spyOn(debugStreamModule, 'debugStream').mockImplementation(() => Promise.resolve());
|
229
|
+
|
230
|
+
// 执行测试
|
231
|
+
await instance.chat({
|
232
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
233
|
+
model: 'meta-llama-3-70b-instruct',
|
234
|
+
stream: true,
|
235
|
+
temperature: 0.7,
|
236
|
+
});
|
237
|
+
|
238
|
+
// 验证 debugStream 被调用
|
239
|
+
expect(debugStreamModule.debugStream).toHaveBeenCalled();
|
240
|
+
|
241
|
+
// 恢复原始环境变量值
|
242
|
+
process.env.DEBUG_GITHUB_CHAT_COMPLETION = originalDebugValue;
|
243
|
+
});
|
244
|
+
});
|
245
|
+
});
|
246
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { AgentRuntimeErrorType } from '../error';
|
2
|
+
import { ModelProvider } from '../types';
|
3
|
+
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
|
4
|
+
|
5
|
+
export const LobeGithubAI = LobeOpenAICompatibleFactory({
|
6
|
+
baseURL: 'https://models.inference.ai.azure.com',
|
7
|
+
debug: {
|
8
|
+
chatCompletion: () => process.env.DEBUG_GITHUB_CHAT_COMPLETION === '1',
|
9
|
+
},
|
10
|
+
errorType: {
|
11
|
+
bizError: AgentRuntimeErrorType.ProviderBizError,
|
12
|
+
invalidAPIKey: AgentRuntimeErrorType.InvalidGithubToken,
|
13
|
+
},
|
14
|
+
provider: ModelProvider.Github,
|
15
|
+
});
|