fix sht
This commit is contained in:
@@ -44,6 +44,14 @@ class SimpleRag:
|
|||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def retrieve(self, query:str):
|
def retrieve(self, query:str):
|
||||||
|
"""检索与给定查询相关的文档,并将其序列化为字符串格式。
|
||||||
|
参数:
|
||||||
|
query (str): 用户输入的查询字符串。
|
||||||
|
返回:
|
||||||
|
Tuple[str, List[Document]]:
|
||||||
|
- 序列化后的文档内容字符串,每个文档包含来源和内容。
|
||||||
|
- 检索到的 Document 对象列表。
|
||||||
|
该工具用于基于向量存储检索相关文档,适用于问答和知识检索场景。"""
|
||||||
retrieved_docs:List[Document] = self.vec_store.search(query, search_kwargs={"k":3})
|
retrieved_docs:List[Document] = self.vec_store.search(query, search_kwargs={"k":3})
|
||||||
serialized = "\n\n".join(
|
serialized = "\n\n".join(
|
||||||
(f"Source: {doc.metadata}\nContent: {doc.page_content}")
|
(f"Source: {doc.metadata}\nContent: {doc.page_content}")
|
||||||
@@ -53,6 +61,7 @@ class SimpleRag:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
config = tyro.cli(SimpleRagConfig)
|
# config = tyro.cli(SimpleRagConfig)
|
||||||
rag = SimpleRag(config)
|
config = SimpleRagConfig()
|
||||||
|
rag:SimpleRag = config.setup()
|
||||||
mcp.run(transport="stdio")
|
mcp.run(transport="stdio")
|
||||||
Reference in New Issue
Block a user