Skip to content

Commit 4384475

Browse files
fix: wire AgentGraph to read LLM and embedding from YAML config
Updated the Config Pydantic model and YAML schema to include llm and embedding fields. Modified AgentGraph constructor to accept these configurations and updated the chat-chainlit.py entry point to pass them from the loaded configuration. This removes hardcoded 'gpt-4o-mini' and 'text-embedding-3-large' references, making the agent models fully configurable.
1 parent 606850c commit 4384475

5 files changed

Lines changed: 18 additions & 3 deletions

File tree

.config.schema.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,10 @@ properties:
7878
pattern: "^[0-9]+[smhdw]$"
7979
required: ["users", "max_messages", "interval"]
8080
required: ["message_rates"]
81+
llm:
82+
type: string
83+
pattern: "^[a-z0-9_-]+/.+$"
84+
embedding:
85+
type: string
86+
pattern: "^[a-z0-9_-]+/.+$"
8187
required: ["features", "messages", "profiles", "usage_limits"]

bin/chat-chainlit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
config: Config | None = Config.from_yaml()
2121

2222
profiles: list[ProfileName] = config.profiles if config else [ProfileName.React_to_Me]
23-
llm_graph = AgentGraph(profiles)
23+
llm_config: str = config.llm if config else "openai/gpt-4o-mini"
24+
embedding_config: str = config.embedding if config else "openai/text-embedding-3-large"
25+
llm_graph = AgentGraph(profiles, llm_config=llm_config, embedding_config=embedding_config)
2426

2527
POSTGRES_CHAINLIT_DB = os.getenv("POSTGRES_CHAINLIT_DB")
2628
POSTGRES_USER = os.getenv("POSTGRES_USER")

config_default.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
profiles:
44
- React-to-Me
55

6+
llm: openai/gpt-4o-mini
7+
embedding: openai/text-embedding-3-large
8+
69
features:
710
postprocessing: # external web search feature
811
enabled: true

src/agent/graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ class AgentGraph:
2828
def __init__(
2929
self,
3030
profiles: list[ProfileName],
31+
llm_config: str = "openai/gpt-4o-mini",
32+
embedding_config: str = "openai/text-embedding-3-large",
3133
) -> None:
3234
# Get base models
33-
llm: BaseChatModel = get_llm("openai", "gpt-4o-mini")
34-
embedding: Embeddings = get_embedding("openai", "text-embedding-3-large")
35+
llm: BaseChatModel = get_llm(llm_config)
36+
embedding: Embeddings = get_embedding(embedding_config)
3537

3638
self.uncompiled_graph: dict[str, StateGraph] = create_profile_graphs(
3739
profiles, llm, embedding

src/util/config_yml/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Config(BaseModel):
2020
messages: dict[str, Message]
2121
profiles: list[ProfileName]
2222
usage_limits: UsageLimits
23+
llm: str = "openai/gpt-4o-mini"
24+
embedding: str = "openai/text-embedding-3-large"
2325

2426
def get_feature(
2527
self,

0 commit comments

Comments
 (0)