Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -35,16 +35,17 @@ def initialize_llm(api_key: str):
|
|
35 |
# 定义 Prompt 模板
|
36 |
def initialize_prompt_template():
|
37 |
from langchain_core.prompts import PromptTemplate
|
38 |
-
template_text =
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
return PromptTemplate(
|
44 |
input_variables=["question", "context"],
|
45 |
template=template_text
|
46 |
)
|
47 |
|
|
|
48 |
# 将检索到的文档内容格式化为字符串
|
49 |
def format_docs(docs) -> str:
|
50 |
return "\n\n".join(doc.page_content for doc in docs)
|
|
|
35 |
# 定义 Prompt 模板
|
36 |
def initialize_prompt_template():
|
37 |
from langchain_core.prompts import PromptTemplate
|
38 |
+
template_text = """请根据以下 context 回答问题,答案请使用 Markdown 格式输出。
|
39 |
+
如果 context 存在latex表达式,请正确书写。
|
40 |
+
如果 context 中包含图表链接,请在回答中原封不动地加入图表,并在每个包含"/images"的链接前添加前缀 "https://huggingface.co/spaces/zliang/palynogeology/resolve/main"。
|
41 |
+
Question: {question}
|
42 |
+
Context: {context}"""
|
43 |
return PromptTemplate(
|
44 |
input_variables=["question", "context"],
|
45 |
template=template_text
|
46 |
)
|
47 |
|
48 |
+
|
49 |
# 将检索到的文档内容格式化为字符串
|
50 |
def format_docs(docs) -> str:
|
51 |
return "\n\n".join(doc.page_content for doc in docs)
|