Skip to content

Embedding with ollama #12

@kleyton67

Description

@kleyton67

Env in Docker using ollama.
Trying to use embeddings from model: https://ollama.com/library/nomic-embed-text ;

Using example from https://langroid.github.io/langroid/tutorials/local-llm-setup/.

Changing
...
embed_provider: str = typer.Option(
"hf",
"--embed",
"-e",
help="Embedding service provider",
# openai, hf, llamacpp
),
embed_config: str = typer.Option(
"hf",
"--embedconfig",
"-ec",
help="Embedding service host/sentence transformer model",
),
...

        logger.info("Using embedding from ollama!!!")
        embed_cfg = lr.embedding_models.OpenAIEmbeddingsConfig(
            api_base="http://10.28.33.120:11434/v1",
            model_name=embed_config,
            api_key=" "
        )

...
agent = DocChatAgent(config)

When try to run the script, got the follow error:

2025-12-07 16:13:18 - WARNING - SSL verification has been disabled. This is insecure and should only be used in trusted environments (e.g., corporate networks with self-signed certificates).
2025-12-07 16:13:18 - WARNING - REDIS_PASSWORD, REDIS_HOST, REDIS_PORT not set in .env file,
using fake redis client
ValueError:
OPENAI_API_KEY must be set in .env or your environment
to use OpenAIEmbeddings.

Behavior: The app end without finish process.

Expected behavior: Wait input for data to talk with docs.

OBS: My ollama api doesnt have api key (already using it with openwebUI).

python environment:
Python 3.12.12
langroid==0.59.21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions