quarkusollamalangchain4j

Ollama not found with Quakus, forbidden with Firefox RESTED plugin


I'm running Ollama in Docker.
I tried to install it as a service, the issue is the same.
I'm on Unbuntu 22.04.
I created a Quarkus project with the quarkus-langchain4j-ollama dependency.
When I run the project with mvn quarkus:dev and then hit "d", I'm on the Quarkus Dev UI.
If I go to the chat and ask a question, I have a 404 error.

"Received: 'Not Found, status code 404' when invoking: Rest Client method: 'io.quarkiverse.langchain4j.ollama.OllamaRestApi#generate'"

If I check the Ollama Logs, I can see a call to "/api/generate".
My Docker compose file looks like this :

services:
  ollama:
    image: ollama/ollama
    container_name: ollama
    volumes:
      - ~/docker/data/ollama:/root/.ollama
    ports:
      - 11434:11434
    environment:
      - OLLAMA_HOST=0.0.0.0
      - OLLAMA_ORIGINS=http://0.0.0.0:11434

If I try to access it with the RESTED Firefox plugin, I have a 403 : Forbidden error.
And still, I can see a call to "/api/generate" in the Ollama logs.
And if I run the following curl, it works perfectly :

curl -X POST http://localhost:11434/api/generate -d '{ "model": "mistral", "prompt":"Tell me a joke" }'

Note : If I update OLLAMA_ORIGINS to Resteasy Reactive Client then the Quarkus error turns to

"io.netty.channel.AbstractChannel$AnnotatedConnectException: Connexion refusée: localhost/127.0.0.1:11434"

Solution

  • Finally, on the Quarkus side, it was all caused by a typo : in my application.properties, I typed

    quarkus.langchain4j.ollama.chat-model.model-id=mistral:lastest

    with an extra in latest.

    With

    quarkus.langchain4j.ollama.chat-model.model-id=mistral:latest

    it works perfectly.
    It's strange that the error was a 404 with no more explainations.

    On the Firefox plugin, it was fixed by adding and environment to the docker compose : OLLAMA_ORIGINS=moz-extension://* or on a larger scale : OLLAMA_ORIGINS=*