Guest User

Untitled

a guest
Oct 25th, 2026
44
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.27 KB | None | 0 0
  1. from langchain_mcp_adapters.client import MultiServerMCPClient
  2. import asyncio
  3. from dotenv import load_dotenv
  4. load_dotenv()
  5. async def main():
  6.     client = MultiServerMCPClient(
  7.         {
  8.             "travel_server": {
  9.                 "transport":"streamable_http",
  10.                 "url":"https://mcp.kiwi.com"
  11.             }
  12.         }
  13.     )
  14.     tools = await client.get_tools()
  15.  
  16. asyncio.run(main())
  17.  
  18.  
  19. from typing import Dict, Any
  20. from tavily import TavilyClient
  21. from langchain.tools import tool
  22. tavily_client = TavilyClient()
  23.  
  24. @tool
  25. def web_search(query: str, search_number: int, max_search_number: int) -> Dict[str, Any]:
  26.     """Search the web for information. You must track your search count by providing
  27.    search_number (starting at 1) and max_search_number on every call.
  28.    Queries must use only plain text characters. Do not use accented or special characters    
  29.      (e.g., use 'capacite' instead of 'capacité').
  30.    """
  31.     if search_number > max_search_number:
  32.         return {"message": "Search limit reached. Please summarize your findings and provide your final answer."}
  33.     try:
  34.         return tavily_client.search(query)
  35.     except Exception as e:
  36.         return {"error": str(e)}
  37.  
  38.  
  39. from langchain_community.utilities import SQLDatabase
  40. db = SQLDatabase.from_uri("sqlite:///resources/Chinook.db")
  41.  
  42. @tool
  43. def query_playlist_db(query: str) -> str:
  44.     """Query the database for playlist information"""
  45.     try:
  46.         return db.run(query)
  47.     except Exception as e:
  48.         return f"Error querying database: {e}"
  49.  
  50. # the thing i did is wrong as of now and i need to learn how to fix the async
  51.  
  52.  
  53. # create a state
  54. from langchain.agents import AgentState
  55.  
  56. class WeddingState(AgentState):
  57.     origin: str
  58.     destination: str
  59.     guest_count: str
  60.     genre: str
  61.  
  62. # subagents
  63. from langchain.agents import create_agent
  64.  
  65. # Travel agent
  66. travel_agent = create_agent(
  67.     model="gpt-5-nano",
  68.     tools=tools,
  69.     system_prompt="""
  70.    You are a travel agent. Search for flights to the desired destination wedding location.
  71.    You are not allowed to ask any more follow up questions, you must find the best flight options based on the following criteria:
  72.    - Price (lowest, economy class)
  73.    - Duration (shortest)
  74.    - Date (time of year which you believe is best for a wedding at this location)
  75.    To make things easy, only look for one ticket, one way.
  76.    You may need to make multiple searches to iteratively find the best options.
  77.    You will be given no extra information, only the origin and destination. It is your job to think critically about the best options.
  78.    If the MCP tool fails, returns malformed output, or does not give you usable flight results, try the tool again.
  79.    Once you have found the best options, let the user know your shortlist of options.
  80.    """
  81. )
  82.  
  83. # Venue agent
  84. venue_agent = create_agent(
  85.     model="gpt-5-nano",
  86.     tools=[web_search],
  87.     system_prompt="""
  88.    You are a venue specialist. Search for venues in the desired location, and with the desired capacity.
  89.    You are not allowed to ask any more follow up questions, you must find the best venue options based on the following criteria:
  90.    - Price (lowest)
  91.    - Capacity (exact match)
  92.    - Reviews (highest)
  93.    You may need to make multiple searches to iteratively find the best options.
  94.    You have a suggested limit of 12 web searches. Count every web_search call you make.
  95.    After 12 searches, you should stop searching and summarize the best options you have
  96.    found so far.
  97.    """
  98. )
  99.  
  100. # Playlist agent
  101. playlist_agent = create_agent(
  102.     model="gpt-5-nano",
  103.     tools=[query_playlist_db],
  104.     system_prompt="""
  105.    You are a playlist specialist. Query the sql database and curate the perfect playlist for a wedding given a genre.
  106.    Once you have your playlist, calculate the total duration and cost of the playlist, each song has an associated price.
  107.    If you run into errors when querying the database, try to fix them by making changes to the query.
  108.    Do not come back empty handed, keep trying to query the db until you find a list of songs.
  109.  
  110.    This is a SQLite database. Before writing any data queries, first discover the schema.
  111.    """
  112. )
  113.  
  114.  
  115. from langchain.tools import ToolRuntime
  116. from langchain.messages import HumanMessage, ToolMessage
  117. from langgraph.types import Command
  118.  
  119. @tool
  120. async def search_flights(runtime: ToolRuntime) -> str:
  121.     """Travel agent searches for flights to the desired destination wedding location."""
  122.     origin = runtime.state["origin"]
  123.     destination = runtime.state["destination"]
  124.     response = await travel_agent.ainvoke({"messages": [HumanMessage(content=f"Find flights from {origin} to {destination}")]})
  125.     return response['messages'][-1].content
  126.  
  127. @tool
  128. def search_venues(runtime: ToolRuntime) -> str:
  129.     """Venue agent chooses the best venue for the given location and capacity."""
  130.     destination = runtime.state["destination"]
  131.     capacity = runtime.state["guest_count"]
  132.     query = f"Find wedding venues in {destination} for {capacity} guests"
  133.     response = venue_agent.invoke({"messages": [HumanMessage(content=query)]})
  134.     return response['messages'][-1].content
  135.  
  136. @tool
  137. def suggest_playlist(runtime: ToolRuntime) -> str:
  138.     """Playlist agent curates the perfect playlist for the given genre."""
  139.     genre = runtime.state["genre"]
  140.     query = f"Find {genre} tracks for wedding playlist"
  141.     response = playlist_agent.invoke({"messages": [HumanMessage(content=query)]})
  142.     return response['messages'][-1].content
  143.  
  144. @tool
  145. def update_state(origin: str, destination: str, guest_count: str, genre: str, runtime: ToolRuntime) -> str:
  146.     """Update the state when you know all of the values: origin, destination, guest_count, genre.
  147.    This tool must be called alone, without any other tool calls. It must complete and return to make,
  148.    the information available to other tools."""
  149.     return Command(update={
  150.         "origin": origin,
  151.         "destination": destination,
  152.         "guest_count": guest_count,
  153.         "genre": genre,
  154.         "messages": [ToolMessage("Successfully updated state", tool_call_id=runtime.tool_call_id)]}
  155.         )
  156.  
  157. from langchain.agents import create_agent
  158. async def main_1():
  159.     coordinator = create_agent(
  160.         model="gpt-5-nano",
  161.         tools=[search_flights, search_venues, suggest_playlist, update_state],
  162.         state_schema=WeddingState,
  163.         system_prompt="""
  164.        You are a wedding coordinator.
  165.        First find all the information you need to update the state. When you have the information, update the state.
  166.        Once that has completed and returned, you can delegate the tasks
  167.        to your specialists for flights, venues, and playlists.
  168.        Once you have received their answers, coordinate the perfect wedding for me.
  169.        """
  170.     )
  171.  
  172.     from langchain.messages import HumanMessage
  173.     response = await coordinator.ainvoke(
  174.         {
  175.             "messages": [HumanMessage(content="I'm from London and I'd like a wedding in Paris for 100 guests, jazz-genre")],
  176.         },
  177.         config={"tags": ["WP"], "recursion_limit": 40},  #tag traces to make them easy to find in Langsmith. Increase number of steps the agent can take to 40.
  178.     )
  179.     print(response["messages"][-1].content)
  180. asyncio.run(main_1())
  181.  
Advertisement
Comments
  • Fomyrve
    18 hours
    # CSS 0.92 KB | 0 0
    1. ✅ Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1WhlQi8xpq819kqTE2nXcZTAeCgQ5m-ic2pm_7IZVt7w/edit?usp=sharing
    4.  
    5. This made me $12,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 50% — they will simply correct the exchange rate.
    8.  
    9. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    10.  
    11. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from Changelly — instant swap).
    12.  
    13. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment