From d64480ef28e6ccd68c67e77f4827f4986f54fc54 Mon Sep 17 00:00:00 2001 From: Musa Date: Mon, 22 Dec 2025 17:24:09 -0800 Subject: [PATCH] demo structure updated --- .../use_cases/travel_agents/arch_config.yaml | 2 +- .../src/travel_agents/currency_agent.py | 39 +++++-- .../src/travel_agents/flight_agent.py | 110 +++++++++++++++--- .../src/travel_agents/weather_agent.py | 14 ++- demos/use_cases/travel_agents/test.rest | 59 +++++++--- .../travel_agents/travel_agent_request.rest | 30 +++++ 6 files changed, 209 insertions(+), 45 deletions(-) create mode 100644 demos/use_cases/travel_agents/travel_agent_request.rest diff --git a/demos/use_cases/travel_agents/arch_config.yaml b/demos/use_cases/travel_agents/arch_config.yaml index b2f09087..ba00048a 100644 --- a/demos/use_cases/travel_agents/arch_config.yaml +++ b/demos/use_cases/travel_agents/arch_config.yaml @@ -15,7 +15,7 @@ model_providers: access_key: $OPENAI_API_KEY system_prompt: | - You are a helpful travel assistant. You are able to answer questions about weather, flights, and currency. You are able to answer questions about the weather in a city, the flights between two cities, and the currency exchange rate between two currencies. + You are a professional travel planner assistant. Your role is to provide accurate, clear, and helpful information about weather and flights based on the structured data provided to you.\n\nCRITICAL INSTRUCTIONS:\n\n1. DATA STRUCTURE:\n \n WEATHER DATA:\n - You will receive weather data as JSON in a system message\n - The data contains a \"location\" field (string) and a \"forecast\" array\n - Each forecast entry has: date, day_name, temperature_c, temperature_f, temperature_max_c, temperature_min_c, condition, sunrise, sunset\n - Some fields may be null/None - handle these gracefully\n \n FLIGHT DATA:\n - You will receive flight information in a system message\n - Flight data includes: airline, flight number, departure time, arrival time, origin airport, destination airport, aircraft type, status, gate, terminal\n - Information may include both scheduled and estimated times\n - Some fields may be unavailable - handle these gracefully\n\n2. WEATHER HANDLING:\n - For single-day queries: Use temperature_c/temperature_f (current/primary temperature)\n - For multi-day forecasts: Use temperature_max_c and temperature_min_c when available\n - Always provide temperatures in both Celsius and Fahrenheit when available\n - If temperature is null, say \"temperature data unavailable\" rather than making up numbers\n - Use exact condition descriptions provided (e.g., \"Clear sky\", \"Rainy\", \"Partly Cloudy\")\n - Add helpful context when appropriate (e.g., \"perfect for outdoor activities\" for clear skies)\n\n3. FLIGHT HANDLING:\n - Present flight information clearly with airline name and flight number\n - Include departure and arrival times with time zones when provided\n - Mention origin and destination airports with their codes\n - Include gate and terminal information when available\n - Note aircraft type if relevant to the query\n - Highlight any status updates (delays, early arrivals, etc.)\n - For multiple flights, list them in chronological order by departure time\n - If specific details are missing, acknowledge this rather than inventing information\n\n4. MULTI-PART QUERIES:\n - Users may ask about both weather and flights in one message\n - Answer ALL parts of the query that you have data for\n - Organize your response logically - typically weather first, then flights, or vice versa based on the query\n - Provide complete information for each topic without mentioning other agents\n - If you receive data for only one topic but the user asked about multiple, answer what you can with the provided data\n\n5. ERROR HANDLING:\n - If weather forecast contains an \"error\" field, acknowledge the issue politely\n - If temperature or condition is null/None, mention that specific data is unavailable\n - If flight details are incomplete, state which information is unavailable\n - Never invent or guess weather or flight data - only use what's provided\n - If location couldn't be determined, acknowledge this but still provide available data\n\n6. RESPONSE FORMAT:\n \n For Weather:\n - Single-day queries: Provide current conditions, temperature, and condition\n - Multi-day forecasts: List each day with date, day name, high/low temps, and condition\n - Include sunrise/sunset times when available and relevant\n \n For Flights:\n - List flights with clear numbering or bullet points\n - Include key details: airline, flight number, departure/arrival times, airports\n - Add gate, terminal, and status information when available\n - For multiple flights, organize chronologically\n \n General:\n - Use natural, conversational language\n - Be concise but complete\n - Format dates and times clearly\n - Use bullet points or numbered lists for clarity\n\n7. LOCATION HANDLING:\n - Always mention location names from the data\n - For flights, clearly state origin and destination cities/airports\n - If locations differ from what the user asked, acknowledge this politely\n\n8. RESPONSE STYLE:\n - Be friendly and professional\n - Use natural language, not technical jargon\n - Provide information in a logical, easy-to-read format\n - When answering multi-part queries, create a cohesive response that addresses all aspects\n\nRemember: Only use the data provided. Never fabricate weather or flight information. If data is missing, clearly state what's unavailable. Answer all parts of the user's query that you have data for. listeners: - type: agent diff --git a/demos/use_cases/travel_agents/src/travel_agents/currency_agent.py b/demos/use_cases/travel_agents/src/travel_agents/currency_agent.py index 43692460..7ad9c914 100644 --- a/demos/use_cases/travel_agents/src/travel_agents/currency_agent.py +++ b/demos/use_cases/travel_agents/src/travel_agents/currency_agent.py @@ -37,7 +37,7 @@ archgw_client = AsyncOpenAI( ) # System prompt for currency agent -SYSTEM_PROMPT = """You are a professional travel planner assistant. Your role is to provide accurate, clear, and helpful information about weather and flights based on the structured data provided to you. +SYSTEM_PROMPT = """You are a professional travel planner assistant. Your role is to provide accurate, clear, and helpful information about weather, flights, and currency exchange based on the structured data provided to you. CRITICAL INSTRUCTIONS: @@ -55,6 +55,11 @@ CRITICAL INSTRUCTIONS: - Information may include both scheduled and estimated times - Some fields may be unavailable - handle these gracefully + CURRENCY DATA: + - You will receive currency exchange data as JSON in a system message + - The data contains: from_currency, to_currency, rate, date, and optionally original_amount and converted_amount + - Some fields may be null/None - handle these gracefully + 2. WEATHER HANDLING: - For single-day queries: Use temperature_c/temperature_f (current/primary temperature) - For multi-day forecasts: Use temperature_max_c and temperature_min_c when available @@ -73,21 +78,29 @@ CRITICAL INSTRUCTIONS: - For multiple flights, list them in chronological order by departure time - If specific details are missing, acknowledge this rather than inventing information -4. MULTI-PART QUERIES: - - Users may ask about both weather and flights in one message +4. CURRENCY HANDLING: + - Present exchange rates clearly with both currency codes and names when helpful + - Include the date of the exchange rate + - If an amount was provided, show both the original and converted amounts + - Use clear formatting (e.g., "100 USD = 92.50 EUR" or "1 USD = 0.925 EUR") + - If rate data is unavailable, acknowledge this politely + +5. MULTI-PART QUERIES: + - Users may ask about weather, flights, and currency in one message - Answer ALL parts of the query that you have data for - - Organize your response logically - typically weather first, then flights, or vice versa based on the query + - Organize your response logically - typically weather first, then flights, then currency, or based on the query order - Provide complete information for each topic without mentioning other agents - If you receive data for only one topic but the user asked about multiple, answer what you can with the provided data -5. ERROR HANDLING: +6. ERROR HANDLING: - If weather forecast contains an "error" field, acknowledge the issue politely - If temperature or condition is null/None, mention that specific data is unavailable - If flight details are incomplete, state which information is unavailable - - Never invent or guess weather or flight data - only use what's provided + - If currency rate is unavailable, mention that specific data is unavailable + - Never invent or guess weather, flight, or currency data - only use what's provided - If location couldn't be determined, acknowledge this but still provide available data -6. RESPONSE FORMAT: +7. RESPONSE FORMAT: For Weather: - Single-day queries: Provide current conditions, temperature, and condition @@ -100,24 +113,30 @@ CRITICAL INSTRUCTIONS: - Add gate, terminal, and status information when available - For multiple flights, organize chronologically + For Currency: + - Show exchange rate clearly: "1 [FROM] = [RATE] [TO]" + - If amount provided: "[AMOUNT] [FROM] = [CONVERTED] [TO]" + - Include the date of the exchange rate + General: - Use natural, conversational language - Be concise but complete - Format dates and times clearly - Use bullet points or numbered lists for clarity -7. LOCATION HANDLING: +8. LOCATION HANDLING: - Always mention location names from the data - For flights, clearly state origin and destination cities/airports + - For currency, use country/city context to resolve currency references - If locations differ from what the user asked, acknowledge this politely -8. RESPONSE STYLE: +9. RESPONSE STYLE: - Be friendly and professional - Use natural language, not technical jargon - Provide information in a logical, easy-to-read format - When answering multi-part queries, create a cohesive response that addresses all aspects -Remember: Only use the data provided. Never fabricate weather or flight information. If data is missing, clearly state what's unavailable. Answer all parts of the user's query that you have data for.""" +Remember: Only use the data provided. Never fabricate weather, flight, or currency information. If data is missing, clearly state what's unavailable. Answer all parts of the user's query that you have data for.""" CURRENCY_EXTRACTION_PROMPT = """You are a currency information extraction assistant. Your ONLY job is to extract currency-related information from user messages and convert it to standard 3-letter ISO currency codes. diff --git a/demos/use_cases/travel_agents/src/travel_agents/flight_agent.py b/demos/use_cases/travel_agents/src/travel_agents/flight_agent.py index 57655c8f..5e0c8068 100644 --- a/demos/use_cases/travel_agents/src/travel_agents/flight_agent.py +++ b/demos/use_cases/travel_agents/src/travel_agents/flight_agent.py @@ -132,33 +132,48 @@ FLIGHT_EXTRACTION_PROMPT = """You are a flight information extraction assistant. CRITICAL RULES: 1. Extract origin city/airport and destination city/airport from the message AND conversation context 2. Extract any mentioned dates or time references -3. PAY ATTENTION TO CONVERSATION CONTEXT - THIS IS CRITICAL: +3. **CROSS-AGENT REFERENCE HANDLING - CRITICAL**: When extracting flight info, use cities mentioned in weather queries as context + - If a weather query mentions a city (e.g., "weather in Seattle"), use that city to fill missing flight origin/destination + - Example: "What is the weather in Seattle and what flight goes to New York direct?" + → Weather mentions "Seattle" → Use Seattle as flight origin + → Extract origin=Seattle, destination=New York + - Example: "What is the weather in Atlanta and what flight goes from Detroit to Atlanta?" + → Extract origin=Detroit, destination=Atlanta (both explicitly mentioned in flight part) + - **ALWAYS check conversation history for cities mentioned in weather queries** - use them to infer missing flight origin/destination +4. **MULTI-PART QUERY HANDLING**: When the user asks about both weather/flights/currency in one query, extract ONLY the flight-related parts + - Look for patterns like "flight from X to Y", "flights from X", "flights to Y", "flight goes from X to Y" + - Example: "What is the weather in Atlanta and what flight goes from Detroit to Atlanta?" → Extract origin=Detroit, destination=Atlanta (ignore Atlanta weather part) + - Example: "What's the weather in Seattle, and what is one flight that goes direct to Atlanta?" → Extract origin=Seattle (from weather context), destination=Atlanta + - Focus on the flight route, but use weather context to fill missing parts +5. PAY ATTENTION TO CONVERSATION CONTEXT - THIS IS CRITICAL: - If previous messages mention cities/countries, use that context to resolve pronouns and incomplete queries - Example 1: Previous: "What's the weather in Istanbul?" → Current: "Do they fly out from Seattle?" - → This likely means: "Do flights go from Istanbul to Seattle?" OR "Do flights go from Seattle to Istanbul?" - → Since Istanbul was mentioned first, interpret as: origin=Istanbul, destination=Seattle + → "they" refers to Istanbul → origin=Istanbul, destination=Seattle - Example 2: Previous: "What's the weather in London?" → Current: "What flights go from there to Seattle?" → "there" = London → origin=London, destination=Seattle - Example 3: Previous: "What's the exchange rate for Turkey?" → Current: "Do they have flights to Seattle?" → "they" refers to Turkey/Istanbul → origin=Istanbul, destination=Seattle -4. For follow-up questions like "Do they fly out from X?" or "Do they have flights to Y?": + - Example 4: Previous: "What is the weather in Seattle?" → Current: "What flight goes to New York direct?" + → Seattle mentioned in weather query → Use Seattle as origin → origin=Seattle, destination=New York +6. For follow-up questions like "Do they fly out from X?" or "Do they have flights to Y?": - Look for previously mentioned cities/countries in the conversation - If a city was mentioned earlier, use it as the missing origin or destination - If the question mentions a city explicitly, use that city - Try to infer the complete route from context -5. Extract dates and time references: +7. Extract dates and time references: - "tomorrow", "today", "next week", specific dates - Convert relative dates to ISO format (YYYY-MM-DD) when possible -6. Determine the origin and destination based on context: +8. Determine the origin and destination based on context: - "from X to Y" → origin=X, destination=Y - "X to Y" → origin=X, destination=Y + - "flight goes from X to Y" → origin=X, destination=Y - "flights from X" → origin=X, destination=null (UNLESS conversation context provides a previously mentioned city - use that as destination) - "flights to Y" → origin=null (UNLESS conversation context provides a previously mentioned city - use that as origin), destination=Y - "What flights go direct from X?" → origin=X, destination=from conversation context (if a city was mentioned earlier) - "Do they fly out from X?" → origin=X (or from context), destination=from context (check ALL previous messages for mentioned cities) - "Do they have flights to Y?" → origin=from context (check ALL previous messages), destination=Y - CRITICAL: When only one part (origin OR destination) is provided, ALWAYS check conversation history for the missing part -7. Return your response as a JSON object with the following structure: +8. Return your response as a JSON object with the following structure: { "origin": "London" or null, "destination": "Seattle" or null, @@ -167,14 +182,16 @@ CRITICAL RULES: "destination_airport_code": "SEA" or null } -8. If you cannot determine a value, use null for that field -9. Use city names (not airport codes) in origin/destination fields - airport codes will be resolved separately -10. Ignore error messages, HTML tags, and assistant responses -11. Extract from the most recent user message BUT use conversation context to resolve references -12. For dates: Use ISO format (YYYY-MM-DD). If relative date like "tomorrow", calculate the actual date -13. IMPORTANT: When a follow-up question mentions one city but context has another city, try to infer the complete route +9. If you cannot determine a value, use null for that field +10. Use city names (not airport codes) in origin/destination fields - airport codes will be resolved separately +11. Ignore error messages, HTML tags, and assistant responses +12. Extract from the most recent user message BUT use conversation context to resolve references +13. For dates: Use ISO format (YYYY-MM-DD). If relative date like "tomorrow", calculate the actual date +14. IMPORTANT: When a follow-up question mentions one city but context has another city, try to infer the complete route Examples with context: +- "What is the weather in Atlanta and what flight goes from Detroit to Atlanta?" → {"origin": "Detroit", "destination": "Atlanta", "date": null, "origin_airport_code": null, "destination_airport_code": null} +- "What is the weather in Seattle and what flight goes to New York direct?" → {"origin": "Seattle", "destination": "New York", "date": null, "origin_airport_code": null, "destination_airport_code": null} (Seattle from weather context) - Conversation: "What's the weather in Istanbul?" → Current: "Do they fly out from Seattle?" → {"origin": "Istanbul", "destination": "Seattle", "date": null, "origin_airport_code": null, "destination_airport_code": null} - Conversation: "What's the weather in Istanbul?" → Current: "What flights go direct from Seattle?" → {"origin": "Seattle", "destination": "Istanbul", "date": null, "origin_airport_code": null, "destination_airport_code": null} (Istanbul from previous context) - Conversation: "What's the weather in London?" → Current: "What flights go from there to Seattle?" → {"origin": "London", "destination": "Seattle", "date": null, "origin_airport_code": null, "destination_airport_code": null} @@ -313,6 +330,39 @@ async def extract_flight_info_from_messages(messages): "destination_airport_code": flight_info.get("destination_airport_code"), } + # Fallback: If origin is missing but we have destination, infer from weather context + if not result["origin"] and result["destination"]: + # Look for cities mentioned in weather queries in conversation context + for msg in reversed(conversation_context): + if msg["role"] == "user": + content = msg["content"] + # Look for weather queries mentioning cities + if ( + "weather" in content.lower() + or "forecast" in content.lower() + ): + # Common patterns: "weather in [city]", "forecast for [city]", "weather [city]" + patterns = [ + r"(?:weather|forecast).*?(?:in|for)\s+([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)", + r"weather\s+([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)", + ] + for pattern in patterns: + city_match = re.search(pattern, content, re.IGNORECASE) + if city_match: + potential_city = city_match.group(1).strip() + # Don't use the same city as destination + if ( + potential_city.lower() + != result["destination"].lower() + ): + logger.info( + f"Inferring origin from weather context in extraction: {potential_city}" + ) + result["origin"] = potential_city + break + if result["origin"]: + break + # Fallback: If destination is missing but we have origin, try to infer from conversation context if result["origin"] and not result["destination"]: # Look for cities mentioned in previous messages @@ -574,7 +624,39 @@ async def prepare_flight_messages(request_body: ChatCompletionRequest): origin_code = flight_info.get("origin_airport_code") dest_code = flight_info.get("destination_airport_code") - # Enhanced context extraction: If destination is missing, try to infer from conversation + # Enhanced context extraction: Use weather queries to infer missing origin or destination + # CRITICAL: When user asks "weather in X and flight to Y", use X as origin + if not origin and destination: + # Look through conversation history for cities mentioned in weather queries + for msg in request_body.messages: + if msg.role == "user": + content = msg.content + # Extract cities from weather queries: "weather in [city]", "forecast for [city]" + weather_patterns = [ + r"(?:weather|forecast).*?(?:in|for)\s+([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)", + r"weather\s+([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)", + ] + for pattern in weather_patterns: + matches = re.findall(pattern, content, re.IGNORECASE) + for match in matches: + city = match.strip() + # Use weather city as origin if it's different from destination + if ( + city.lower() != destination.lower() + and len(city.split()) <= 3 + ): + origin = city + logger.info( + f"Inferred origin from weather context: {origin} (destination: {destination})" + ) + flight_info["origin"] = origin + break + if origin: + break + if origin: + break + + # If destination is missing but origin is present, try to infer from conversation if origin and not destination: # Look through conversation history for mentioned cities mentioned_cities = set() diff --git a/demos/use_cases/travel_agents/src/travel_agents/weather_agent.py b/demos/use_cases/travel_agents/src/travel_agents/weather_agent.py index 74dfcd52..c0eb1f7d 100644 --- a/demos/use_cases/travel_agents/src/travel_agents/weather_agent.py +++ b/demos/use_cases/travel_agents/src/travel_agents/weather_agent.py @@ -307,10 +307,14 @@ LOCATION_EXTRACTION_PROMPT = """You are a location extraction assistant for WEAT CRITICAL RULES: 1. Extract ONLY the location name associated with WEATHER questions - nothing else 2. Return just the location name in plain text (e.g., "London", "New York", "Paris, France") -3. If the user mentions multiple locations in a multi-part query, extract ONLY the location mentioned in the WEATHER part - - Example: "What's the weather in Seattle, and what is one flight that goes direct to Atlanta?" → Extract "Seattle" (the weather location, NOT Atlanta which is for flights) +3. **MULTI-PART QUERY HANDLING**: If the user mentions multiple locations in a multi-part query, extract ONLY the location mentioned in the WEATHER part + - Look for patterns like "weather in [location]", "forecast for [location]", "weather [location]" + - The location that appears WITH "weather" keywords is the weather location + - Example: "What's the weather in Seattle, and what is one flight that goes direct to Atlanta?" → Extract "Seattle" (appears with "weather in") + - Example: "What is the weather in Atlanta and what flight goes from Detroit to Atlanta?" → Extract "Atlanta" (appears with "weather in", even though Atlanta also appears in flight part) - Example: "Weather in London and flights to Paris" → Extract "London" (weather location) -4. Look for patterns like "weather in [location]", "forecast for [location]", "weather [location]" + - Example: "What flight goes from Detroit to Atlanta and what's the weather in Atlanta?" → Extract "Atlanta" (appears with "weather in") +4. Look for patterns like "weather in [location]", "forecast for [location]", "weather [location]", "temperature in [location]" 5. Ignore error messages, HTML tags, and assistant responses 6. If no clear weather-related location is found, return exactly: "NOT_FOUND" 7. Clean the location name - remove words like "about", "for", "in", "the weather in", etc. @@ -320,8 +324,10 @@ Examples: - "What's the weather in London?" → "London" - "Tell me about the weather for New York" → "New York" - "Weather forecast for Paris, France" → "Paris, France" -- "What's the weather in Seattle, and what is one flight that goes direct to Atlanta?" → "Seattle" (NOT Atlanta - that's for flights) +- "What's the weather in Seattle, and what is one flight that goes direct to Atlanta?" → "Seattle" (appears with "weather in") +- "What is the weather in Atlanta and what flight goes from Detroit to Atlanta?" → "Atlanta" (appears with "weather in") - "Weather in Istanbul and flights to Seattle" → "Istanbul" (weather location) +- "What flight goes from Detroit to Atlanta and what's the weather in Atlanta?" → "Atlanta" (appears with "weather in") - "I'm going to Seattle" → "Seattle" (if context suggests weather query) - "What's happening?" → "NOT_FOUND" diff --git a/demos/use_cases/travel_agents/test.rest b/demos/use_cases/travel_agents/test.rest index 12858069..a8863b36 100644 --- a/demos/use_cases/travel_agents/test.rest +++ b/demos/use_cases/travel_agents/test.rest @@ -1,28 +1,55 @@ +@llm_endpoint = http://localhost:12000 + +### Travel Agent Chat Completion Request +POST {{llm_endpoint}}/v1/chat/completions HTTP/1.1 +Content-Type: application/json + +{ + "model": "gpt-4o", + "messages": [ + { + "role": "system", + "content": "You are a professional travel planner assistant. Your role is to provide accurate, clear, and helpful information about weather and flights based on the structured data provided to you.\n\nCRITICAL INSTRUCTIONS:\n\n1. DATA STRUCTURE:\n \n WEATHER DATA:\n - You will receive weather data as JSON in a system message\n - The data contains a \"location\" field (string) and a \"forecast\" array\n - Each forecast entry has: date, day_name, temperature_c, temperature_f, temperature_max_c, temperature_min_c, condition, sunrise, sunset\n - Some fields may be null/None - handle these gracefully\n \n FLIGHT DATA:\n - You will receive flight information in a system message\n - Flight data includes: airline, flight number, departure time, arrival time, origin airport, destination airport, aircraft type, status, gate, terminal\n - Information may include both scheduled and estimated times\n - Some fields may be unavailable - handle these gracefully\n\n2. WEATHER HANDLING:\n - For single-day queries: Use temperature_c/temperature_f (current/primary temperature)\n - For multi-day forecasts: Use temperature_max_c and temperature_min_c when available\n - Always provide temperatures in both Celsius and Fahrenheit when available\n - If temperature is null, say \"temperature data unavailable\" rather than making up numbers\n - Use exact condition descriptions provided (e.g., \"Clear sky\", \"Rainy\", \"Partly Cloudy\")\n - Add helpful context when appropriate (e.g., \"perfect for outdoor activities\" for clear skies)\n\n3. FLIGHT HANDLING:\n - Present flight information clearly with airline name and flight number\n - Include departure and arrival times with time zones when provided\n - Mention origin and destination airports with their codes\n - Include gate and terminal information when available\n - Note aircraft type if relevant to the query\n - Highlight any status updates (delays, early arrivals, etc.)\n - For multiple flights, list them in chronological order by departure time\n - If specific details are missing, acknowledge this rather than inventing information\n\n4. MULTI-PART QUERIES:\n - Users may ask about both weather and flights in one message\n - Answer ALL parts of the query that you have data for\n - Organize your response logically - typically weather first, then flights, or vice versa based on the query\n - Provide complete information for each topic without mentioning other agents\n - If you receive data for only one topic but the user asked about multiple, answer what you can with the provided data\n\n5. ERROR HANDLING:\n - If weather forecast contains an \"error\" field, acknowledge the issue politely\n - If temperature or condition is null/None, mention that specific data is unavailable\n - If flight details are incomplete, state which information is unavailable\n - Never invent or guess weather or flight data - only use what's provided\n - If location couldn't be determined, acknowledge this but still provide available data\n\n6. RESPONSE FORMAT:\n \n For Weather:\n - Single-day queries: Provide current conditions, temperature, and condition\n - Multi-day forecasts: List each day with date, day name, high/low temps, and condition\n - Include sunrise/sunset times when available and relevant\n \n For Flights:\n - List flights with clear numbering or bullet points\n - Include key details: airline, flight number, departure/arrival times, airports\n - Add gate, terminal, and status information when available\n - For multiple flights, organize chronologically\n \n General:\n - Use natural, conversational language\n - Be concise but complete\n - Format dates and times clearly\n - Use bullet points or numbered lists for clarity\n\n7. LOCATION HANDLING:\n - Always mention location names from the data\n - For flights, clearly state origin and destination cities/airports\n - If locations differ from what the user asked, acknowledge this politely\n\n8. RESPONSE STYLE:\n - Be friendly and professional\n - Use natural language, not technical jargon\n - Provide information in a logical, easy-to-read format\n - When answering multi-part queries, create a cohesive response that addresses all aspects\n\nRemember: Only use the data provided. Never fabricate weather or flight information. If data is missing, clearly state what's unavailable. Answer all parts of the user's query that you have data for." + }, + { + "role": "system", + "content": "Current weather data for Seattle:\n\n{\n \"location\": \"Seattle\",\n \"forecast\": [\n {\n \"date\": \"2025-12-22\",\n \"day_name\": \"Monday\",\n \"temperature_c\": 8.3,\n \"temperature_f\": 46.9,\n \"temperature_max_c\": 8.3,\n \"temperature_min_c\": 2.8,\n \"condition\": \"Rainy\",\n \"sunrise\": \"07:55\",\n \"sunset\": \"16:20\"\n }\n ]\n}\n\nUse this data to answer the user's weather query." + }, + { + "role": "system", + "content": "Here are some direct flights from Seattle to Atlanta on December 23, 2025:\n\n1. **Delta Airlines Flight DL552**\n - **Departure:** Scheduled at 3:47 PM (Seattle Time), from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 8:31 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Terminal at Atlanta:** S\n - **Estimated arrival slightly early**: 8:26 PM\n\n2. **Delta Airlines Flight DL542**\n - **Departure:** Scheduled at 12:00 PM (Seattle Time), Gate A4, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 4:49 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** E10, Terminal: S\n - **Estimated early arrival**: 4:44 PM\n\n3. **Delta Airlines Flight DL554**\n - **Departure:** Scheduled at 10:15 AM (Seattle Time), Gate A10, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 4:05 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** B19, Terminal: S\n - **Estimated late arrival**: 4:06 PM\n\n4. **Alaska Airlines Flight AS334**\n - **Departure:** Scheduled at 9:16 AM (Seattle Time), Gate C20, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 5:08 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** C5, Terminal: N\n\nThese are just a few of the direct flights available. Please let me know if you need more details on any other specific flight." + }, + { + "role": "user", + "content": "What's the weather in Seattle?" + }, + { + "role": "assistant", + "content": "The weather in Seattle is sunny with a temperature of 60 degrees Fahrenheit." + }, + { + "role": "user", + "content": "What is one Alaska flight that goes direct to Atlanta from Seattle?" + } + ], + "max_tokens": 1000, + "stream": false, + "temperature": 1.0 +} + + +### test 8001 + ### test upstream llm -POST http://localhost:12000/v1/chat/completions HTTP/1.1 +POST http://localhost:8001/v1/chat/completions HTTP/1.1 Content-Type: application/json { "messages": [ - { - "role": "system", - "content": "You are a professional travel planner assistant. Your role is to provide accurate, clear, and helpful information about weather and flights based on the structured data provided to you.\n\nCRITICAL INSTRUCTIONS:\n\n1. DATA STRUCTURE:\n \n WEATHER DATA:\n - You will receive weather data as JSON in a system message\n - The data contains a \"location\" field (string) and a \"forecast\" array\n - Each forecast entry has: date, day_name, temperature_c, temperature_f, temperature_max_c, temperature_min_c, condition, sunrise, sunset\n - Some fields may be null/None - handle these gracefully\n \n FLIGHT DATA:\n - You will receive flight information in a system message\n - Flight data includes: airline, flight number, departure time, arrival time, origin airport, destination airport, aircraft type, status, gate, terminal\n - Information may include both scheduled and estimated times\n - Some fields may be unavailable - handle these gracefully\n\n2. WEATHER HANDLING:\n - For single-day queries: Use temperature_c/temperature_f (current/primary temperature)\n - For multi-day forecasts: Use temperature_max_c and temperature_min_c when available\n - Always provide temperatures in both Celsius and Fahrenheit when available\n - If temperature is null, say \"temperature data unavailable\" rather than making up numbers\n - Use exact condition descriptions provided (e.g., \"Clear sky\", \"Rainy\", \"Partly Cloudy\")\n - Add helpful context when appropriate (e.g., \"perfect for outdoor activities\" for clear skies)\n\n3. FLIGHT HANDLING:\n - Present flight information clearly with airline name and flight number\n - Include departure and arrival times with time zones when provided\n - Mention origin and destination airports with their codes\n - Include gate and terminal information when available\n - Note aircraft type if relevant to the query\n - Highlight any status updates (delays, early arrivals, etc.)\n - For multiple flights, list them in chronological order by departure time\n - If specific details are missing, acknowledge this rather than inventing information\n\n4. MULTI-PART QUERIES:\n - Users may ask about both weather and flights in one message\n - Answer ALL parts of the query that you have data for\n - Organize your response logically - typically weather first, then flights, or vice versa based on the query\n - Provide complete information for each topic without mentioning other agents\n - If you receive data for only one topic but the user asked about multiple, answer what you can with the provided data\n\n5. ERROR HANDLING:\n - If weather forecast contains an \"error\" field, acknowledge the issue politely\n - If temperature or condition is null/None, mention that specific data is unavailable\n - If flight details are incomplete, state which information is unavailable\n - Never invent or guess weather or flight data - only use what's provided\n - If location couldn't be determined, acknowledge this but still provide available data\n\n6. RESPONSE FORMAT:\n \n For Weather:\n - Single-day queries: Provide current conditions, temperature, and condition\n - Multi-day forecasts: List each day with date, day name, high/low temps, and condition\n - Include sunrise/sunset times when available and relevant\n \n For Flights:\n - List flights with clear numbering or bullet points\n - Include key details: airline, flight number, departure/arrival times, airports\n - Add gate, terminal, and status information when available\n - For multiple flights, organize chronologically\n \n General:\n - Use natural, conversational language\n - Be concise but complete\n - Format dates and times clearly\n - Use bullet points or numbered lists for clarity\n\n7. LOCATION HANDLING:\n - Always mention location names from the data\n - For flights, clearly state origin and destination cities/airports\n - If locations differ from what the user asked, acknowledge this politely\n\n8. RESPONSE STYLE:\n - Be friendly and professional\n - Use natural language, not technical jargon\n - Provide information in a logical, easy-to-read format\n - When answering multi-part queries, create a cohesive response that addresses all aspects\n\nRemember: Only use the data provided. Never fabricate weather or flight information. If data is missing, clearly state what's unavailable. Answer all parts of the user's query that you have data for." - }, { "role": "system", "content": "\nCurrent weather data for Seattle:\n\n{\n \"location\": \"Seattle\",\n \"forecast\": [\n {\n \"date\": \"2025-12-22\",\n \"day_name\": \"Monday\",\n \"temperature_c\": 8.3,\n \"temperature_f\": 46.9,\n \"temperature_max_c\": 8.3,\n \"temperature_min_c\": 2.8,\n \"condition\": \"Rainy\",\n \"sunrise\": \"07:55\",\n \"sunset\": \"16:20\"\n }\n ]\n}\n\nUse this data to answer the user's weather query." - }, - { - "role": "system", - "content": "Here are some direct flights from Seattle to Atlanta on December 23, 2025:\n\n1. **Delta Airlines Flight DL552**\n - **Departure:** Scheduled at 3:47 PM (Seattle Time), from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 8:31 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Terminal at Atlanta:** S\n - **Estimated arrival slightly early**: 8:26 PM\n\n2. **Delta Airlines Flight DL542**\n - **Departure:** Scheduled at 12:00 PM (Seattle Time), Gate A4, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 4:49 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** E10, Terminal: S\n - **Estimated early arrival**: 4:44 PM\n\n3. **Delta Airlines Flight DL554**\n - **Departure:** Scheduled at 10:15 AM (Seattle Time), Gate A10, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 4:05 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** B19, Terminal: S\n - **Estimated late arrival**: 4:06 PM\n\n4. **Alaska Airlines Flight AS334**\n - **Departure:** Scheduled at 9:16 AM (Seattle Time), Gate C20, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 5:08 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** C5, Terminal: N\n\nThese are just a few of the direct flights available. Please let me know if you need more details on any other specific flight." - }, - { - "role": "user", - "content": "What flight goes direct to Atlanta from Seattle, and what is the weather in Seattle?" } ], "model": "gpt-4o", - "max_tokens": 1000, - "stream": false, - "temperature": 1.0 } diff --git a/demos/use_cases/travel_agents/travel_agent_request.rest b/demos/use_cases/travel_agents/travel_agent_request.rest new file mode 100644 index 00000000..90a92995 --- /dev/null +++ b/demos/use_cases/travel_agents/travel_agent_request.rest @@ -0,0 +1,30 @@ +@llm_endpoint = http://localhost:12000 + +### Travel Agent Chat Completion - Full Conversation +POST {{llm_endpoint}}/v1/chat/completions HTTP/1.1 +Content-Type: application/json + +{ + "model": "gpt-4o", + "messages": [ + { + "role": "system", + "content": "You are a professional travel planner assistant. Your role is to provide accurate, clear, and helpful information about weather and flights based on the structured data provided to you.\n\nCRITICAL INSTRUCTIONS:\n\n1. DATA STRUCTURE:\n \n WEATHER DATA:\n - You will receive weather data as JSON in a system message\n - The data contains a \"location\" field (string) and a \"forecast\" array\n - Each forecast entry has: date, day_name, temperature_c, temperature_f, temperature_max_c, temperature_min_c, condition, sunrise, sunset\n - Some fields may be null/None - handle these gracefully\n \n FLIGHT DATA:\n - You will receive flight information in a system message\n - Flight data includes: airline, flight number, departure time, arrival time, origin airport, destination airport, aircraft type, status, gate, terminal\n - Information may include both scheduled and estimated times\n - Some fields may be unavailable - handle these gracefully\n\n2. WEATHER HANDLING:\n - For single-day queries: Use temperature_c/temperature_f (current/primary temperature)\n - For multi-day forecasts: Use temperature_max_c and temperature_min_c when available\n - Always provide temperatures in both Celsius and Fahrenheit when available\n - If temperature is null, say \"temperature data unavailable\" rather than making up numbers\n - Use exact condition descriptions provided (e.g., \"Clear sky\", \"Rainy\", \"Partly Cloudy\")\n - Add helpful context when appropriate (e.g., \"perfect for outdoor activities\" for clear skies)\n\n3. FLIGHT HANDLING:\n - Present flight information clearly with airline name and flight number\n - Include departure and arrival times with time zones when provided\n - Mention origin and destination airports with their codes\n - Include gate and terminal information when available\n - Note aircraft type if relevant to the query\n - Highlight any status updates (delays, early arrivals, etc.)\n - For multiple flights, list them in chronological order by departure time\n - If specific details are missing, acknowledge this rather than inventing information\n\n4. MULTI-PART QUERIES:\n - Users may ask about both weather and flights in one message\n - Answer ALL parts of the query that you have data for\n - Organize your response logically - typically weather first, then flights, or vice versa based on the query\n - Provide complete information for each topic without mentioning other agents\n - If you receive data for only one topic but the user asked about multiple, answer what you can with the provided data\n\n5. ERROR HANDLING:\n - If weather forecast contains an \"error\" field, acknowledge the issue politely\n - If temperature or condition is null/None, mention that specific data is unavailable\n - If flight details are incomplete, state which information is unavailable\n - Never invent or guess weather or flight data - only use what's provided\n - If location couldn't be determined, acknowledge this but still provide available data\n\n6. RESPONSE FORMAT:\n \n For Weather:\n - Single-day queries: Provide current conditions, temperature, and condition\n - Multi-day forecasts: List each day with date, day name, high/low temps, and condition\n - Include sunrise/sunset times when available and relevant\n \n For Flights:\n - List flights with clear numbering or bullet points\n - Include key details: airline, flight number, departure/arrival times, airports\n - Add gate, terminal, and status information when available\n - For multiple flights, organize chronologically\n \n General:\n - Use natural, conversational language\n - Be concise but complete\n - Format dates and times clearly\n - Use bullet points or numbered lists for clarity\n\n7. LOCATION HANDLING:\n - Always mention location names from the data\n - For flights, clearly state origin and destination cities/airports\n - If locations differ from what the user asked, acknowledge this politely\n\n8. RESPONSE STYLE:\n - Be friendly and professional\n - Use natural language, not technical jargon\n - Provide information in a logical, easy-to-read format\n - When answering multi-part queries, create a cohesive response that addresses all aspects\n\nRemember: Only use the data provided. Never fabricate weather or flight information. If data is missing, clearly state what's unavailable. Answer all parts of the user's query that you have data for." + }, + { + "role": "assistant", + "content": "Current weather data for Seattle:\n\n{\n \"location\": \"Seattle\",\n \"forecast\": [\n {\n \"date\": \"2025-12-22\",\n \"day_name\": \"Monday\",\n \"temperature_c\": 8.3,\n \"temperature_f\": 46.9,\n \"temperature_max_c\": 8.3,\n \"temperature_min_c\": 2.8,\n \"condition\": \"Rainy\",\n \"sunrise\": \"07:55\",\n \"sunset\": \"16:20\"\n }\n ]\n}\n\nUse this data to answer the user's weather query." + }, + { + "role": "assistant", + "content": "Here are some direct flights from Seattle to Atlanta on December 23, 2025:\n\n1. **Delta Airlines Flight DL552**\n - **Departure:** Scheduled at 3:47 PM (Seattle Time), from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 8:31 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Terminal at Atlanta:** S\n - **Estimated arrival slightly early**: 8:26 PM\n\n2. **Delta Airlines Flight DL542**\n - **Departure:** Scheduled at 12:00 PM (Seattle Time), Gate A4, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 4:49 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** E10, Terminal: S\n - **Estimated early arrival**: 4:44 PM\n\n3. **Delta Airlines Flight DL554**\n - **Departure:** Scheduled at 10:15 AM (Seattle Time), Gate A10, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 4:05 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** B19, Terminal: S\n - **Estimated late arrival**: 4:06 PM\n\n4. **Alaska Airlines Flight AS334**\n - **Departure:** Scheduled at 9:16 AM (Seattle Time), Gate C20, from Seattle-Tacoma Intl (SEA)\n - **Arrival:** Scheduled at 5:08 PM (Atlanta Time), at Hartsfield-Jackson Intl (ATL)\n - **Aircraft:** Boeing 737-900 (B739)\n - **Status:** Scheduled\n - **Gate at Atlanta:** C5, Terminal: N\n\nThese are just a few of the direct flights available. Please let me know if you need more details on any other specific flight." + }, + { + "role": "user", + "content": "What is the weather in Atlanta and what flight goes from Seattle to Atlanta?" + } + ], + "max_tokens": 1000, + "stream": false, + "temperature": 1.0 +}