mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 21:37:20 +08:00
[update]change name
This commit is contained in:
parent
ed9ecebffc
commit
ea68e058cd
@ -20,8 +20,8 @@ import {
|
||||
LobePerplexityAI,
|
||||
LobeRuntimeAI,
|
||||
LobeZhipuAI,
|
||||
LobeChatChatAI,
|
||||
ModelProvider,
|
||||
LobeKnowledgeAI,
|
||||
} from '@/libs/agent-runtime';
|
||||
import { TraceClient } from '@/libs/traces';
|
||||
|
||||
@ -169,8 +169,8 @@ class AgentRuntime {
|
||||
break;
|
||||
}
|
||||
|
||||
case ModelProvider.Knowledge: {
|
||||
runtimeModel = this.initKnowledge(payload);
|
||||
case ModelProvider.ChatChat: {
|
||||
runtimeModel = this.initChatChat(payload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -275,11 +275,11 @@ class AgentRuntime {
|
||||
return new LobeMistralAI({ apiKey });
|
||||
}
|
||||
|
||||
private static initKnowledge(payload: JWTPayload) {
|
||||
private static initChatChat(payload: JWTPayload) {
|
||||
const { KNOWLEDGE_PROXY_URL } = getServerConfig();
|
||||
const baseURL = payload?.endpoint || KNOWLEDGE_PROXY_URL;
|
||||
|
||||
return new LobeKnowledgeAI({ baseURL });
|
||||
return new LobeChatChatAI({ baseURL });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ import { useHover } from 'ahooks';
|
||||
import { createStyles, useResponsive } from 'antd-style';
|
||||
import { memo, useMemo, useRef } from 'react';
|
||||
import Avatar from '@/components/Avatar';
|
||||
|
||||
const { Item } = List;
|
||||
|
||||
const useStyles = createStyles(({ css, token, responsive }) => {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { MobileNavBar } from '@lobehub/ui';
|
||||
import { memo } from 'react';
|
||||
import Logo from '@/components/Logo';
|
||||
|
||||
const Header = memo(() => {
|
||||
return <MobileNavBar center={<Logo type={'text'} />} />;
|
||||
});
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { MobileNavBar } from '@lobehub/ui';
|
||||
import { memo } from 'react';
|
||||
import Logo from '@/components/Logo';
|
||||
|
||||
const Header = memo(() => <MobileNavBar center={<Logo type={'text'} />} />);
|
||||
|
||||
export default Header;
|
||||
|
||||
@ -3,6 +3,7 @@ import { Loader2 } from 'lucide-react';
|
||||
import { memo } from 'react';
|
||||
import { Center, Flexbox } from 'react-layout-kit';
|
||||
import Logo from '@/components/Logo';
|
||||
|
||||
const FullscreenLoading = memo<{ title?: string }>(({ title }) => {
|
||||
return (
|
||||
<Flexbox height={'100%'} style={{ userSelect: 'none' }} width={'100%'}>
|
||||
|
||||
@ -3,6 +3,7 @@ import { createStyles } from 'antd-style';
|
||||
import { ReactNode, memo } from 'react';
|
||||
import { Center, Flexbox } from 'react-layout-kit';
|
||||
import Avatar from '@/components/Avatar';
|
||||
|
||||
export const useStyles = createStyles(({ css, token }) => ({
|
||||
container: css`
|
||||
color: ${token.colorText};
|
||||
|
||||
@ -5,7 +5,7 @@ import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { ChatStreamCallbacks } from '@/libs/agent-runtime';
|
||||
|
||||
import * as debugStreamModule from '../utils/debugStream';
|
||||
import { LobeKnowledgeAI } from './index';
|
||||
import { LobeChatChatAI } from './index';
|
||||
|
||||
const provider = 'knowledge';
|
||||
const defaultBaseURL = 'http://localhost:7861/v1';
|
||||
@ -15,10 +15,10 @@ const invalidErrorType = 'InvalidKnowledgeArgs';
|
||||
// Mock the console.error to avoid polluting test output
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
let instance: LobeKnowledgeAI;
|
||||
let instance: LobeChatChatAI;
|
||||
|
||||
beforeEach(() => {
|
||||
instance = new LobeKnowledgeAI({ apiKey: 'knowledge', baseURL: defaultBaseURL });
|
||||
instance = new LobeChatChatAI({ apiKey: 'knowledge', baseURL: defaultBaseURL });
|
||||
|
||||
// 使用 vi.spyOn 来模拟 chat.completions.create 方法
|
||||
vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(
|
||||
@ -30,7 +30,7 @@ afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('LobeKnowledgeAI', () => {
|
||||
describe('LobeChatChatAI', () => {
|
||||
|
||||
describe('init', ()=>{
|
||||
it('should init with default baseURL', () => {
|
||||
@ -13,13 +13,13 @@ import { Stream } from 'openai/streaming';
|
||||
const DEFAULT_BASE_URL = 'http://localhost:7861/v1';
|
||||
|
||||
|
||||
export class LobeKnowledgeAI implements LobeRuntimeAI {
|
||||
export class LobeChatChatAI implements LobeRuntimeAI {
|
||||
private client: OpenAI;
|
||||
|
||||
baseURL: string;
|
||||
|
||||
constructor({ apiKey = 'knowledge', baseURL = DEFAULT_BASE_URL, ...res }: ClientOptions) {
|
||||
if (!baseURL) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidKnowledgeArgs);
|
||||
constructor({ apiKey = 'chatChat', baseURL = DEFAULT_BASE_URL, ...res }: ClientOptions) {
|
||||
if (!baseURL) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidChatChatArgs);
|
||||
|
||||
this.client = new OpenAI({ apiKey, baseURL, ...res });
|
||||
this.baseURL = baseURL;
|
||||
@ -31,7 +31,7 @@ export class LobeKnowledgeAI implements LobeRuntimeAI {
|
||||
payload as unknown as (OpenAI.ChatCompletionCreateParamsStreaming | OpenAI.ChatCompletionCreateParamsNonStreaming),
|
||||
);
|
||||
|
||||
if (LobeKnowledgeAI.isStream(response)) {
|
||||
if (LobeChatChatAI.isStream(response)) {
|
||||
|
||||
const [prod, debug] = response.tee();
|
||||
|
||||
@ -48,7 +48,7 @@ export class LobeKnowledgeAI implements LobeRuntimeAI {
|
||||
console.debug(JSON.stringify(response));
|
||||
}
|
||||
|
||||
const stream = LobeKnowledgeAI.createChatCompletionStream(response?.choices[0].message.content || '');
|
||||
const stream = LobeChatChatAI.createChatCompletionStream(response?.choices[0].message.content || '');
|
||||
|
||||
return new StreamingTextResponse(stream);
|
||||
}
|
||||
@ -65,8 +65,8 @@ export class LobeKnowledgeAI implements LobeRuntimeAI {
|
||||
throw AgentRuntimeError.chat({
|
||||
endpoint: desensitizedEndpoint,
|
||||
error: error as any,
|
||||
errorType: AgentRuntimeErrorType.InvalidKnowledgeArgs,
|
||||
provider: ModelProvider.Knowledge,
|
||||
errorType: AgentRuntimeErrorType.InvalidChatChatArgs,
|
||||
provider: ModelProvider.ChatChat,
|
||||
});
|
||||
}
|
||||
|
||||
@ -78,13 +78,13 @@ export class LobeKnowledgeAI implements LobeRuntimeAI {
|
||||
|
||||
const { errorResult, RuntimeError } = handleOpenAIError(error);
|
||||
|
||||
const errorType = RuntimeError || AgentRuntimeErrorType.OllamaBizError;
|
||||
const errorType = RuntimeError || AgentRuntimeErrorType.ChatChatBizError;
|
||||
|
||||
throw AgentRuntimeError.chat({
|
||||
endpoint: desensitizedEndpoint,
|
||||
error: errorResult,
|
||||
errorType,
|
||||
provider: ModelProvider.Knowledge,
|
||||
provider: ModelProvider.ChatChat,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -35,8 +35,8 @@ export const AgentRuntimeErrorType = {
|
||||
InvalidAnthropicAPIKey: 'InvalidAnthropicAPIKey',
|
||||
AnthropicBizError: 'AnthropicBizError',
|
||||
|
||||
InvalidKnowledgeArgs: 'InvalidKnowledgeArgs',
|
||||
KnowledgeBizError: 'KnowledgeBizError',
|
||||
InvalidChatChatArgs: 'InvalidChatChatArgs',
|
||||
ChatChatBizError: 'ChatChatBizError',
|
||||
} as const;
|
||||
|
||||
export type ILobeAgentRuntimeErrorType =
|
||||
|
||||
@ -2,6 +2,7 @@ export { LobeAnthropicAI } from './anthropic';
|
||||
export { LobeAzureOpenAI } from './azureOpenai';
|
||||
export * from './BaseAI';
|
||||
export { LobeBedrockAI } from './bedrock';
|
||||
export { LobeChatChatAI } from './chatchat';
|
||||
export * from './error';
|
||||
export { LobeGoogleAI } from './google';
|
||||
export { LobeMistralAI } from './mistral';
|
||||
@ -12,4 +13,3 @@ export { LobePerplexityAI } from './perplexity';
|
||||
export * from './types';
|
||||
export { AgentRuntimeError } from './utils/createError';
|
||||
export { LobeZhipuAI } from './zhipu';
|
||||
export { LobeKnowledgeAI } from './knowledge';
|
||||
|
||||
@ -25,6 +25,7 @@ export enum ModelProvider {
|
||||
Anthropic = 'anthropic',
|
||||
Azure = 'azure',
|
||||
Bedrock = 'bedrock',
|
||||
ChatChat = 'chatChat',
|
||||
ChatGLM = 'chatglm',
|
||||
Google = 'google',
|
||||
Mistral = 'mistral',
|
||||
@ -33,6 +34,5 @@ export enum ModelProvider {
|
||||
OpenAI = 'openai',
|
||||
Perplexity = 'perplexity',
|
||||
Tongyi = 'tongyi',
|
||||
ZhiPu = 'zhipu',
|
||||
Knowledge = 'knowledge',
|
||||
ZhiPu = 'zhipu'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user