Spaces:
Sleeping
Sleeping
Create tools.py
Browse files
tools.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from llama_index.tools.wikipedia import WikipediaToolSpec
|
| 2 |
+
from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
|
| 3 |
+
from llama_index.core.tools.tool_spec.load_and_search import LoadAndSearchToolSpec
|
| 4 |
+
|
| 5 |
+
def add(a: int, b: int) -> int:
|
| 6 |
+
"""Add two numbers"""
|
| 7 |
+
return a + b
|
| 8 |
+
|
| 9 |
+
def subtract(a: int, b: int) -> int:
|
| 10 |
+
"""Subtract two numbers"""
|
| 11 |
+
return a - b
|
| 12 |
+
|
| 13 |
+
def multiply(a: int, b: int) -> int:
|
| 14 |
+
"""Multiply two numbers"""
|
| 15 |
+
return a * b
|
| 16 |
+
|
| 17 |
+
def divide(a: int, b: int) -> int:
|
| 18 |
+
"""Divide two numbers"""
|
| 19 |
+
return a / b
|
| 20 |
+
|
| 21 |
+
wiki_tool_spec = WikipediaToolSpec().to_tool_list()[1]
|
| 22 |
+
search_tool_spec = DuckDuckGoSearchToolSpec()
|
| 23 |
+
|
| 24 |
+
wiki_tool = LoadAndSearchToolSpec.from_defaults(wiki_tool_spec).to_tool_list()
|
| 25 |
+
search_tool = search_tool_spec.duckduckgo_full_search
|