refactor: remove hardcoded system prompt — let Hermes handle natively
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
This commit is contained in:
parent
c2e8f92abe
commit
3b42a8618a
@ -3,7 +3,6 @@ import type { AiChatDto } from './dto/ai-chat.dto';
|
|||||||
|
|
||||||
const HERMES_API_URL = 'http://10.2.0.7:8642/v1/chat/completions';
|
const HERMES_API_URL = 'http://10.2.0.7:8642/v1/chat/completions';
|
||||||
const HERMES_API_KEY = 'zhixi-hermes-key-2026';
|
const HERMES_API_KEY = 'zhixi-hermes-key-2026';
|
||||||
const SYSTEM_PROMPT = '你是知习管理后台的 AI 任务助理,帮助管理员处理日常任务、解答问题。请用简洁专业的中文回复。';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminAiChatService {
|
export class AdminAiChatService {
|
||||||
@ -12,14 +11,7 @@ export class AdminAiChatService {
|
|||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
async chat(dto: AiChatDto) {
|
async chat(dto: AiChatDto) {
|
||||||
const systemMessages = dto.messages.filter(m => m.role === 'system');
|
return await this.callHermes(dto.messages);
|
||||||
const hasSystemPrompt = systemMessages.length > 0;
|
|
||||||
|
|
||||||
const messages = hasSystemPrompt
|
|
||||||
? dto.messages
|
|
||||||
: [{ role: 'system' as const, content: SYSTEM_PROMPT }, ...dto.messages];
|
|
||||||
|
|
||||||
return await this.callHermes(messages);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async callHermes(messages: Array<{ role: string; content: string }>) {
|
private async callHermes(messages: Array<{ role: string; content: string }>) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user