Skip to content

Commit

Permalink
add support for deepseek
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 6, 2024
1 parent 3b581d9 commit 30db007
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/BE/DB/Enums/DBModelProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public enum DBModelProvider
WenXinQianFan = 6,
AliyunDashscope = 7,
Sparkdesk = 8,
ZhiPuAI = 9
ZhiPuAI = 9,
DeepSeek = 10,
}
2 changes: 2 additions & 0 deletions src/BE/Services/ChatServices/ChatFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Chats.BE.DB.Enums;
using Chats.BE.Services.ChatServices.Implementations.Azure;
using Chats.BE.Services.ChatServices.Implementations.DashScope;
using Chats.BE.Services.ChatServices.Implementations.DeepSeek;
using Chats.BE.Services.ChatServices.Implementations.GLM;
using Chats.BE.Services.ChatServices.Implementations.Hunyuan;
using Chats.BE.Services.ChatServices.Implementations.Kimi;
Expand Down Expand Up @@ -30,6 +31,7 @@ public ChatService CreateConversationService(Model model)
DBModelProvider.HunYuan => new HunyuanChatService(model),
DBModelProvider.Sparkdesk => throw new NotImplementedException("Spark model is not implemented"),
DBModelProvider.LingYi => new LingYiChatService(model),
DBModelProvider.DeepSeek => new DeepSeekChatService(model),
_ => throw new NotSupportedException($"Unknown model provider: {modelProvider}")
};
return cs;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Chats.BE.DB;
using Chats.BE.Services.ChatServices.Implementations.OpenAI;

namespace Chats.BE.Services.ChatServices.Implementations.DeepSeek;

public class DeepSeekChatService(Model model) : OpenAIChatService(model, new Uri("https://api.deepseek.com/v1"));
11 changes: 5 additions & 6 deletions src/FE/components/Chat/SystemPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Props {
export const SystemPrompt: FC<Props> = ({
currentPrompt,
prompts,
model,
model,
onChangePromptText,
onChangePrompt,
}) => {
Expand Down Expand Up @@ -164,8 +164,8 @@ export const SystemPrompt: FC<Props> = ({
}, [value]);

useEffect(() => {
setValue(currentPrompt);
}, [currentPrompt]);
setValue(formatPrompt(currentPrompt, { model }));
}, [currentPrompt, model]);

useEffect(() => {
const handleOutsideClick = (e: MouseEvent) => {
Expand Down Expand Up @@ -196,11 +196,10 @@ export const SystemPrompt: FC<Props> = ({
resize: 'none',
bottom: `${textareaRef?.current?.scrollHeight}px`,
maxHeight: '300px',
overflow: `${
textareaRef.current && textareaRef.current.scrollHeight > 400
overflow: `${textareaRef.current && textareaRef.current.scrollHeight > 400
? 'auto'
: 'hidden'
}`,
}`,
}}
placeholder={
t(`Enter a prompt or type "/" to select a prompt...`) || ''
Expand Down
2 changes: 1 addition & 1 deletion src/FE/components/HomeContent/HomeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const HomeContent = () => {
data.temperature ??
userModelConfig?.temperature ??
DEFAULT_TEMPERATURE,
prompt: formatPrompt(data.content, { model }),
prompt: data.content,
});
});
};
Expand Down
1 change: 1 addition & 0 deletions src/FE/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
"DashScope": "通义千问",
"Xunfei SparkDesk": "讯飞星火",
"Zhipu AI": "智谱AI",
"DeepSeek": "DeepSeek",
"Invalid JSON config": "无效的JSON配置",
"Invalid host": "无效的host",
"Invalid secret": "无效的secret",
Expand Down
3 changes: 3 additions & 0 deletions src/FE/public/logos/deepseek.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/FE/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum DBModelProvider {
QianWen = 7,
Spark = 8,
ZhiPuAI = 9,
DeepSeek = 10,
}

export type FEModelProvider = {
Expand All @@ -34,6 +35,7 @@ export const feModelProviders: FEModelProvider[] = [
{ id: 7, name: 'DashScope', icon: '/logos/qianwen.svg' },
{ id: 8, name: 'Xunfei SparkDesk', icon: '/logos/spark.svg' },
{ id: 9, name: 'Zhipu AI', icon: '/logos/zhipuai.svg' },
{ id: 10, name: 'DeepSeek', icon: '/logos/deepseek.svg' },
];

export interface ChatModelFileConfig {
Expand Down
1 change: 0 additions & 1 deletion src/FE/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const getApiUrl = () =>
: process.env.API_URL;

export const getQueryId = (router: NextRouter): string => {
console.log(router.query);
const { id } = router.query;
if (id) {
if (Array.isArray(id)) {
Expand Down

0 comments on commit 30db007

Please sign in to comment.