| | """ |
| | Copyright (c) 2023, salesforce.com, inc. |
| | All rights reserved. |
| | SPDX-License-Identifier: Apache License 2.0 |
| | For full license text, see the LICENSE file in the repo root or https://www.apache.org/licenses/LICENSE-2.0 |
| | """ |
| |
|
| |
|
| | |
| | import sys, os |
| | import random |
| |
|
| | templates = [ |
| | "This is a bot helping users to _____. Given the dialog context and external database, please generate a relevant system response for the user.", |
| | "This bot assists users to _____. Based on the dialogue context and information from the external database, please generate an appropriate response for the user.", |
| | "This bot helps users to _____. Provide a suitable response to the user, keeping in mind the conversation history and accessible external data.", |
| | "The purpose of this bot is to assist users to _____. Considering the dialogue context and the information available in the external knowledge, please provide a fitting response for the user.", |
| | "This bot is designed to help users _____. By utilizing the current dialog context and external resources, generate an appropriate response for the user." |
| | ] |
| |
|
| | mapping = { |
| | "ABCD":{ |
| | "product_defect": "solve issues about refunds and returns", |
| | "storewide_query": "find answers to FAQ questions about pricing, timing, membership or features", |
| | "shipping_issue": "check out update a shipment of an item", |
| | "subscription_inquiry": "updates premium subscription", |
| | "account_access": "manage account access information", |
| | "troubleshoot_site": "solve website-related issues", |
| | "single_item_query": "find answers to FAQ questions about clothes", |
| | "order_issue": "get status of an order or change an order", |
| | "purchase_dispute": "dispute a purchase", |
| | "manage_account": "manage account profile", |
| | }, |
| | "AirDialogue":{ |
| | "flight": "book a flight ticket", |
| | }, |
| | "BiTOD":{ |
| | "restaurants": "find and book a restaurant", |
| | "attractions": "find a tourist attraction", |
| | "HKMTR": "find a metro line", |
| | "weathers": "search weather information", |
| | "hotels": "find and book a hotel", |
| | }, |
| | "CaSiNo":{ |
| | "negotiate": "take the role of campsite neighbors and negotiate for food, water, and firewood" |
| | }, |
| | "CraigslistBargains":{ |
| | "bargain": "bargain for goods" |
| | }, |
| | "DSTC2-Clean":{ |
| | "restaurant": "find a restaurant" |
| | }, |
| | "FRAMES":{ |
| | "trip": "book a trip" |
| | }, |
| | "KVRET":{ |
| | "schedule":"manage a calendar", |
| | "weather":"find weather information", |
| | "navigate":"get navigation", |
| | }, |
| | "WOZ2_0":{ |
| | "restaurant":"find a restaurant", |
| | }, |
| | "SGD":{ |
| | "alarm": "manage alarms", |
| | "banks": "manage bank accounts", |
| | "buses": "book a bus journey", |
| | "events": "book an event ticket", |
| | "flights": "book a flight ticket", |
| | "homes": "find an apartment or schedule an apartment viewing", |
| | "hotels": "book a hotel", |
| | "media": "rent a movie to watch", |
| | "music": "find a song", |
| | "rentalcars": "rent a car", |
| | "restaurants": "book a restaurant", |
| | "ridesharing": "book a ride", |
| | "services": "reserve a therapist, dentists, doctor or hair stylist", |
| | "travel": "find a tourist attraction", |
| | "weather": "get weather information", |
| | "messaging": "connect and share locations", |
| | "movies": "book a movie ticket", |
| | "payment": "manage a payment", |
| | "trains": "book a train journey", |
| | "calendar": "manage a calendar", |
| | }, |
| | "MetaLWOZ":{ |
| | "update_calendar": "schedule meetings on a calendar", |
| | "order_pizza": "order a pizza", |
| | "movie_listings": "get movie information", |
| | "event_reserve": "make reservations for events", |
| | "weather_check": "get weather information", |
| | "update_contact": "update cell phone contacts", |
| | "make_restaurant_reservations": "reserve a restaurant", |
| | "edit_playlist": "manage music playlists", |
| | "look_up_info": "fetch information from the internet", |
| | "shopping": "order products from website", |
| | "store_details": "get information about stores and businesses", |
| | "sports_info": "get sports information", |
| | "quote_of_the_day_bot": "get a quote of the day", |
| | "how_to_basic": "get instructions for basic tasks", |
| | "prompt_generator": "get creative prompts", |
| | "library_request": "get library information", |
| | "bank_bot": "manage bank accounts", |
| | "restaurant_picker": "find a restaurant", |
| | "phone_plan_bot": "get mobile phone service", |
| | "name_suggester": "get names for things", |
| | "city_info": "get facts about different cities", |
| | "music_suggester": "get music suggestions", |
| | "agreement_bot": "get agreements", |
| | "pet_advice": "get pet advice", |
| | "apartment_finder": "find an apartment", |
| | "guiness_check": "get world records", |
| | "geography": "get to know where countries are", |
| | "alarm_set": "manage alarms", |
| | "contact_manager": "manage the user's contacts", |
| | "phone_settings": "manage the user's phone's settings", |
| | "appointment_reminder": "confirm their appointments", |
| | "home_bot": "manage the user's home", |
| | "policy_bot": "get information about a company's policies", |
| | "decider_bot": "make decisions for the user", |
| | "catalogue_bot": "search a catalogue", |
| | "ski_bot": "book skiing trips", |
| | "bus_schedule_bot": "manage public transit schedules", |
| | "insurance": "get insurance information", |
| | "what_is_it": "remember what a thing is.", |
| | "auto_sort": "sort things", |
| | "scam_lookup": "get about various scams", |
| | "time_zone": "get information about time zones", |
| | "play_times": "schedule shows during a theatre festival", |
| | "game_rules": "know the rules for games", |
| | "wedding_planner": "plan weddings", |
| | "check_status": "check the status of things", |
| | "present_ideas": "get advice on gift giving", |
| | "booking_flight": "book a flight ticket", |
| | "hotel_reserve": "book rooms in a hotel", |
| | "vacation_ideas": "plan for vacations and trips", |
| | "tourism": "get tourism related advices" |
| | }, |
| | "STAR":{ |
| | "apartment": "find an apartment or schedule an apartment viewing", |
| | "bank": "manage bank accounts", |
| | "doctor": "make an appointment with a doctor", |
| | "hotel": "book a hotel", |
| | "meeting": "schedule a meeting", |
| | "party": "plan a party", |
| | "plane": "book a flight ticket", |
| | "restaurant": "reserve a restaurant", |
| | "ride": "book a ride", |
| | "spaceship": "solve issues with a spaceship", |
| | "trip": "get navigation", |
| | "trivia": "plan a game of trivia", |
| | "weather": "get weather information", |
| | }, |
| | "Taskmaster1":{ |
| | "restaurant": "reserve a restaurant", |
| | "movie": "book a movie ticket", |
| | "pizza": "order a pizza", |
| | "coffee": "order coffee drinks", |
| | "auto": "make appointment for auto repair", |
| | "uber": "book a uber ride", |
| | }, |
| | "Taskmaster2":{ |
| | "flights": "book a flight ticket", |
| | "food-ordering": "make a take-out order", |
| | "hotels":"find a hotel", |
| | "movies":"find a movie to watch", |
| | "music": "find music tracks", |
| | "restaurant-search": "find a restaurant", |
| | "sports": "get sports information", |
| | }, |
| | "Taskmaster3":{ |
| | "movie": "book a movie ticket", |
| | }, |
| | "SimJointMovie":{ |
| | "movie": "book a movie ticket", |
| | }, |
| | "SimJointRestaurant":{ |
| | "restaurant": "reserve a restaurant", |
| | }, |
| | "SimJointGEN":{ |
| | "movie": "book a movie ticket", |
| | }, |
| | "MulDoGO":{ |
| | "airline": "book a flight ticket", |
| | "fastfood": "order fast food", |
| | "finance": "manage bank accounts", |
| | "insurance": "get insurance information", |
| | "media": "order a media service", |
| | "software": "get software service information", |
| | }, |
| | "MS-DC":{ |
| | "restaurant": "reserve a restaurant", |
| | "taxi": "book a taxi", |
| | "movie": "book a movie ticket", |
| | }, |
| | "SalesBot":{ |
| | "GetTimesForMovie": "get information for a movie", |
| | "LookupSong": "find a song", |
| | "FindMovies": "find a movie to watch", |
| | "LookupMusic": "find and play a song", |
| | "PlaySong": "play a song", |
| | "FindAttractions": "find a tourist attraction", |
| | }, |
| | "MuDoCo":{ |
| | "calling": "make a call", |
| | "messaging": "send or read messages", |
| | "music": "find a song", |
| | "news": "get news information", |
| | "reminders": "modify a reminder", |
| | "weather": "get weather information", |
| | }, |
| | "MULTIWOZ2_2":{ |
| | "restaurant": "find a restaurant", |
| | "hotel": "find a hotel", |
| | "attraction": "find an attraction", |
| | "train": "book a train ticket", |
| | "taxi": "find a taxi", |
| | "hospital": "find a hospital", |
| | "police": "find a police station", |
| | "bus": "find a bus", |
| | }, |
| | } |
| |
|
| | def generate_prompt(data_name, domains, num_sample=1): |
| | """ |
| | Including all 5 types of prompt and output a list |
| | """ |
| | |
| | descriptions = [mapping[data_name][domain] for domain in domains] |
| | if len(descriptions) == 1: |
| | description_str = descriptions[0] |
| | elif len(descriptions) == 2: |
| | description_str = " and ".join(descriptions) |
| | elif len(descriptions) == 0: |
| | description_str = "complete specified tasks" |
| | else: |
| | description_str = "complete multiple tasks, e.g. " + ", ".join(descriptions[:-1]) + ", and " + descriptions[-1] |
| | return [sampled_template.replace("_____", description_str) for sampled_template in templates] |