Browse Source

chore: 优化提示词,移除多余接口

main
tanxing 5 days ago
parent
commit
7e4f2f8dc8
  1. 4
      deepsearcher/agent/deep_search.py
  2. 61
      main.py

4
deepsearcher/agent/deep_search.py

@ -91,7 +91,7 @@ REFLECT_PROMPT = """
SUMMARY_PROMPT = """
你是一个内容分析专家
请你综合已经提出的问题和检索到的信息以原问题为中心生成详细准确层次分明尽可能长的回答
请你综合已经提出的问题和检索到的信息以原问题为中心生成详细准确层次分明多级标题从一级开始尽可能长的回答
如果检索到的信息不足以回答问题你应该使用你的知识来进行扩展补充
注意不要逐个回答问题而是应该综合所有问题和信息生成一个完整的回答
同时你应该根据提供的信息生成文内引用"[^index]"(markdown文内引用)
@ -149,7 +149,7 @@ class DeepSearch(BaseAgent):
max_iter: The maximum number of iterations for the search process.
route_collection: Whether to use a collection router for search.
text_window_splitter: Whether to use text_window splitter.
enable_web_search: Whether to enable web search functionality.
web_search: Whether to enable web search functionality.
**kwargs: Additional keyword arguments for customization.
"""
self.llm = llm

61
main.py

@ -10,10 +10,10 @@ import os
import asyncio
import json
import queue
from typing import AsyncGenerator
from collections.abc import AsyncGenerator
from deepsearcher.configuration import Configuration, init_config
from deepsearcher.offline_loading import load_from_local_files, load_from_website
from deepsearcher.offline_loading import load_from_local_files
from deepsearcher.online_query import query
from deepsearcher.utils.message_stream import get_message_stream
@ -146,63 +146,6 @@ def load_files(
raise HTTPException(status_code=500, detail=str(e))
@app.post("/load-website/")
def load_website(
urls: str | list[str] = Body(
...,
description="A list of URLs of websites to be loaded.",
examples=["https://milvus.io/docs/overview.md"],
),
collection_name: str = Body(
None,
description="Optional name for the collection.",
examples=["my_collection"],
),
collection_description: str = Body(
None,
description="Optional description for the collection.",
examples=["This is a test collection."],
),
batch_size: int = Body(
None,
description="Optional batch size for the collection.",
examples=[256],
),
force_rebuild: bool = Body(
False,
description="Whether to force rebuild the collection if it already exists.",
examples=[False],
),
):
"""
Load website content into the vector database.
Args:
urls (Union[str, List[str]]): URLs of websites to load.
collection_name (str, optional): Name for the collection. Defaults to None.
collection_description (str, optional): Description for the collection. Defaults to None.
batch_size (int, optional): Batch size for processing. Defaults to None.
force_rebuild (bool, optional): Whether to force rebuild the collection. Defaults to False.
Returns:
dict: A dictionary containing a success message.
Raises:
HTTPException: If loading website content fails.
"""
try:
load_from_website(
urls=urls,
collection_name=collection_name,
collection_description=collection_description,
batch_size=batch_size if batch_size is not None else 8,
force_rebuild=force_rebuild,
)
return {"message": "成功加载"}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/query-stream/")
async def perform_query_stream(
original_query: str = Query(

Loading…
Cancel
Save