liumaolin commited on
Commit
310c0ba
·
1 Parent(s): b7ae839

调整LLM prompt的存放位置

Browse files
src/voice_dialogue/config/llm_config.py CHANGED
@@ -1,9 +1,25 @@
1
  """LLM模型配置管理"""
2
 
3
  from typing import Dict, Any
 
4
  from voice_dialogue.utils.apple_silicon import get_optimal_llama_cpp_config, get_apple_silicon_info
5
 
6
- __all__ = ('get_llm_model_params', 'get_apple_silicon_summary')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
 
9
  def get_llm_model_params() -> Dict[str, Any]:
 
1
  """LLM模型配置管理"""
2
 
3
  from typing import Dict, Any
4
+
5
  from voice_dialogue.utils.apple_silicon import get_optimal_llama_cpp_config, get_apple_silicon_info
6
 
7
+ __all__ = ('get_llm_model_params', 'get_apple_silicon_summary', 'CHINESE_SYSTEM_PROMPT', 'ENGLISH_SYSTEM_PROMPT')
8
+
9
+ CHINESE_SYSTEM_PROMPT = (
10
+ "你是AI助手。请以自然流畅的中文口语化表达直接回答问题,避免冗余的思考过程。"
11
+ "你的回答第一句话必须少于十个字。每段回答控制在二到三句话,既不要过短也不要过长,以适应对话语境。"
12
+ "回答应准确、精炼且有依据。"
13
+ "/no_think"
14
+ )
15
+
16
+ ENGLISH_SYSTEM_PROMPT = (
17
+ "You are an AI assistant. "
18
+ "Please answer directly and naturally, using conversational English, without showing your thinking process. "
19
+ "Your first sentence must be less than 10 words. "
20
+ "Your responses should be accurate, concise, and well-supported, ideally around 2-3 sentences long to ensure a good conversational flow."
21
+ "/no_think"
22
+ )
23
 
24
 
25
  def get_llm_model_params() -> Dict[str, Any]:
src/voice_dialogue/services/text/generator.py CHANGED
@@ -6,7 +6,9 @@ from langchain.memory import ConversationBufferWindowMemory
6
  from langchain_core.chat_history import InMemoryChatMessageHistory
7
 
8
  from voice_dialogue.config import paths
9
- from voice_dialogue.config.llm_config import get_llm_model_params, get_apple_silicon_summary
 
 
10
  from voice_dialogue.core.base import BaseThread
11
  from voice_dialogue.core.constants import chat_history_cache
12
  from voice_dialogue.models.voice_task import VoiceTask, QuestionDisplayMessage
@@ -14,21 +16,6 @@ from voice_dialogue.services.text.processor import preprocess_sentence_text, \
14
  create_langchain_chat_llamacpp_instance, create_langchain_pipeline, warmup_langchain_pipeline
15
  from voice_dialogue.utils.logger import logger
16
 
17
- CHINESE_SYSTEM_PROMPT = (
18
- "你是AI助手。请以自然流畅的中文口语化表达直接回答问题,避免冗余的思考过程。"
19
- "你的回答第一句话必须少于十个字。每段回答控制在二到三句话,既不要过短也不要过长,以适应对话语境。"
20
- "回答应准确、精炼且有依据。"
21
- "/no_think"
22
- )
23
-
24
- ENGLISH_SYSTEM_PROMPT = (
25
- "You are an AI assistant. "
26
- "Please answer directly and naturally, using conversational English, without showing your thinking process. "
27
- "Your first sentence must be less than 10 words. "
28
- "Your responses should be accurate, concise, and well-supported, ideally around 2-3 sentences long to ensure a good conversational flow."
29
- "/no_think"
30
- )
31
-
32
 
33
  class LLMResponseGenerator(BaseThread):
34
  """LLM 回答生成器 - 负责使用语言模型生成回答文本"""
 
6
  from langchain_core.chat_history import InMemoryChatMessageHistory
7
 
8
  from voice_dialogue.config import paths
9
+ from voice_dialogue.config.llm_config import (
10
+ get_llm_model_params, get_apple_silicon_summary, CHINESE_SYSTEM_PROMPT, ENGLISH_SYSTEM_PROMPT
11
+ )
12
  from voice_dialogue.core.base import BaseThread
13
  from voice_dialogue.core.constants import chat_history_cache
14
  from voice_dialogue.models.voice_task import VoiceTask, QuestionDisplayMessage
 
16
  create_langchain_chat_llamacpp_instance, create_langchain_pipeline, warmup_langchain_pipeline
17
  from voice_dialogue.utils.logger import logger
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  class LLMResponseGenerator(BaseThread):
21
  """LLM 回答生成器 - 负责使用语言模型生成回答文本"""