feat: add OpenAI configuration options to Settings and update LLM client setup (#126)

* chore: Add model and base url customization support for graphiti svc

* fix: formatter
This commit is contained in:
Pavlo Paliychuk 2024-09-19 16:35:36 -04:00 committed by GitHub
parent bfd8d3bb68
commit 33908da18e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -2,11 +2,14 @@ from functools import lru_cache
from typing import Annotated
from fastapi import Depends
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict # type: ignore
class Settings(BaseSettings):
openai_api_key: str
openai_base_url: str | None = Field(None)
model_name: str | None = Field(None)
neo4j_uri: str
neo4j_user: str
neo4j_password: str

View file

@ -54,6 +54,12 @@ async def get_graphiti(settings: ZepEnvDep):
user=settings.neo4j_user,
password=settings.neo4j_password,
)
if settings.openai_base_url is not None:
client.llm_client.config.base_url = settings.openai_base_url
if settings.openai_api_key is not None:
client.llm_client.config.api_key = settings.openai_api_key
if settings.model_name is not None:
client.llm_client.model = settings.model_name
try:
yield client
finally: