feat: 实现 OpenAI LLM 服务(SSE 流式解析 + 多模态消息构建)及 System Prompt 定义
This commit is contained in:
25
backend/internal/ai/llm/prompt.go
Normal file
25
backend/internal/ai/llm/prompt.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package llm
|
||||
|
||||
import "strings"
|
||||
|
||||
// BuildSystemPrompt 根据语言和细节级别构建系统提示词。
|
||||
func BuildSystemPrompt(language, detailLevel string) string {
|
||||
isChinese := strings.HasPrefix(language, "zh")
|
||||
|
||||
var prompt strings.Builder
|
||||
if isChinese {
|
||||
prompt.WriteString("你是一个视觉助手。用户通过摄像头看到一个场景,并用语音向你提问。请用简洁自然的中文回答。如果涉及视觉描述,先说\"我看到……\"。回答控制在3-5句话以内,除非用户要求详细说明。")
|
||||
} else {
|
||||
prompt.WriteString("You are a visual assistant. The user sees a scene through their camera and asks questions by voice. Answer concisely and naturally. If describing visual content, start with 'I see...'. Keep answers to 3-5 sentences unless the user asks for detail.")
|
||||
}
|
||||
|
||||
if detailLevel == "high" {
|
||||
if isChinese {
|
||||
prompt.WriteString("请提供更详细的视觉描述,包括颜色、位置、数量等细节。")
|
||||
} else {
|
||||
prompt.WriteString(" Provide detailed visual descriptions including colors, positions, quantities, and other details.")
|
||||
}
|
||||
}
|
||||
|
||||
return prompt.String()
|
||||
}
|
||||
Reference in New Issue
Block a user