[add]添加chatchat设置

This commit is contained in:
VLOU 2024-04-10 23:14:25 +08:00
parent ea68e058cd
commit 6f3a07ee61
6 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,69 @@
import { Input, Flex } from 'antd';
import { useTheme } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import Avatar from 'next/image';
import { imageUrl } from '@/const/url';
import { ModelProvider } from '@/libs/agent-runtime';
import Checker from '../components/Checker';
import ProviderConfig from '../components/ProviderConfig';
import { LLMProviderBaseUrlKey, LLMProviderConfigKey } from '../const';
const providerKey = 'chatchat';
const ChatChatProvider = memo(() => {
const { t } = useTranslation('setting');
const theme = useTheme();
console.log('----ttt---1-', t('llm.ChatChat.endpoint.title'))
console.log('----ttt---2-', t('llm.Ollama.endpoint.title'))
console.log('----ttt---3-', t)
return (
<ProviderConfig
configItems={[
{
children: <Input allowClear placeholder={t('llm.ChatChat.endpoint.placeholder')} />,
desc: t('llm.ChatChat.endpoint.desc'),
label: t('llm.ChatChat.endpoint.title'),
name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
},
{
children: (
<Input.TextArea
allowClear
placeholder={t('llm.ChatChat.customModelName.placeholder')}
style={{ height: 100 }}
/>
),
desc: t('llm.ChatChat.customModelName.desc'),
label: t('llm.ChatChat.customModelName.title'),
name: [LLMProviderConfigKey, providerKey, 'customModelName'],
},
{
children: <Checker model={'gml-4'} provider={ModelProvider.ChatChat} />,
desc: t('llm.ChatChat.checker.desc'),
label: t('llm.checker.title'),
minWidth: undefined,
},
]}
provider={providerKey}
title={
<Flex>
<Avatar
alt={'Chatchat'}
height={24}
src={imageUrl('logo.png')}
width={24}
/>
{ 'ChatChat' }
</Flex>
}
/>
);
});
export default ChatChatProvider;

View File

@ -17,6 +17,7 @@ import Ollama from './Ollama';
import OpenAI from './OpenAI';
import Perplexity from './Perplexity';
import Zhipu from './Zhipu';
import ChatChat from './ChatChat'
export default memo<{ showOllama: boolean }>(({ showOllama }) => {
const { t } = useTranslation('setting');
@ -34,6 +35,7 @@ export default memo<{ showOllama: boolean }>(({ showOllama }) => {
<Anthropic />
<Mistral />
{showOllama && <Ollama />}
<ChatChat/>
<Footer>
<Trans i18nKey="llm.waitingForMore" ns={'setting'}>

View File

@ -91,6 +91,10 @@ export const DEFAULT_LLM_CONFIG: GlobalLLMConfig = {
apiKey: '',
enabled: false,
},
chatchat: {
enabled: false,
endpoint: ''
},
};
export const DEFAULT_AGENT: GlobalDefaultAgent = {

View File

@ -35,6 +35,9 @@ const Tools = memo(() => {
const list = useToolStore(pluginSelectors.installedPluginMetaList, isEqual);
const builtinList = useToolStore(builtinToolSelectors.metaList, isEqual);
console.log('builtinList--', builtinList)
console.log('list--', list)
const enablePluginCount = useSessionStore(
(s) =>
agentSelectors

View File

@ -181,6 +181,22 @@ export default {
title: 'API Key',
},
},
ChatChat: {
title: 'ChatChat',
checker: {
desc: '测试地址是否正确填写',
},
customModelName: {
desc: '增加自定义模型,多个模型使用逗号(,)隔开',
placeholder: 'gml-4',
title: '自定义模型名称',
},
endpoint: {
desc: '填入 ChatCaht 接口代理地址,本地未额外指定可留空',
placeholder: 'http://127.0.0.1:7861/chat',
title: '接口代理地址',
},
},
checker: {
button: '检查',

View File

@ -70,6 +70,12 @@ export interface MistralConfig {
enabled: boolean;
}
export interface ChatChatConfig {
customModelName?: string;
enabled?: boolean;
endpoint?: string;
}
export interface GlobalLLMConfig {
anthropic: AnthropicConfig;
azure: AzureOpenAIConfig;
@ -81,6 +87,7 @@ export interface GlobalLLMConfig {
openAI: OpenAIConfig;
perplexity: PerplexityConfig;
zhipu: ZhiPuConfig;
chatchat: ChatChatConfig;
}
export type GlobalLLMProviderKey = keyof GlobalLLMConfig;