search_enhanced_qa.py
1 """ 2 This script demonstrates how to use the SearchEnhancedQA action to answer questions 3 by leveraging web search results. It showcases a simple example of querying about 4 the current weather in Beijing. 5 6 The SearchEnhancedQA action combines web search capabilities with natural language 7 processing to provide informative answers to user queries. 8 """ 9 10 import asyncio 11 12 from metagpt.actions.search_enhanced_qa import SearchEnhancedQA 13 14 15 async def main(): 16 """Runs a sample query through SearchEnhancedQA and prints the result.""" 17 18 action = SearchEnhancedQA() 19 20 query = "What is the weather like in Beijing today?" 21 answer = await action.run(query) 22 23 print(f"The answer to '{query}' is:\n\n{answer}") 24 25 26 if __name__ == "__main__": 27 asyncio.run(main())