Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/memory_agent/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
"""Utility functions used in our graph."""


def split_model_and_provider(fully_specified_name: str) -> dict:
"""Initialize the configured chat model."""
"""Split a fully specified model name into provider and model components.

Args:
fully_specified_name: String in format "provider/model" (e.g., "anthropic/claude-3").
If no provider is specified, returns provider=None.

Returns:
Dictionary with keys "model" (str) and "provider" (str | None).
"""
if not isinstance(fully_specified_name, str):
raise ValueError("Input must be a string")

if not fully_specified_name:
raise ValueError("Input string cannot be empty")

if "/" in fully_specified_name:
provider, model = fully_specified_name.split("/", maxsplit=1)
if not provider or not model:
raise ValueError("Provider and model must both be specified when using '/'")
else:
provider = None
model = fully_specified_name

return {"model": model, "provider": provider}