graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

Missing required `LLMConfig` for Azure OpenAI in documentation example

Open PrettyWood opened this issue 7 months ago • 0 comments

Hello and thanks for your work on this library! Seems really promising :)

The documentation example at Graphiti Azure OpenAI integration does not include the necessary LLMConfig when initializing OpenAIClient with custom model names.

I had to go into internals of graphiti to understand how it works and there were issues here

To fix this, the example should show explicit use of LLMConfig(model=..., small_model=...) with the appropriate Azure deployment names.

Here is a MRE

import asyncio
import os
from datetime import datetime, timezone

from graphiti_core import Graphiti
from graphiti_core.cross_encoder.openai_reranker_client import OpenAIRerankerClient
from graphiti_core.embedder.openai import OpenAIEmbedder, OpenAIEmbedderConfig
from graphiti_core.llm_client.client import LLMConfig
from graphiti_core.llm_client.openai_client import OpenAIClient
from graphiti_core.nodes import EpisodeType
from openai import AsyncAzureOpenAI


async def test_azure_deployments():
    azure_openai_client = AsyncAzureOpenAI(
        api_key=os.getenv("AZURE_LLM_API_KEY"),
        api_version=os.getenv("AZURE_LLM_API_VERSION"),
        azure_endpoint=os.getenv("AZURE_LLM_ENDPOINT"),
    )
    azure_llm_config = LLMConfig(
        small_model="gpt-4o-mini",
        model="gpt-4o-mini",
    )

    graphiti = Graphiti(
        "bolt://localhost:7687",
        "neo4j",
        "password",
        llm_client=OpenAIClient(
            config=azure_llm_config,
            client=azure_openai_client,
        ),
        embedder=OpenAIEmbedder(
            config=OpenAIEmbedderConfig(
                embedding_model="text-embedding-3-small",
            ),
            client=azure_openai_client,
        ),
        cross_encoder=OpenAIRerankerClient(
            config=azure_llm_config,
            client=azure_openai_client,
        ),
    )

    try:
        await graphiti.add_episode(
            name="rippletide_short_description",
            episode_body="Rippletide is a company that is building Sales AGI.",
            source=EpisodeType.text,
            source_description="company information",
            reference_time=datetime.now(timezone.utc),
        )
    except Exception as e:
        print(f"❌ Episode error: {e}")
    else:
        print("✅ Episode added")


asyncio.run(test_azure_deployments())

PrettyWood avatar Jun 04 '25 04:06 PrettyWood