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:
parent
bfd8d3bb68
commit
33908da18e
2 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue