Spaces:
Paused
Paused
Update RAG_Learning_Assistant_with_Streaming.py via admin tool
Browse files
RAG_Learning_Assistant_with_Streaming.py
CHANGED
|
@@ -36,21 +36,22 @@ class RAGLearningAssistant:
|
|
| 36 |
|
| 37 |
# 模型配置
|
| 38 |
self.model = model
|
| 39 |
-
self.temperature = 0.
|
| 40 |
self.max_tokens = 2000
|
| 41 |
|
| 42 |
# 系统提示词
|
| 43 |
-
self.system_prompt = """
|
|
|
|
| 44 |
You have access to a knowledge base of course materials. When answering questions:
|
| 45 |
1. Stick to the provided context from the knowledge base.
|
| 46 |
-
2. If the
|
| 47 |
-
|
| 48 |
When a question posted, NEVER provide direct solutions for calculation questions, instead, ONLY provide what steps need to be done, and explain the steps.
|
| 49 |
If you solve the questions, you need to remind the users that you may make mistake, must check carefully.
|
| 50 |
-
|
| 51 |
Enclose mathematical formulas and parameters for proper Markdown rendering.
|
| 52 |
Bold key words if applicable.
|
| 53 |
At the end of your response, LIST 'title' (name of the chunks) & 'from' (Source info of the chunks, similar to: W 1.1 Introduction to Road Engineering, page 8) fields of the chunks that were used to answer the question.
|
|
|
|
| 54 |
"""
|
| 55 |
|
| 56 |
# 查询重写的系统提示词 - 改进版本
|
|
@@ -121,7 +122,7 @@ Return the entities as a JSON array of strings. Only include the most important
|
|
| 121 |
response = self.client.chat.completions.create(
|
| 122 |
model=self.model,
|
| 123 |
messages=messages,
|
| 124 |
-
temperature=0.
|
| 125 |
max_tokens=2000
|
| 126 |
)
|
| 127 |
|
|
|
|
| 36 |
|
| 37 |
# 模型配置
|
| 38 |
self.model = model
|
| 39 |
+
self.temperature = 0.2
|
| 40 |
self.max_tokens = 2000
|
| 41 |
|
| 42 |
# 系统提示词
|
| 43 |
+
self.system_prompt = """
|
| 44 |
+
You are a helpful learning assistant specializing in road engineering.
|
| 45 |
You have access to a knowledge base of course materials. When answering questions:
|
| 46 |
1. Stick to the provided context from the knowledge base.
|
| 47 |
+
2. If the response covers parameter explanation that involve value selection from tables, charts, or equations, tell user where to find them (e.g., Table 2.3 from Austroads guidance, page 32) or if necessary, present the table or equation.
|
| 48 |
+
3. If the knowledge base doesn't contain relevant information, say so. Students can go to the teaching team for further assistance.
|
| 49 |
When a question posted, NEVER provide direct solutions for calculation questions, instead, ONLY provide what steps need to be done, and explain the steps.
|
| 50 |
If you solve the questions, you need to remind the users that you may make mistake, must check carefully.
|
|
|
|
| 51 |
Enclose mathematical formulas and parameters for proper Markdown rendering.
|
| 52 |
Bold key words if applicable.
|
| 53 |
At the end of your response, LIST 'title' (name of the chunks) & 'from' (Source info of the chunks, similar to: W 1.1 Introduction to Road Engineering, page 8) fields of the chunks that were used to answer the question.
|
| 54 |
+
|
| 55 |
"""
|
| 56 |
|
| 57 |
# 查询重写的系统提示词 - 改进版本
|
|
|
|
| 122 |
response = self.client.chat.completions.create(
|
| 123 |
model=self.model,
|
| 124 |
messages=messages,
|
| 125 |
+
temperature=0.3, # 低温度确保一致性
|
| 126 |
max_tokens=2000
|
| 127 |
)
|
| 128 |
|