from llama_index.llms import Ollama
from llama_index.agent import ReActAgent
from llama_index.tools import FunctionTool
from datetime import date
def add_numbers(a : int, b: int) -> int:
"""Adds two numbers and returns the result"""
return a+b
def get_current_date() -> date:
"""returns the current date"""
return date.today()
tools = [
FunctionTool.from_defaults(fn=add_numbers),
FunctionTool.from_defaults(fn=get_current_date)
]
llm = Ollama(model="mistral")
agent = ReActAgent.from_tools(tools, llm=llm, verbose=True)
response = agent.chat("what is today's date?")
from llama_index.llms.ollama import Ollama from llama_index.core.agent import ReActAgent from llama_index.core.tools import FunctionTool
pip install llama-index-llms-ollama
File "C:\Users\lhenry\AppData\Local\Programs\Python\Python312\Lib\site-packages\llama_index\llms\ollama\base.py", line 135, in chat
response.raise_for_status()
File "C:\Users\lhenry\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_models.py", line 761, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://localhost:11434/api/chat'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
PS C:\Users\lhenry\Desktop\Projects\AIProject>