Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPStatusError during Querying step in Ollama/Mistral/LlamaIndex Cookbook #56

Closed
garandria opened this issue Jun 18, 2024 · 1 comment

Comments

@garandria
Copy link

I am trying to run Ollama <> Mistral <> LlamaIndex Cookbook's notebook.

The Querying part of the notebook raises a HTTPStatusError:

In [3]: from llama_index.core.llms import ChatMessage
   ...:
   ...: messages = [
   ...:     ChatMessage(role="system", content="You are a helpful assistant."),
   ...:     ChatMessage(role="user", content="What is the capital city of France?"),
   ...: ]
   ...: response = llm.chat(messages)
---------------------------------------------------------------------------
HTTPStatusError                           Traceback (most recent call last)
Cell In[3], line 7
      1 from llama_index.core.llms import ChatMessage
      3 messages = [
      4     ChatMessage(role="system", content="You are a helpful assistant."),
      5     ChatMessage(role="user", content="What is the capital city of France?"),
      6 ]
----> 7 response = llm.chat(messages)

File ~/.py-venv/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    226 self.span_enter(
    227     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    228 )
    229 try:
--> 230     result = func(*args, **kwargs)
    231 except BaseException as e:
    232     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File ~/.py-venv/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py:172, in llm_chat_callback.<locals>.wrap.<locals>.wrapped_llm_chat(_self, messages, **kwargs)
    163 event_id = callback_manager.on_event_start(
    164     CBEventType.LLM,
    165     payload={
   (...)
    169     },
    170 )
    171 try:
--> 172     f_return_val = f(_self, messages, **kwargs)
    173 except BaseException as e:
    174     callback_manager.on_event_end(
    175         CBEventType.LLM,
    176         payload={EventPayload.EXCEPTION: e},
    177         event_id=event_id,
    178     )

File ~/.py-venv/lib/python3.11/site-packages/llama_index/llms/ollama/base.py:135, in Ollama.chat(self, messages, **kwargs)
    130 with httpx.Client(timeout=Timeout(self.request_timeout)) as client:
    131     response = client.post(
    132         url=f"{self.base_url}/api/chat",
    133         json=payload,
    134     )
--> 135     response.raise_for_status()
    136     raw = response.json()
    137     message = raw["message"]

File ~/.py-venv/lib/python3.11/site-packages/httpx/_models.py:761, in Response.raise_for_status(self)
    759 error_type = error_types.get(status_class, "Invalid status code")
    760 message = message.format(self, error_type=error_type)
--> 761 raise HTTPStatusError(message, request=request, response=self)

HTTPStatusError: Client error '404 Not Found' for url 'http:https://localhost:11434/api/chat'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

I have installed all the needed packages to run the notebook, from Ollama and pip.
In addition, the Ollama server is running and I can query it with the example curl code from the documentation:

 $ curl -X POST http:https://localhost:11434/api/generate -d '{
  "model": "mistral",
  "prompt":"Here is a story about llamas eating grass"
 }'
{"model":"mistral","created_at":"2024-06-18T08:03:01.76453978Z","response":" Title","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.057336093Z","response":":","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.346361586Z","response":" The","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.55772899Z","response":" L","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.670552331Z","response":"l","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.784986299Z","response":"ama","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.891749852Z","response":" G","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:02.995237782Z","response":"raz","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:03.102841835Z","response":"ers","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:03.229874023Z","response":" of","done":false}
{"model":"mistral","created_at":"2024-06-18T08:03:03.334951599Z","response":" the","done":false}
^C

Looks like everything is working well except the Querying done in the notebook. In fact, the server seems to work without failure using requests:

In [13]: payload = {"model":"mistral", "prompt": "is the sky blue ?", "stream": False}
In [14]: r = requests.post('http:https://localhost:11434/api/generate', json=payload)
In [15]: r
Out[15]: <Response [200]>
@garandria
Copy link
Author

Really sorry but I have made a mistake. In fact, I ran Ollama with ollama run mistral instead of the needed one ollama run mistral:instruct. Works fine with mistral:instruct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant