Skip to content

[BUG] Small Model setting is not adhered instead always defaulting to gpt-4.1-nano #791

@kameshbrao

Description

@kameshbrao

Bug Description

I'm using Ollama and trying the custom entity and edge type example and when try to search it fails with the below error

openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4.1-nano" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}

My Ollama setttings are as follows

`# Configure Ollama LLM client
llm_config = LLMConfig(
api_key="abc", # Ollama doesn't require a real API key
model="deepseek-r1:8b",
small_model="deepseek-r1:8b",
base_url="http://localhost:11434/v1", # Ollama provides this port
)

llm_client = OpenAIClient(config=llm_config)

Initialize Graphiti with Ollama clients

graphiti = Graphiti(
"bolt://localhost:7687",
"neo4j",
"xxxxx",
llm_client=llm_client,
embedder=OpenAIEmbedder(
config=OpenAIEmbedderConfig(
api_key="abc",
embedding_model="nomic-embed-text",
embedding_dim=768,
base_url="http://localhost:11434/v1",
)
),
cross_encoder=OpenAIRerankerClient(client=llm_client, config=llm_config),
)`

Steps to Reproduce

the code that causes this error is
`entity_types = {
"Person": Person,
"Company": Company,
"Product": Product
}

    edge_types = {
        "Employment": Employment,
        "Investment": Investment,
        "Partnership": Partnership
    }

    edge_type_map = {
        ("Person", "Company"): ["Employment"],
        ("Company", "Company"): ["Partnership", "Investment"],
        ("Person", "Person"): ["Partnership"],
        ("Entity", "Entity"): ["Investment"],  # Apply to any entity type
    }

    await graphiti.add_episode(
        name="Employee Update",
        episode_body="Kamesh joined MBRDI as CTO in July 2019 with a $200K salary. MBRDI partnered with Mercedes-Benz in a $5M deal.",
        source_description="Business news",
        reference_time=datetime.now(),
        entity_types=entity_types,
        edge_types=edge_types,
        edge_type_map=edge_type_map
    )

   

    #Search for only specific entity types
    search_filter = SearchFilters(
        node_labels=["Person", "Company"]  # Only return Person and Company entities
    )

    results = await graphiti.search_(
        query="Who works at tech companies?",
        search_filter=search_filter
    )

    # Search for only specific edge types
    search_filter = SearchFilters(
        edge_types=["Employment", "Partnership"]  # Only return Employment and Partnership edges
    )

    results = await graphiti.search_(
        query="Tell me about business relationships",
        search_filter=search_filter
    )`
entity_types = {
            "Person": Person,
            "Company": Company,
            "Product": Product
        }

        edge_types = {
            "Employment": Employment,
            "Investment": Investment,
            "Partnership": Partnership
        }

        edge_type_map = {
            ("Person", "Company"): ["Employment"],
            ("Company", "Company"): ["Partnership", "Investment"],
            ("Person", "Person"): ["Partnership"],
            ("Entity", "Entity"): ["Investment"],  # Apply to any entity type
        }

        await graphiti.add_episode(
            name="Employee Update",
            episode_body="Kamesh joined MBRDI as CTO in July 2019 with a $200K salary. MBRDI partnered with Mercedes-Benz in a $5M deal.",
            source_description="Business news",
            reference_time=datetime.now(),
            entity_types=entity_types,
            edge_types=edge_types,
            edge_type_map=edge_type_map
        )

       

        #Search for only specific entity types
        search_filter = SearchFilters(
            node_labels=["Person", "Company"]  # Only return Person and Company entities
        )

        results = await graphiti.search_(
            query="Who works at tech companies?",
            search_filter=search_filter
        )

        # Search for only specific edge types
        search_filter = SearchFilters(
            edge_types=["Employment", "Partnership"]  # Only return Employment and Partnership edges
        )

        results = await graphiti.search_(
            query="Tell me about business relationships",
            search_filter=search_filter
        )

Expected Behavior

The code should work properly as the small_model is configured already in the LLMConfig

Actual Behavior

Instead it fails and falls back to the small_model default

openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4.1-nano" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}

Environment

  • Graphiti Version: [0.18.0]
  • Python Version: [3.12]
  • Operating System: [ macOS 14.0, ]
  • Database Backend: [Neo4j 5.26,]
  • LLM Provider & Model: [Ollama with deepseek-r1:8b ]

Installation Method

  • uv add

Error Messages/Traceback

Traceback (most recent call last):
  File "/Users/KAMERAO/Projects/graphiti/ollama.py", line 325, in <module>
    asyncio.run(main())
  File "/Users/KAMERAO/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/ollama.py", line 299, in main
    results = await graphiti.search_(
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/graphiti.py", line 940, in search_
    return await search(
           ^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/search/search.py", line 97, in search
    ) = await semaphore_gather(
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/helpers.py", line 120, in semaphore_gather
    return await asyncio.gather(*(_wrap_coroutine(coroutine) for coroutine in coroutines))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/helpers.py", line 118, in _wrap_coroutine
    return await coroutine
           ^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/search/search.py", line 345, in node_search
    reranked_node_names = await cross_encoder.rank(query, list(name_to_uuid_map.keys()))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/cross_encoder/openai_reranker_client.py", line 84, in rank
    responses = await semaphore_gather(
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/helpers.py", line 120, in semaphore_gather
    return await asyncio.gather(*(_wrap_coroutine(coroutine) for coroutine in coroutines))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/graphiti_core/helpers.py", line 118, in _wrap_coroutine
    return await coroutine
           ^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2454, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/openai/_base_client.py", line 1791, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/KAMERAO/Projects/graphiti/.venv/lib/python3.12/site-packages/openai/_base_client.py", line 1591, in request
    raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4.1-nano" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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