Spaces:
Build error
Build error
| import requests | |
| from llama_index.tools.wikipedia import WikipediaToolSpec | |
| from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec | |
| from llama_index.tools.code_interpreter import CodeInterpreterToolSpec | |
| from llama_index.core.tools import FunctionTool | |
| # wikipedia search tool | |
| wiki_spec = WikipediaToolSpec() | |
| wiki_tool = wiki_spec.to_tool_list() | |
| # duckduckgo search tool | |
| ddgo_spec = DuckDuckGoSearchToolSpec() | |
| ddgo_tool = ddgo_spec.to_tool_list() | |
| # execute python code and return the stdout and stderr. | |
| code_spec = CodeInterpreterToolSpec() | |
| code_tool = code_spec.to_tool_list() | |
| def download_file(url: str, save_path: str) -> str: | |
| """Download a file from a given URL and save it to the specified path.""" | |
| response = requests.get(url) | |
| with open(save_path, 'wb') as file: | |
| file.write(response.content) | |
| return f"File downloaded to (save_path)" | |
| download_tool = FunctionTool.from_defaults( | |
| fn=download_file, | |
| name="download_file_tool", | |
| description="A tool to download files from an HTTPS API endpoint. The tool accepts two arguments: The https url path to download the file and the location to save the downloaded file. If no auguments are passed then use the default values. Default values: For 'url' use 'https://agents-course-unit4-scoring.hf.space/files/{task_id}' and for 'save_path' use the current path." | |
| ) | |
| # agent complete tool list | |
| agent_tools_list = wiki_tool + ddgo_tool + code_tool + [download_tool] | |