Skip to content

Commit

Permalink
model name as const
Browse files Browse the repository at this point in the history
  • Loading branch information
r-carroll committed Feb 8, 2025
1 parent 4bf83f6 commit c69fde7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions example_agent/utils/ex_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

load_dotenv()

environ_model_name = os.environ.get("MODEL_NAME")
ENVIRON_MODEL_NAME = os.environ.get("MODEL_NAME")

@lru_cache(maxsize=4)
def _get_tool_model(model_name: str):
Expand Down Expand Up @@ -46,7 +46,7 @@ def multi_choice_structured(state: AgentState, config):
# We call the model with structured output in order to return the same format to the user every time
# state['messages'][-2] is the last ToolMessage in the convo, which we convert to a HumanMessage for the model to use
# We could also pass the entire chat history, but this saves tokens since all we care to structure is the output of the tool
model_name = config.get("configurable", {}).get("model_name", environ_model_name)
model_name = config.get("configurable", {}).get("model_name", ENVIRON_MODEL_NAME)

response = _get_response_model(model_name).invoke(
[
Expand All @@ -72,18 +72,20 @@ def structure_response(state: AgentState, config):
# if not multi-choice don't need to do anything
return {"messages": []}


system_prompt = """
You are an oregon trail playing tool calling AI agent. Use the tools available to you to answer the question you are presented. When in doubt use the tools to help you find the answer.
If anyone asks your first name is Art return just that string.
"""


# Define the function that calls the model
def call_tool_model(state: AgentState, config):
# Combine system prompt with incoming messages
messages = [{"role": "system", "content": system_prompt}] + state["messages"]

# Get from LangGraph config
model_name = config.get("configurable", {}).get("model_name", environ_model_name)
model_name = config.get("configurable", {}).get("model_name", ENVIRON_MODEL_NAME)

# Get our model that binds our tools
model = _get_tool_model(model_name)
Expand Down

0 comments on commit c69fde7

Please sign in to comment.