22 lines
564 B
Python
22 lines
564 B
Python
"""
|
|
Utility functions for the LangGraph project.
|
|
"""
|
|
|
|
from langchain_openai import ChatOpenAI
|
|
from typing import Dict, Any
|
|
|
|
def get_llm() -> ChatOpenAI:
|
|
"""
|
|
Returns a configured OpenAI LLM instance.
|
|
"""
|
|
# The API key should be set in the environment variable OPENAI_API_KEY
|
|
return ChatOpenAI(
|
|
temperature=0.7,
|
|
model_name="gpt-3.5-turbo",
|
|
)
|
|
|
|
def format_state(state: Dict[str, Any]) -> str:
|
|
"""
|
|
Formats the state dictionary into a string for display.
|
|
"""
|
|
return "\n".join(f"{k}: {v}" for k, v in state.items()) |