提升搜索代理与本地搜索能力的先进框架
AgentSearch是一个创新框架,通过结合多家提供商的LLM技术与搜索引擎,增强搜索代理性能。支持搜索结果总结、查询生成与深度检索,还能部署个性化本地搜索解决方案,提供多样的API接入选项。
AgentSearch 是一个框架,旨在通过将不同供应商的语言模型技术(LLM)与各类搜索引擎无缝集成,从而支持搜索代理。这种集成使得搜索代理可以通过检索增强生成(RAG)执行多种功能,包括总结搜索结果、生成新查询和检索详细的后续结果。
可以通过以下命令进行安装:
pip install agent-search
从 SciPhi 获取免费 API 密钥,并在环境中设置:
export SCIPHI_API_KEY=$MY_SCIPHI_API_KEY
调用预配置的搜索代理端点:
from agent_search import SciPhi client = SciPhi() # 搜索,摘要结果并生成相关查询 agent_summary = client.get_search_rag_response(query='latest news', search_provider='bing', llm_model='SciPhi/Sensei-7B-V1') print(agent_summary)
支持独立搜索以及使用 AgentSearch 搜索引擎:
from agent_search import SciPhi client = SciPhi() # 执行搜索 search_response = client.search(query='Quantum Field Theory', search_provider='agent-search') print(search_response)
自定义编写搜索代理工作流程:
from agent_search import SciPhi client = SciPhi() instruction = "Your task is to perform retrieval augmented generation (RAG) over the given query and search results. Return your answer in a json format that includes a summary of the search results and a list of related queries." query = "What is Fermat's Last Theorem?" search_response = client.search(query=query, search_provider='agent-search') search_context = "\n\n".join( f"{idx + 1}. Title: {item['title']}\nURL: {item['url']}\nText: {item['text']}" for idx, item in enumerate(search_response) ).encode('utf-8') json_response_prefix = '{"summary":' formatted_prompt = f"### Instruction:{instruction}\n\nQuery:\n{query}\n\nSearch Results:\n${search_context}\n\nQuery:\n{query}\n### Response:\n{json_response_prefix}" completion = json_response_prefix + client.completion(formatted_prompt, llm_model_name="SciPhi/Sensei-7B-V1") print(completion)