Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save vaygeth89/4626c4de35f5ec977f12cd718584b63e to your computer and use it in GitHub Desktop.

Select an option

Save vaygeth89/4626c4de35f5ec977f12cd718584b63e to your computer and use it in GitHub Desktop.
import asyncio
from datetime import datetime
from langchain.agents import create_agent, AgentState
from langchain_ollama import ChatOllama
from langchain_openai import ChatOpenAI
from langchain.messages import HumanMessage
from langchain.tools import tool
import mlflow
mlflow.set_tracking_uri("http://localhost:5000")
mlflow.set_experiment("wedding-planner-agent-experiment")
mlflow.autolog()
print("Hello from wedding planner agent!")
model = ChatOpenAI(
model_name="qwen3-vl:235b-cloud", api_key="", base_url="http://localhost:11434/v1"
)
@tool(
"get_flight_recommendations",
description="Retrieve flight recommendations for a given destination and date.",
)
def get_flight_recommendations(destination: str, date: str) -> str:
"""Retrieve flight recommendations for a given destination and date."""
return f"Recommended flights to {destination} on {date}: Flight A123, Flight B456."
@tool(
"get_venues_recommendations",
description="Recommend vanues based on certain location",
)
def get_venues_recommendation(destination: str) -> list[str]:
"""Retrieve Venues based on location/area/destination"""
return ["Coffee Shop XY", "Arcade Game Center"]
@tool("get_suggest_playlist", description="Suggest playlist based on type of event")
def get_suggest_playlist(event: str) -> list[str]:
"""Suggest music playlist for different events"""
return ["linked-park reanimatio", "yani: within attraction"]
flights_agent = create_agent(
model=model,
system_prompt="You are a wedding planner agent. Your job is to help users plan their weddings by providing recommendations on venues, catering, and entertainment.",
tools=[get_flight_recommendations],
)
venues_agent = create_agent(
model=model,
system_prompt="You are a venue recommendation agent. Your job is to suggest wedding venues based on user preferences.",
tools=[get_venues_recommendation],
)
playlist_agent = create_agent(
model=model,
system_prompt="You are a wedding playlist agent. Your job is to create wedding playlists based on user music tastes.",
tools=[get_suggest_playlist],
)
@tool(
"call_flight_agent",
description="Call the flight agent to get all flights for a destination.",
)
def call_flight_agent(destination: str, date: datetime) -> str:
"""Call the Flight Agent to get all flights."""
response = flights_agent.invoke(
{
"messages": [
HumanMessage(
content=f"Get all flights available on {date} for following destination {destination}"
)
]
}
)
return response["messages"][-1].content
@tool(
"call_venues_agent",
description="Call the venues_agent to a recommendation vanues based on destination.",
)
def call_venues_agent(destination: str) -> str:
"""Call the venues agent to suggest venues"""
response = venues_agent.invoke(
{
"messages": [
HumanMessage(
content=f"Recommend venues for following destination {destination}"
)
]
}
)
return response["messages"][-1].content
@tool(
"call_summarization_agent",
description="Call the playlist agent to suggest a playlist for an event",
)
def call_playlist_agent(event: str) -> str:
"""Call the playlist agent"""
response = playlist_agent.invoke(
{
"messages": [
HumanMessage(
content=f"Find a suitable playlist music for following event:{event}"
)
]
}
)
return response["messages"][-1].content
supervisor = create_agent(
model=model,
system_prompt="You're a Wedding Planner Agent that is part of a multi-agent system collaborating to plan a wedding event, coordinating with different agents to plan the event such as finding the flights, suggest venues and music playlist",
tools=[call_flight_agent, call_venues_agent, call_playlist_agent],
)
messages = []
while True:
user_message = input("User: ")
human_message = HumanMessage(content=user_message)
messages.append(human_message)
response = supervisor.invoke({"messages": messages})
messages = response["messages"]
print(messages[-1].content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment