QA with web search

This commit is contained in:
seehi 2024-08-01 10:18:36 +08:00
parent e11d03fe5b
commit a366ed37d7
4 changed files with 328 additions and 24 deletions

View file

@ -0,0 +1,27 @@
"""
This script demonstrates how to use the SearchEnhancedQA action to answer questions
by leveraging web search results. It showcases a simple example of querying about
the current weather in Beijing.
The SearchEnhancedQA action combines web search capabilities with natural language
processing to provide informative answers to user queries.
"""
import asyncio
from metagpt.actions.search_enhanced_qa import SearchEnhancedQA
async def main():
"""Runs a sample query through SearchEnhancedQA and prints the result."""
action = SearchEnhancedQA()
query = "What is the weather like in Beijing today?"
answer = await action.run(query)
print(f"The answer to '{query}' is:\n\n{answer}")
if __name__ == "__main__":
asyncio.run(main())