feat:添加对话情景功能
This commit is contained in:
@@ -2,10 +2,26 @@ package llm
|
||||
|
||||
import "strings"
|
||||
|
||||
// BuildSystemPrompt 根据语言和细节级别构建系统提示词。
|
||||
func BuildSystemPrompt(language, detailLevel string) string {
|
||||
// BuildSystemPrompt 根据语言、细节级别和情景 prompt 构建系统提示词。
|
||||
// scenarioPrompt 非空时,覆盖默认视觉助手 prompt。
|
||||
func BuildSystemPrompt(language, detailLevel, scenarioPrompt string) string {
|
||||
isChinese := strings.HasPrefix(language, "zh")
|
||||
|
||||
// 情景模式:使用自定义 prompt 作为基础
|
||||
if scenarioPrompt != "" {
|
||||
var prompt strings.Builder
|
||||
prompt.WriteString(scenarioPrompt)
|
||||
if detailLevel == "high" {
|
||||
if isChinese {
|
||||
prompt.WriteString(" 请在涉及视觉内容时提供更详细的描述,包括颜色、位置、数量等细节。")
|
||||
} else {
|
||||
prompt.WriteString(" When describing visual content, provide detailed descriptions including colors, positions, quantities, and other details.")
|
||||
}
|
||||
}
|
||||
return prompt.String()
|
||||
}
|
||||
|
||||
// 默认模式:视觉助手
|
||||
var prompt strings.Builder
|
||||
if isChinese {
|
||||
prompt.WriteString("你是一个视觉助手。用户通过摄像头看到一个场景,并用语音向你提问。请用简洁自然的中文回答。如果涉及视觉描述,先说\"我看到……\"。回答控制在3-5句话以内,除非用户要求详细说明。")
|
||||
|
||||
Reference in New Issue
Block a user