Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,11 @@ import os
|
|
11 |
# --- 1. 配置部分 ---
|
12 |
VECTOR_STORE_PATH = "vector_store"
|
13 |
EMBEDDING_MODEL = "BAAI/bge-large-zh-v1.5"
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
# --- 2. 加载RAG核心管道 ---
|
17 |
# 将所有耗时操作封装起来,只在应用启动时执行一次
|
18 |
def load_rag_chain():
|
@@ -62,7 +65,19 @@ def load_rag_chain():
|
|
62 |
)
|
63 |
|
64 |
# 定义Prompt模板
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
背景知识:
|
68 |
{context}
|
|
|
11 |
# --- 1. 配置部分 ---
|
12 |
VECTOR_STORE_PATH = "vector_store"
|
13 |
EMBEDDING_MODEL = "BAAI/bge-large-zh-v1.5"
|
14 |
+
|
15 |
+
# 切换到TheBloke提供的、更稳定且强大的Qwen1.5模型
|
16 |
+
GGUF_MODEL_REPO = "TheBloke/Qwen1.5-7B-Chat-GGUF"
|
17 |
+
# 我们选择一个大小适中的4位量化版本
|
18 |
+
GGUF_MODEL_FILE = "qwen1_5-7b-chat.Q4_K_M.gguf"
|
19 |
# --- 2. 加载RAG核心管道 ---
|
20 |
# 将所有耗时操作封装起来,只在应用启动时执行一次
|
21 |
def load_rag_chain():
|
|
|
65 |
)
|
66 |
|
67 |
# 定义Prompt模板
|
68 |
+
prompt_template = """<|im_start|>system
|
69 |
+
You are a helpful assistant named "粤小智". Answer the user's question based on the provided "Context".
|
70 |
+
Your answer should be in Chinese, clear, and step-by-step if it's an operation guide.
|
71 |
+
If you don't know the answer from the context, just say: "抱歉,关于您的问题,我的知识库暂时没有相关信息。". Do not make up answers.
|
72 |
+
<|im_end|>
|
73 |
+
<|im_start|>user
|
74 |
+
Context:
|
75 |
+
{context}
|
76 |
+
|
77 |
+
Question:
|
78 |
+
{question}<|im_end|>
|
79 |
+
<|im_start|>assistant
|
80 |
+
"""
|
81 |
|
82 |
背景知识:
|
83 |
{context}
|