Spaces:
Running
Running
Update agent_llamaindex.py
Browse files- agent_llamaindex.py +3 -3
agent_llamaindex.py
CHANGED
@@ -6,7 +6,7 @@ from llama_index.agent import OpenAIAgent
|
|
6 |
from llama_index.llms import OpenAI
|
7 |
from llama_index.tools import FunctionTool
|
8 |
|
9 |
-
def
|
10 |
"""Returns today's date. Use this for any questions related to knowing today's date.
|
11 |
The input should always be an empty string, and this function will always return today's date.
|
12 |
Any date mathematics should occur outside this function."""
|
@@ -20,11 +20,11 @@ def agent_llamaindex(config, prompt):
|
|
20 |
tool_spec = OpenWeatherMapToolSpec(key = os.environ["OPENWEATHERMAP_API_KEY"])
|
21 |
tools = tool_spec.to_tool_list()
|
22 |
|
23 |
-
|
24 |
|
25 |
agent = OpenAIAgent.from_tools(
|
26 |
[tools[0], # built-in tools
|
27 |
-
|
28 |
llm = llm,
|
29 |
verbose = True
|
30 |
)
|
|
|
6 |
from llama_index.llms import OpenAI
|
7 |
from llama_index.tools import FunctionTool
|
8 |
|
9 |
+
def today_tool(text: str) -> str:
|
10 |
"""Returns today's date. Use this for any questions related to knowing today's date.
|
11 |
The input should always be an empty string, and this function will always return today's date.
|
12 |
Any date mathematics should occur outside this function."""
|
|
|
20 |
tool_spec = OpenWeatherMapToolSpec(key = os.environ["OPENWEATHERMAP_API_KEY"])
|
21 |
tools = tool_spec.to_tool_list()
|
22 |
|
23 |
+
date_tool = FunctionTool.from_defaults(fn = today_tool)
|
24 |
|
25 |
agent = OpenAIAgent.from_tools(
|
26 |
[tools[0], # built-in tools
|
27 |
+
date_tool], # custom tools
|
28 |
llm = llm,
|
29 |
verbose = True
|
30 |
)
|