(ืืืฆื ืขื ืืชืืื ื ืืืขืื ืืฆืคืืื ืืกืจืืื ืฉื ืืฉืืขืืจ ืืื)
ืืจืืืื ืืืืื ืืฉืืขืืจ ืขื ืืื-ืงืืื ืืฆืื ืืกืืื ื AI! ืคืจืง ืื ืืืืขื ืืืชืืืืื ืืกืงืจื ืื ืืืฆื ืกืืื ื AI ืืืืืื ืืืฉืื ืขื ืชืืืืื ืืืฉืืื ืฉืืื ืขืฆืื. ืืกืืื ืืฉืืขืืจ, ืชืืื ื ืืืฉืืื ืืจืืืืื ืืชืืื ืืฆืืืืื ืืืืืืืืช ืืขืฉืืืช ืืืืฉืื ืืื-ืงืืื ืืฆืื ืืขืืฆืื ืกืืื ื AI.
ืืืืจ ืืฉืืืช ืืฉืืขืืจ, ืชืืืื:
- ืืืืื ืืช ืืืฉืืืืช ืฉื ืืืืืืช ืืฉืืื ืืืืืจืืช ืกืืื ืื.
- ืืืฉืชืืฉ ืืืื ืืงืืช ืชืื ืื ืืืขืจืื ืืื ืืขืืืจ ืืกืืื ืื ืืชืงื ืืช ืขืฆืื.
- ืืืฆืืจ ืกืืื ืื ืืฉืืื ืืืกืืืืื ืืฉื ืืช ืงืื ืืื ืืืฆืข ืืฉืืืืช.
ืืื-ืงืืื ืืฆืื ืืชืืืืกืช ืืชืืืืืื ืงืืื ืืืืืืื ืืจืื ืืืืื ืืืืืืื ืืฉืืื ืขื ืืืฉืืื ืฉื ืขืฆืื. ืขืืืจ ืกืืื ื AI, ืืืฉืืขืืช ืืื ืืืืืืช ืืืขืจืื ืืืืชืืื ืืช ืคืขืืืืชืืื ืืืชืืกืก ืขื ืืืืขืืช ืขืฆืืืช ืื ืืกืืื ืขืืจ. ืืื-ืงืืื ืืฆืื, ืื "ืืฉืืื ืขื ืืฉืืื", ืืื ืืืฉื ืืฉืื ืืคืืชืื ืืขืจืืืช AI ืกืืื ืืืช. ืืื ืืืืืช ืืขืจืืืช AI ืฉืืืืขืืช ืืชืืืืืื ืืคื ืืืืื ืฉืืื ืืืืืืืช ืื ืืจ, ืืืืกืช ืืืืชืืื ืืช ืืชื ืืืืชื ืืืชืื. ืืืืืง ืืื ืฉืื ืื ื ืขืืฉืื ืืฉืื ืื ื ืงืืจืืื ืืช ืืกืืืืืฆืื ืื ืืชืืืืืื ืขื ืืขืื. ืืืืขืืช ืขืฆืืืช ืื ืืืืื ืืขืืืจ ืืืขืจืืืช AI ืืงืื ืืืืืืช ืืืืืช ืืืชืจ, ืืืืืช ืืขืืืืช ืืืฉืคืจ ืืช ืืืฆืืขืืื ืืืืจื ืืื - ืฉืื, ืืืงืฉืจ ืืืืื ืืืืจืื ื ืืืืืื ืืื AI ืขืืื ืืืฉืชืื.
ืืืงืฉืจ ืฉื ืืขืจืืืช AI ืกืืื ืืืช, ืืื-ืงืืื ืืฆืื ืืืืื ืืขืืืจ ืืืชืืืื ืขื ืืกืคืจ ืืชืืจืื, ืืืื:
- ืฉืงืืคืืช: ืืืืืช ืืืืืช ืฉื ืืขืจืืืช AI ืืืกืืืจ ืืช ืืืืืืื ืืืืืืืืช ืฉืืื.
- ืืฉืืื: ืฉืืคืืจ ืืืืืืช ืฉื ืืขืจืืืช AI ืืกื ืชื ืืืืข ืืืงืื ืืืืืืช ืืืฉืืืืช.
- ืืกืชืืืืช: ืืชื ืืคืฉืจืืช ืืืขืจืืืช AI ืืืชืืื ืืช ืขืฆืื ืืกืืืืืช ืืืฉืืช ืืืชื ืืื ืืฉืชื ืื.
- ืชืคืืกื: ืฉืืคืืจ ืืืืืง ืฉื ืืขืจืืืช AI ืืืืืื ืืคืจืฉื ืืช ื ืชืื ืื ืืืกืืืื ืฉืืื.
ืืื-ืงืืื ืืฆืื, ืื "ืืฉืืื ืขื ืืฉืืื", ืืื ืชืืืื ืงืืื ืืืืื ืืจืื ืืืืื ืืืืื ืืืืขืืช ืขืฆืืืช ืืจืืืืฆืื ืขืฆืืืช ืฉื ืชืืืืืื ืงืืื ืืืืืืื. ืืชืืื ื-AI, ืืื-ืงืืื ืืฆืื ืืืคืฉืจืช ืืกืืื ืื ืืืขืจืื ืืืืชืืื ืืช ืืืกืืจืืืืืช ืืืคืขืืืืช ืฉืืื, ืื ืฉืืืืื ืืฉืืคืืจ ืืืืืืช ืคืชืจืื ืืขืืืช ืืงืืืช ืืืืืืช. ืขื ืืื ืืื ืช ืืื-ืงืืื ืืฆืื, ืชืืืื ืืขืฆื ืกืืื ื AI ืฉืื ืื ืจืง ืืืืื ืืืชืจ ืืื ืื ืืกืชืืืื ืืืขืืืื ืืืชืจ. ืืืื-ืงืืื ืืฆืื ืืืืชืืช, ืชืจืื ืืช ื-AI ืืืฆืข ืืฉืืื ืืคืืจืฉืช ืขื ืืืฉืืื ืฉืื ืขืฆืื.
ืืืืื: "ื ืชืชื ืขืืืคืืช ืืืืกืืช ืืืืืช ืืืชืจ ืื... ืืืื ืื ื ืืคืกืคืก ืืืกืืช ืืฉืืจืืช, ืื ืืืื ืฉืืืืืง ืฉืื." ืืขืงื ืืืจ ืืื ืื ืืื ืืื ืืืจ ืืกืืื ืืกืืื.
- ืฆืืื ืฉืืื ืขืฉื ืืขืืืืช ืื ืืกืชืื ืืชืจ ืขื ืืืืื ืขื ืืขืืคืืช ืืฉืชืืฉ ืืืคืขื ืืงืืืืช, ืืืื ืืื ืืฉื ื ืืช ืืกืืจืืืืืช ืงืืืช ืืืืืืืช ืฉืื ืืื ืจืง ืืช ืืืืืฆื ืืกืืคืืช.
- ืืืืื ืืคืืกืื ืืื, "ืืื ืคืขื ืฉืื ื ืจืืื ืฉืืืฉืชืืฉ ืืืืืจ 'ืืืชืจ ืืื ืฆืคืืฃ', ืื ื ืฆืจืื ืื ืจืง ืืืกืืจ ืืืจืงืฆืืืช ืืกืืืืืช ืืื ืื ืืฉืงืฃ ืฉืืฉืืื ืฉืื ืืืืืจืช 'ืืืจืงืฆืืืช ืืืืืืืช' ืคืืืื ืื ืื ื ืชืืื ืืืจื ืืคื ืคืืคืืืจืืืช."
ืืื-ืงืืื ืืฆืื ืืฉืืงืช ืชืคืงืื ืงืจืืื ืืขืืฆืื ืกืืื ื AI ืืืกืคืจ ืกืืืืช:
- ืจืคืืงืฆืื ืขืฆืืืช: ืกืืื ืื ืืืืืื ืืืขืจืื ืืช ืืืืฆืืขืื ืฉืืื ืืืืืืช ืชืืืืื ืืฉืืคืืจ.
- ืืกืชืืืืช: ืกืืื ืื ืืืืืื ืืฉื ืืช ืืช ืืืกืืจืืืืืช ืฉืืื ืืืชืืกืก ืขื ื ืืกืืื ืขืืจ ืืกืืืืืช ืืฉืชื ืืช.
- ืชืืงืื ืืขืืืืช: ืกืืื ืื ืืืืืื ืืืืืช ืืืชืงื ืืขืืืืช ืืืืคื ืขืฆืืื, ืื ืฉืืืืื ืืชืืฆืืืช ืืืืืงืืช ืืืชืจ.
- ื ืืืื ืืฉืืืื: ืกืืื ืื ืืืืืื ืืืืขื ืืช ืืฉืืืืฉ ืืืฉืืืื, ืืื ืืื ืืืื ืืืฉืื, ืขื ืืื ืชืื ืื ืืืขืจืืช ืคืขืืืืชืืื.
ืืคื ื ืฉื ืฆืืื ืืชืืืืื ืืื-ืงืืื ืืฆืื, ืืฉืื ืืืืื ืืช ืืจืืืืื ืืืกืืกืืื ืฉื ืกืืื AI. ืกืืื AI ืืืจืื ืืืจื ืืื ื:
- ืคืจืกืื ื: ืืืืฉืืืช ืืืืืคืืื ืื ืฉื ืืกืืื, ืฉืืืืืจืื ืืืฆื ืืื ืืชืงืฉืจ ืขื ืืฉืชืืฉืื.
- ืืืื: ืืืืืืืช ืืืคืื ืงืฆืืืช ืฉืืกืืื ืืืื ืืืฆืข.
- ืืืืื ืืืืช: ืืืืข ืืืืืืืืืช ืฉืืกืืื ืืืืืง.
ืจืืืืื ืืื ืขืืืืื ืืื ืืื ืืืฆืืจ "ืืืืืช ืืืืืืืช" ืฉืืืืื ืืืฆืข ืืฉืืืืช ืกืคืฆืืคืืืช.
ืืืืื: ืืฉืื ืขื ืกืืื ื ืกืืขืืช, ืฉืืจืืช ืกืืื ืื ืฉืื ืจืง ืืชืื ื ืืช ืืืืคืฉื ืฉืืื ืืื ืื ืืชืืื ืืช ืืืกืืื ืฉืื ืืืชืืกืก ืขื ื ืชืื ืื ืืืื ืืืช ืื ืืกืืื ืืกืข ืืงืืืืช ืงืืื.
ืืืืื ื ืฉืืชื ืืขืฆืืื ืฉืืจืืช ืกืืื ื ืกืืขืืช ืืืืคืขื ืขื ืืื AI. ืกืืื ืื, "Travel Agent", ืืกืืืข ืืืฉืชืืฉืื ืืชืื ืื ืืืืคืฉืืช ืฉืืื. ืืื ืืฉืื ืืื-ืงืืื ืืฆืื, Travel Agent ืฆืจืื ืืืขืจืื ืืืืชืืื ืืช ืคืขืืืืชืื ืืืชืืกืก ืขื ืืืืขืืช ืขืฆืืืช ืื ืืกืืื ืขืืจ. ืื ื ืืื ืืื-ืงืืื ืืฆืื ืืืืื ืืฉืืง ืชืคืงืื:
ืืืฉืืื ืื ืืืืืช ืืื ืืขืืืจ ืืืฉืชืืฉ ืืชืื ื ืืืื ืืคืจืื.
- ืืืกืืฃ ืืขืืคืืช ืืฉืชืืฉ: ืฉืืื ืืช ืืืฉืชืืฉ ืขื ืชืืจืืื ืื ืกืืขื, ืืชืงืฆืื, ืชืืืื ืืขื ืืื (ืืืฉื, ืืืืืืื ืื, ืืืื, ืงื ืืืช) ืืื ืืจืืฉื ืกืคืฆืืคืืช.
- ืืืืืจ ืืืืข: ืืคืฉื ืืคืฉืจืืืืช ืืืกื, ืืงืืืืช ืืื ื, ืืืจืงืฆืืืช ืืืกืขืืืช ืฉืืชืืืืืช ืืืขืืคืืช ืืืฉืชืืฉ.
- ืืฆืืจืช ืืืืฆืืช: ืกืคืงื ืืกืืื ืืืฉื ืขื ืคืจืื ืืืกื, ืืืื ืืช ืืืื ืืคืขืืืืืืช ืืืฆืขืืช.
- ืืชืืื ืขื ืืกืืก ืืฉืื: ืืงืฉื ืืืืฉืชืืฉ ืืฉืื ืขื ืืืืืฆืืช ืืืฆืขื ืืชืืืืช ื ืืืฆืืช.
- ืืืฉื ืืืกืื ื ืชืื ืื ืฉื ืืืื ืช ืืืกืืช ืืืืื ืืช.
- ืืืืข ืขื ืืืจืงืฆืืืช ืืืกืขืืืช ืืคืจืื.
- ื ืชืื ื ืืฉืื ืืฉืชืืฉืื ืืืื ืืจืืงืฆืืืช ืงืืืืืช.
Travel Agent ืืฉืชืืฉ ืืืื-ืงืืื ืืฆืื ืืื ืืืขืจืื ืืช ืืืฆืืขืื ืืืืืื ืื ืืกืืื ืขืืจ. ืืืืืื:
- ื ืืชืื ืืฉืื ืืฉืชืืฉืื: Travel Agent ืกืืงืจ ืืฉืื ืืฉืชืืฉืื ืืื ืืงืืืข ืืืื ืืืืฆืืช ืืชืงืืื ืืืื ืืืืื ืื. ืืื ืืชืืื ืืช ืืืฆืขืืช ืืขืชืืืืืช ืฉืื ืืืชืื.
- ืืกืชืืืืช: ืื ืืฉืชืืฉ ืฆืืื ืืขืืจ ืืืกืจ ืืืื ืืืงืืืืช ืฆืคืืคืื, Travel Agent ืืื ืข ืืืืืืืฅ ืขื ืืชืจื ืชืืืจืืช ืคืืคืืืจืืื ืืฉืขืืช ืฉืื ืืขืชืื.
- ืชืืงืื ืืขืืืืช: ืื Travel Agent ืขืฉื ืืขืืช ืืืืื ื ืงืืืืช, ืืื ืืืืฆื ืขื ืืืื ืฉืืื ืืชืคืืกื ืืืื, ืืื ืืืื ืืืืืง ืืืื ืืช ืืฆืืจื ืืกืืืืช ืืืชืจ ืืคื ื ืืชื ืืืืฆืืช.
ืื ื ืืืืื ืคืฉืืื ืืงืื ืฉื Travel Agent ืฉืืฉืื ืืื-ืงืืื ืืฆืื:
class Travel_Agent:
def __init__(self):
self.user_preferences = {}
self.experience_data = []
def gather_preferences(self, preferences):
self.user_preferences = preferences
def retrieve_information(self):
# Search for flights, hotels, and attractions based on preferences
flights = search_flights(self.user_preferences)
hotels = search_hotels(self.user_preferences)
attractions = search_attractions(self.user_preferences)
return flights, hotels, attractions
def generate_recommendations(self):
flights, hotels, attractions = self.retrieve_information()
itinerary = create_itinerary(flights, hotels, attractions)
return itinerary
def adjust_based_on_feedback(self, feedback):
self.experience_data.append(feedback)
# Analyze feedback and adjust future recommendations
self.user_preferences = adjust_preferences(self.user_preferences, feedback)
# Example usage
travel_agent = Travel_Agent()
preferences = {
"destination": "Paris",
"dates": "2025-04-01 to 2025-04-10",
"budget": "moderate",
"interests": ["museums", "cuisine"]
}
travel_agent.gather_preferences(preferences)
itinerary = travel_agent.generate_recommendations()
print("Suggested Itinerary:", itinerary)
feedback = {"liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"]}
travel_agent.adjust_based_on_feedback(feedback)- ืจืคืืงืฆืื ืขืฆืืืช: ืกืืื ืื ืืืืืื ืื ืชื ืืช ืืืืฆืืขืื ืฉืืื ืืืืืืช ืชืืืืื ืืฉืืคืืจ.
- ืืกืชืืืืช: ืกืืื ืื ืืืืืื ืืฉื ืืช ืืกืืจืืืืืช ืืืชืืกืก ืขื ืืฉืื ืืชื ืืื ืืฉืชื ืื.
- ืชืืงืื ืืขืืืืช: ืกืืื ืื ืืืืืื ืืืืืช ืืืชืงื ืืขืืืืช ืืืืคื ืขืฆืืื.
- ื ืืืื ืืฉืืืื: ืกืืื ืื ืืืืืื ืืืืขื ืืช ืืฉืืืืฉ ืืืฉืืืื, ืืื ืืื ืืืื ืืืฉืื.
ืขื ืืื ืฉืืืื ืืื-ืงืืื ืืฆืื, Travel Agent ืืืื ืืกืคืง ืืืืฆืืช ื ืกืืขื ืืืฉืืืช ืืืืืืงืืช ืืืชืจ, ืื ืฉืืฉืคืจ ืืช ืืืืืืช ืืืฉืชืืฉ ืืืืืืช.
ืชืื ืื ืืื ืืจืืื ืงืจืืื ืืืชื ืืืืช ืกืืื ื AI. ืืื ืืืื ืชืื ืื ืืฉืืืื ืืืจืืฉืื ืืืฉืืช ืืืจื, ืชืื ืืชืืฉืืืช ืืืฆื ืื ืืืื, ืืฉืืืื ืืืืฉืืืื ืืคืฉืจืืื.
- ืืฉืืื ื ืืืืืช: ืืืืจืช ืืืฉืืื ืืฆืืจื ืืจืืจื.
- ืฉืืืื ืืืฉืืืช ืืืฉืืื: ืคืืจืืง ืืืฉืืื ืืฉืืืื ื ืืชื ืื ืื ืืืื.
- ืืฉืืืื ื ืืจืฉืื: ืืืืื ืืืฉืืืื ืื ืืืฆืื.
- ื ืืกืืื: ืฉืืืืฉ ืื ืืกืืื ืขืืจ ืืื ืืืืืข ืืช ืืชืื ืื.
ืืืืื: ืื ื ืืฉืืืื ืฉ-Travel Agent ืฆืจืื ืืืฆืข ืืื ืืขืืืจ ืืืฉืชืืฉ ืืชืื ื ืืช ืืืืื ืฉืื ืืฆืืจื ืืขืืื:
-
ืืืกืืฃ ืืขืืคืืช ืืฉืชืืฉ
- ืฉืืื ืืช ืืืฉืชืืฉ ืขื ืคืจืืื ืืืื ืชืืจืืื ืื ืกืืขื, ืืชืงืฆืื, ืชืืืื ืืขื ืืื ืืื ืืจืืฉื ืกืคืฆืืคืืช.
- ืืืืืืืช: "ืืชื ืืชื ืืชืื ื ืื ืื ืกืืข?" "ืื ืืืื ืืชืงืฆืื ืฉืืื?" "ืืืื ืคืขืืืืืืช ืืชื ื ืื ืื ืืขืฉืืช ืืืืคืฉื?"
-
ืืืืืจ ืืืืข
- ืืคืฉื ืืคืฉืจืืืืช ื ืกืืขื ืจืืืื ืืืืช ืืืชืืกืก ืขื ืืขืืคืืช ืืืฉืชืืฉ.
- ืืืกืืช: ืืคืฉื ืืืกืืช ืืืื ืืช ืืืกืืจืช ืืชืงืฆืื ืืชืืจืืื ืื ืกืืขื ืืืืขืืคืื ืฉื ืืืฉืชืืฉ.
- ืืงืืืืช ืืื ื: ืืฆืื ืืืื ืืช ืื ื ืืกืื ืืืฉืืจื ืฉืืชืืืืื ืืืขืืคืืช ืืืฉืชืืฉ ืืืืื ืช ืืืงืื, ืืืืจ ืืฉืืจืืชืื.
- ืืืจืงืฆืืืช ืืืกืขืืืช: ืืืืื ืืืจืงืฆืืืช, ืคืขืืืืืืช ืืืคืฉืจืืืืช ืืืื ืคืืคืืืจืืืช ืฉืืชืืืืืช ืืชืืืื ืืขื ืืื ืฉื ืืืฉืชืืฉ.
-
ืืฆืืจืช ืืืืฆืืช
- ืจืืื ืืช ืืืืืข ืฉื ืืกืฃ ืืืกืืื ืืืฉื.
- ืกืคืงื ืคืจืืื ืืื ืืคืฉืจืืืืช ืืืกื, ืืืื ืืช ืืืื ืืคืขืืืืืืช ืืืฆืขืืช, ืชืื ืืชืืืช ืืืืืฆืืช ืืืขืืคืืช ืืืฉืชืืฉ.
-
ืืฆืืช ืืืกืืื ืืืฉืชืืฉ
- ืฉืชืคื ืืช ืืืกืืื ืืืืฆืข ืขื ืืืฉืชืืฉ ืืฆืืจื ืกืงืืจื.
- ืืืืื: "ืื ื ืืกืืื ืืืฆืข ืืืืื ืฉืืื ืืคืจืื. ืืื ืืืื ืคืจืื ืืืกื, ืืืื ืืช ืืืื ืืจืฉืืืช ืคืขืืืืืืช ืืืกืขืืืช ืืืืืฆืืช. ืกืคืจื ืื ืื ืืขืชืื!"
-
ืืืกืืฃ ืืฉืื
- ืืงืฉื ืืืืฉืชืืฉ ืืฉืื ืขื ืืืกืืื ืืืืฆืข.
- ืืืืืืืช: "ืืื ืืชื ืืืืืื ืืช ืืคืฉืจืืืืช ืืืืกื?" "ืืื ืืืืื ืืชืืื ืืฆืจืืื ืฉืืื?" "ืืื ืืฉ ืคืขืืืืืืช ืฉืชืจืฆื ืืืืกืืฃ ืื ืืืกืืจ?"
-
ืืชืืื ืขื ืืกืืก ืืฉืื
- ืืชืืืื ืืช ืืืกืืื ืืืชืืกืก ืขื ืืฉืื ืืืฉืชืืฉ.
- ืืฆืขื ืฉืื ืืืื ื ืืืฆืื ืืืืืฆืืช ืืืืกื, ืืืื ื ืืืคืขืืืืืืช ืืื ืืืชืืื ืืื ืืืชืจ ืืืขืืคืืช ืืืฉืชืืฉ.
-
ืืืฉืืจ ืกืืคื
- ืืฆืืื ืืช ืืืกืืื ืืืขืืืื ืืืฉืชืืฉ ืืืืฉืืจ ืกืืคื.
- ืืืืื: "ืืืฆืขืชื ืืช ืืืชืืืืช ืืืชืืกืก ืขื ืืืฉืื ืฉืืื. ืื ื ืืืกืืื ืืืขืืืื. ืืื ืืื ื ืจืื ืืื ืืื?"
-
ืืืื ื ืืืืฉืืจ
- ืืืืจ ืฉืืืฉืชืืฉ ืืืฉืจ ืืช ืืืกืืื, ืืืฉืืื ืืืืื ืช ืืืกืืช, ืืงืืืืช ืืื ื ืืื ืคืขืืืืืืช ืืชืืื ื ืืช ืืจืืฉ.
- ืฉืืื ืคืจืื ืืืฉืืจ ืืืฉืชืืฉ.
-
ืืชื ืชืืืื ืืชืืฉืืช
- ืืืฉืืจื ืืืื ืื ืืกืืืข ืืืฉืชืืฉ ืขื ืื ืฉืื ืื ืื ืืงืฉื ื ืืกืคืช ืืคื ื ืืืืืื ืืืืื.
- ืืืืื: "ืื ืชืฆืืจืื ืขืืจื ื ืืกืคืช ืืืืื ืืืืื ืฉืืื, ืื ืชืืกืกื ืืคื ืืช ืืืื ืืื ืขืช!"
class Travel_Agent:
def __init__(self):
self.user_preferences = {}
self.experience_data = []
def gather_preferences(self, preferences):
self.user_preferences = preferences
def retrieve_information(self):
flights = search_flights(self.user_preferences)
hotels = search_hotels(self.user_preferences)
attractions = search_attractions(self.user_preferences)
return flights, hotels, attractions
def generate_recommendations(self):
flights, hotels, attractions = self.retrieve_information()
itinerary = create_itinerary(flights, hotels, attractions)
return itinerary
def adjust_based_on_feedback(self, feedback):
self.experience_data.append(feedback)
self.user_preferences = adjust_preferences(self.user_preferences, feedback)
# Example usage within a booing request
travel_agent = Travel_Agent()
preferences = {
"destination": "Paris",
"dates": "2025-04-01 to 2025-04-10",
"budget": "moderate",
"interests": ["museums", "cuisine"]
}
travel_agent.gather_preferences(preferences)
itinerary = travel_agent.generate_recommendations()
print("Suggested Itinerary:", itinerary)
feedback = {"liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"]}
travel_agent.adjust_based_on_feedback(feedback)ืจืืฉืืช, ืืืื ื ืชืืื ืืืื ืช ืืืืื ืืื ืืื RAG ืืืขืื ืช ืืงืฉืจ ืืงืืืื.
RAG ืืฉืื ืืขืจืืช ืืืืืจ ืขื ืืืื ืืฆืืจื. ืืืฉืจ ืืชืืฆืข ืฉืืืืชื, ืืขืจืืช ืืืืืืจ ืฉืืืคืช ืืกืืืื ืื ื ืชืื ืื ืจืืืื ืืืื ืืืงืืจ ืืืฆืื ื, ืืืืืข ืื ืืฉืืฉ ืืืจืืืช ืืงืื ืืืืื ืืืฆืืจื. ืื ืขืืืจ ืืืืื ืืืฆืืจ ืชืืืืืช ืืืืืงืืช ืืจืืืื ืืืืช ืืืืื ื ืืงืฉืจืืช.
ืืืขืจืืช RAG, ืืกืืื ืฉืืืฃ ืืืืข ืจืืืื ืื ืืืืืจ ืืืข ืืืฉืชืืฉ ืื ืืื ืืืฆืืจ ืชืืืืืช ืื ืคืขืืืืช ืืชืืืืืช.
ืืืฉืช ืชืืงืื RAG ืืชืืงืืช ืืฉืืืืฉ ืืืื ืืงืืช RAG ืืชืืงืื ืืขืืืืช ืืฉืืคืืจ ืืืืง ืกืืื ื AI. ืื ืืืื:
- ืืื ืืงืช ืื ืืื: ืฉืืืืฉ ืืื ืืืืช ืกืคืฆืืคืืืช ืืื ืืื ืืืช ืืช ืืกืืื ืืืืืืจ ืืืืข ืจืืืื ืื.
- ืืื: ืืืฉืื ืืืืืจืืชืืื ืืื ืื ืื ืื ืฉืืืคืฉืจืื ืืกืืื ืืืขืจืื ืืช ืืจืืืื ืืืืช ืฉื ืืืืืข ืฉื ืฉืืฃ ืืืืฆืืจ ืชืืืืืช ืืืืืงืืช.
- ืืขืจืื: ืืขืจืื ืืชืืฉืืช ืฉื ืืืฆืืขื ืืกืืื ืืืืฆืืข ืืชืืืืช ืืฉืืคืืจ ืืืืงื ืืืขืืืืชื.
ืืฉืื ืขื ืกืืื ืืืคืืฉ ืฉืฉืืืฃ ืืืืข ืืืืื ืืจื ื ืืื ืืขื ืืช ืขื ืฉืืืืชืืช ืืฉืชืืฉืื. ืืืฉืช ืชืืงืื RAG ืขืฉืืื ืืืืื:
- ืืื ืืงืช ืื ืืื: ื ืืกืื ืฉืืืืชืืช ืืืคืืฉ ืืืชืืกืก ืขื ืงืื ืืืฉืชืืฉ.
- ืืื: ืฉืืืืฉ ืืขืืืื ืฉืคื ืืืขืืช ืืืืืืจืืชืืื ืฉื ืืืืืช ืืืื ื ืืื ืืืจื ืืืกื ื ืชืืฆืืืช ืืืคืืฉ.
- ืืขืจืื: ื ืืชืื ืืฉืื ืืฉืชืืฉืื ืืื ืืืืืช ืืืชืงื ืื ืืืืงืื ืืืืืข ืฉื ืฉืืฃ.
ืชืืงืื RAG (ืืฆืืจื ืืืืืจืช ืืืืืจ) ืืฉืคืจ ืืช ืืืืืช ื-AI ืืืืืจ ืืืืฆืืจ ืืืืข ืชืื ืชืืงืื ืื ืืืืงืื. ืืืื ื ืจืื ืืื Travel Agent ืืืื ืืืฉืชืืฉ ืืืืฉืช ืชืืงืื RAG ืืื ืืกืคืง ืืืืฆืืช ื ืกืืขื ืืืืืงืืช ืืจืืืื ืืืืช ืืืชืจ.
ืื ืืืื:
- ืืื ืืงืช ืื ืืื: ืฉืืืืฉ ืืื ืืืืช ืกืคืฆืืคืืืช ืืื ืืื ืืืช ืืช ืืกืืื ืืืืืืจ ืืืืข ืจืืืื ืื.
- ืืื: ืืืฉืื ืืืืืจืืชืืื ืืื ืื ืื ืื ืฉืืืคืฉืจืื ืืกืืื ืืืขืจืื ืืช ืืจืืืื ืืืืช ืฉื ืืืืืข ืฉื ืฉืืฃ ืืืืฆืืจ ืชืืืืืช ืืืืืงืืช.
- ืืขืจืื: ืืขืจืื ืืชืืฉืืช ืฉื ืืืฆืืขื ืืกืืื ืืืืฆืืข ืืชืืืืช ืืฉืืคืืจ ืืืืงื ืืืขืืืืชื.
-
ืืื ืืจืืงืฆืื ืจืืฉืื ืืช ืขื ืืืฉืชืืฉ
-
Travel Agent ืืืกืฃ ืืขืืคืืช ืจืืฉืื ืืืช ืืืืฉืชืืฉ, ืืื ืืขื, ืชืืจืืื ื ืกืืขื, ืชืงืฆืื ืืชืืืื ืขื ืืื.
-
ืืืืื:
preferences = { "destination": "Paris", "dates": "2025-04-01 to 2025-04-10", "budget": "moderate", "interests": ["museums", "cuisine"] }
-
-
ืืืืืจ ืืืืข
-
Travel Agent ืฉืืืฃ ืืืืข ืขื ืืืกืืช, ืืงืืืืช ืืื ื, ืืืจืงืฆืืืช ืืืกืขืืืช ืืืชืืกืก ืขื ืืขืืคืืช ืืืฉืชืืฉ.
-
ืืืืื:
flights = search_flights(preferences) hotels = search_hotels(preferences) attractions = search_attractions(preferences)
-
-
ืืฆืืจืช ืืืืฆืืช ืจืืฉืื ืืืช
-
Travel Agent ืืฉืชืืฉ ืืืืืข ืฉื ืฉืืฃ ืืื ืืืฆืืจ ืืกืืื ืืืฉื.
-
ืืืืื:
itinerary = create_itinerary(flights, hotels, attractions) print("Suggested Itinerary:", itinerary)
-
-
ืืืกืืฃ ืืฉืื ืืฉืชืืฉืื
-
Travel Agent ืืืงืฉ ืืืืฉืชืืฉ ืืฉืื ืขื ืืืืืฆืืช ืืจืืฉืื ืืืช.
-
ืืืืื:
feedback = { "liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"] }
-
-
ืชืืืื ืชืืงืื RAG
-
ืืื ืืงืช ืื ืืื: Travel Agent ืื ืกื ืฉืืืืชืืช ืืืคืืฉ ืืืฉืืช ืืืชืืกืก ืขื ืืฉืื ืืืฉืชืืฉ.
-
ืืืืื:
if "disliked" in feedback: preferences["avoid"] = feedback["disliked"]
-
-
ืืื: Travel Agent ืืฉืชืืฉ ืืืืืืจืืชืืื ืืืจื ืืืกื ื ืชืืฆืืืช ืืืคืืฉ ืืืฉืืช, ืชืื ืืืืฉืช ืืจืืืื ืืืืช ืืืชืืกืก ืขื ืืฉืื ืืืฉืชืืฉ.
-
ืืืืื:
new_attractions = search_attractions(preferences) new_itinerary = create_itinerary(flights, hotels, new_attractions) print("Updated Itinerary:", new_itinerary)
-
-
ืืขืจืื: Travel Agent ืืขืจืื ืืืืคื ืืชืืฉื ืืช ืืจืืืื ืืืืช ืืืืืืง ืฉื ืืืืฆืืชืื ืขื ืืื ื ืืชืื ืืฉืื ืืฉืชืืฉืื ืืืืฆืืข ืืชืืืืช ื ืืืฆืืช.
-
ืืืืื:
def adjust_preferences(preferences, feedback): if "liked" in feedback: preferences["favorites"] = feedback["liked"] if "disliked" in feedback: preferences["avoid"] = feedback["disliked"] return preferences preferences = adjust_preferences(preferences, feedback)
-
-
class Travel_Agent:
def __init__(self):
self.user_preferences = {}
self.experience_data = []
def gather_preferences(self, preferences):
self.user_preferences = preferences
def retrieve_information(self):
flights = search_flights(self.user_preferences)
hotels = search_hotels(self.user_preferences)
attractions = search_attractions(self.user_preferences)
return flights, hotels, attractions
def generate_recommendations(self):
flights, hotels, attractions = self.retrieve_information()
itinerary = create_itinerary(flights, hotels, attractions)
return itinerary
def adjust_based_on_feedback(self, feedback):
self.experience_data.append(feedback)
self.user_preferences = adjust_preferences(self.user_preferences, feedback)
new_itinerary = self.generate_recommendations()
return new_itinerary
# Example usage
travel_agent = Travel_Agent()
preferences = {
"destination": "Paris",
"dates": "2025-04-01 to 2025-04-10",
"budget": "moderate",
"interests": ["museums", "cuisine"]
}
travel_agent.gather_preferences(preferences)
itinerary = travel_agent.generate_recommendations()
print("Suggested Itinerary:", itinerary)
feedback = {"liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"]}
new_itinerary = travel_agent.adjust_based_on_feedback(feedback)
print("Updated Itinerary:", new_itinerary)ืืขืื ืช ืืงืฉืจ ืืจืืฉ ืืืืืช ืืขืื ืช ืืืืข ืจืืืื ืื ืื ืจืงืข ืืชืื ืืืืื ืืคื ื ืขืืืื ืืฉืืืืชื. ืืืฉืืขืืช ืืื ืฉืืืืื ืืฉ ืืืฉื ืืืืืข ืื ืืืืชืืื, ืื ืฉืขืืืจ ืื ืืืืฆืจ ืชืืืืืช ืืืฉืืืืช ืืืชืจ ืืืื ืืืืืงืง ืืฉืืืคืช ื ืชืื ืื ื ืืกืคืื ืืืืื ืืชืืืื.
ืื ื ืืืืื ืคืฉืืื ืืืืคื ืฉืื ืืขืื ืช ืืงืฉืจ ืืจืืฉ ืขืฉืืื ืืืืจืืืช ืืืคืืืงืฆืืืช ืกืืื ื ืกืืขืืช ื-Python:
class TravelAgent:
def __init__(self):
# Pre-load popular destinations and their information
self.context = {
"Paris": {"country": "France", "currency": "Euro", "language": "French", "attractions": ["Eiffel Tower", "Louvre Museum"]},
"Tokyo": {"country": "Japan", "currency": "Yen", "language": "Japanese", "attractions": ["Tokyo Tower", "Shibuya Crossing"]},
"New York": {"country": "USA", "currency": "Dollar", "language": "English", "attractions": ["Statue of Liberty", "Times Square"]},
"Sydney": {"country": "Australia", "currency": "Dollar", "language": "English", "attractions": ["Sydney Opera House", "Bondi Beach"]}
}
def get_destination_info(self, destination):
# Fetch destination information from pre-loaded context
info = self.context.get(destination)
if info:
return f"{destination}:\nCountry: {info['country']}\nCurrency: {info['currency']}\nLanguage: {info['language']}\nAttractions: {', '.join(info['attractions'])}"
else:
return f"Sorry, we don't have information on {destination}."
# Example usage
travel_agent = TravelAgent()
print(travel_agent.get_destination_info("Paris"))
print(travel_agent.get_destination_info("Tokyo"))-
ืืชืืื (ืฉืืืช
__init__): ืืืืงืชTravelAgentืืืขื ืช ืืจืืฉ ืืืืื ืืืืื ืืืืข ืขื ืืขืืื ืคืืคืืืจืืื ืืื ืคืจืื, ืืืงืื, ื ืื ืืืจืง ืืกืืื ื. ืืืืืื ืืืื ืคืจืืื ืืื ืืืื ื, ืืืืข, ืฉืคื ืืืืจืงืฆืืืช ืืจืืืืืช ืืื ืืขื. -
ืฉืืืคืช ืืืืข (ืฉืืืช
get_destination_info): ืืืฉืจ ืืฉืชืืฉ ืฉืืื ืขื ืืขื ืืกืืื, ืืฉืืืget_destination_infoืฉืืืคืช ืืช ืืืืืข ืืจืืืื ืื ืืืืืืื ืืืขืื ืืจืืฉ.
ืขื ืืื ืืขืื ืช ืืืงืฉืจ ืืจืืฉ, ืืคืืืงืฆืืืช ืกืืื ืื ืกืืขืืช ืืืืื ืืืืื ืืืืืจืืช ืืฉืืืืชืืช ืืฉืชืืฉืื ืืืื ืืืืืงืง ืืฉืืืคืช ืืืืข ืืืงืืจ ืืืฆืื ื ืืืื ืืืช. ืื ืืืคื ืืช ืืืคืืืงืฆืื ืืืขืืื ืืืืืจื ืืืชืจ.
ืื ืืืช ืชืืื ืืช ืขื ืืืจื ืืืืืช ืืชืืื ืขื ืืขื ืืจืืจ ืื ืชืืฆืื ืจืฆืืื ืืจืืฉ. ืขื ืืื ืืืืจืช ืืืืจื ืืจืืฉ, ืืืืื ืืืื ืืืฉืชืืฉ ืื ืืขืงืจืื ืื ืื ืืืืจื ืื ืชืืืื ืืืืืจืฆืื. ืื ืขืืืจ ืืืืืื ืฉืื ืืืืจืฆืื ืืชืงืืืช ืืขืืจ ืืฉืืช ืืชืืฆืื ืืจืฆืืื, ืื ืฉืืืคื ืืช ืืชืืืื ืืืขืื ืืืืืงื ืืืชืจ.
ืื ื ืืืืื ืืืืคื ืฉืื ื ืืชื ืืื ืืช ืชืืื ืืช ื ืกืืขื ืขื ืืืจื ืืคื ื ืืืืจืฆืื ืขืืืจ ืกืืื ื ืกืืขืืช ื-Python:
ืกืืื ื ืกืืขืืช ืจืืฆื ืืชืื ื ืืืคืฉื ืืืชืืืช ืืืฉืืช ืขืืืจ ืืงืื. ืืืืจื ืืื ืืืฆืืจ ืืกืืื ื ืกืืขื ืฉืืืงืกื ืืช ืฉืืืขืืช ืจืฆืื ืืืงืื ืืืชืืกืก ืขื ืืขืืคืืชืื ืืืชืงืฆืื ืฉืื.
- ืืืืืืจ ืืช ืืขืืคืืช ืืืงืื ืืืชืงืฆืื.
- ืืื ืืช ืชืืื ืืช ืจืืฉืื ืืช ืืืชืืกืก ืขื ืืขืืคืืช ืืื.
- ืืืฆืข ืืืืจืฆืืืช ืืฉืืคืืจ ืืชืืื ืืช, ืชืื ืืืคืืืืืืฆืื ืืฉืืืขืืช ืจืฆืื ืืืงืื.
class TravelAgent:
def __init__(self, destinations):
self.destinations = destinations
def bootstrap_plan(self, preferences, budget):
plan = []
total_cost = 0
for destination in self.destinations:
if total_cost + destination['cost'] <= budget and self.match_preferences(destination, preferences):
plan.append(destination)
total_cost += destination['cost']
return plan
def match_preferences(self, destination, preferences):
for key, value in preferences.items():
if destination.get(key) != value:
return False
return True
def iterate_plan(self, plan, preferences, budget):
for i in range(len(plan)):
for destination in self.destinations:
if destination not in plan and self.match_preferences(destination, preferences) and self.calculate_cost(plan, destination) <= budget:
plan[i] = destination
break
return plan
def calculate_cost(self, plan, new_destination):
return sum(destination['cost'] for destination in plan) + new_destination['cost']
# Example usage
destinations = [
{"name": "Paris", "cost": 1000, "activity": "sightseeing"},
{"name": "Tokyo", "cost": 1200, "activity": "shopping"},
{"name": "New York", "cost": 900, "activity": "sightseeing"},
{"name": "Sydney", "cost": 1100, "activity": "beach"},
]
preferences = {"activity": "sightseeing"}
budget = 2000
travel_agent = TravelAgent(destinations)
initial_plan = travel_agent.bootstrap_plan(preferences, budget)
print("Initial Plan:", initial_plan)
refined_plan = travel_agent.iterate_plan(initial_plan, preferences, budget)
print("Refined Plan:", refined_plan)-
ืืชืืื (ืฉืืืช
__init__): ืืืืงืชTravelAgentืืืืชืืืช ืขื ืจืฉืืืช ืืขืืื ืคืืื ืฆืืืืืื, ืฉืืื ืืื ืืื ืืฉ ืืืคืืื ืื ืืื ืฉื, ืขืืืช ืืกืื ืคืขืืืืช. -
ืื ืืืช ืชืืื ืืช ืจืืฉืื ืืช (ืฉืืืช
bootstrap_plan): ืฉืืื ืื ืืืฆืจืช ืชืืื ืืช ื ืกืืขื ืจืืฉืื ืืช ืืืชืืกืก ืขื ืืขืืคืืช ืืืงืื ืืืชืงืฆืื. ืืื ืขืืืจืช ืขื ืจืฉืืืช ืืืขืืื ืืืืกืืคื ืืืชื ืืชืืื ืืช ืื ืื ืชืืืืื ืืช ืืขืืคืืช ืืืงืื ืืืชืืืืื ืืชืงืฆืื. -
ืืชืืืช ืืขืืคืืช (ืฉืืืช
match_preferences): ืฉืืื ืื ืืืืงืช ืื ืืขื ืืกืืื ืชืืื ืืช ืืขืืคืืช ืืืงืื. -
ืืืืจืฆืื ืขื ืืชืืื ืืช (ืฉืืืช
iterate_plan): ืฉืืื ืื ืืฉืคืจืช ืืช ืืชืืื ืืช ืืจืืฉืื ืืช ืขื ืืื ื ืืกืืื ืืืืืืฃ ืื ืืขื ืืชืืื ืืช ืืืชืืื ืืืื ืืืชืจ, ืชืื ืืชืืฉืืืช ืืืขืืคืืช ืืืงืื ืืืืืืืืช ืืชืงืฆืื. -
ืืืฉืื ืขืืืช (ืฉืืืช
calculate_cost): ืฉืืื ืื ืืืฉืืช ืืช ืืขืืืช ืืืืืืช ืฉื ืืชืืื ืืช ืื ืืืืืช, ืืืื ืืขื ืืืฉ ืคืืื ืฆืืืื.
- ืชืืื ืืช ืจืืฉืื ืืช: ืกืืื ืื ืกืืขืืช ืืืฆืจ ืชืืื ืืช ืจืืฉืื ืืช ืืืชืืกืก ืขื ืืขืืคืืช ืืืงืื ืืืืืืื ืืืชืจืื ืชืืืจืืชืืื ืืชืงืฆืื ืฉื $2000.
- ืชืืื ืืช ืืฉืืคืจืช: ืกืืื ืื ืกืืขืืช ืืืฆืข ืืืืจืฆืืืช ืขื ืืชืืื ืืช, ืืฉืคืจ ืืืชื ืืืชืื ืืืขืืคืืช ืืืงืื ืืืชืงืฆืื.
ืขื ืืื ืื ืืืช ืืชืืื ืืช ืขื ืืืจื ืืจืืจื (ืืืฉื, ืืงืกืื ืฉืืืขืืช ืจืฆืื ืืืงืื) ืืืืฆืืข ืืืืจืฆืืืช ืืฉืืคืืจื, ืกืืื ืื ืกืืขืืช ืืืื ืืืฆืืจ ืืกืืื ื ืกืืขื ืืืชืื ืืืืคืืืืื ืขืืืจ ืืืงืื. ืืืฉื ืื ืืืืืื ืฉืืชืืื ืืช ืชืืืืช ืืช ืืขืืคืืช ืืืงืื ืืืชืงืฆืื ืืืืชืืื ืืืฉืชืคืจืช ืขื ืื ืืืืจืฆืื.
ืืืืืื ืืืืืื ืืฉืคื (LLMs) ืืืืืื ืืฉืืฉ ืืืืจืื ืืืืฉ ืื ืืงืื ืขื ืืื ืืขืจืืช ืืจืืืื ืืืืช ืืืืืืืช ืฉื ืืกืืืื ืฉื ืฉืืคื ืื ืชืืืืืช ืฉื ืืฆืจื. ืื ืื ืขืืื:
ืฉืืืคื: ืฉืื ืืฉืืืคื ืืจืืฉืื ื ืืืืืจ ืกื ืฉื ืืกืืืื ืื ืชืืืืืช ืืืขืืืื ืืืชืืกืก ืขื ืืฉืืืืชื.
ืืืจืื ืืืืฉ: ื-LLM ืืขืจืื ืืช ืืืืขืืืื ืืืืจื ืืืชื ืืืืฉ ืืืชืืกืก ืขื ืืจืืืื ืืืืช ืืืืืืืช ืฉืืื. ืฉืื ืื ืืืืื ืฉืืืืืข ืืจืืืื ืื ืืืืืืืชื ืืืืชืจ ืืืฆื ืจืืฉืื.
ื ืืงืื: ื-LLM ืืงืฆื ื ืืงืื ืืื ืืืขืื, ืืืฉืงืฃ ืืช ืืจืืืื ืืืืช ืืืืืืืช ืฉืืื. ืื ืขืืืจ ืืืืืจืช ืืชืืืื ืื ืืืกืื ืืืื ืืืืชืจ ืขืืืจ ืืืฉืชืืฉ.
ืขื ืืื ื ืืฆืื LLMs ืืืืจืื ืืืืฉ ืื ืืงืื, ืืืขืจืืช ืืืืื ืืกืคืง ืืืืข ืืืืืง ืืจืืืื ืื ืืืชืจ ืืืืื ื ืืงืฉืจืืช, ืืืฉืคืจ ืืช ืืืืืืช ืืืฉืชืืฉ ืืืืืืช.
ืื ื ืืืืื ืืืืคื ืฉืื ืกืืื ื ืกืืขืืช ืขืฉืื ืืืฉืชืืฉ ืืืืื ืฉืคื ืืืื (LLM) ืืืืจืื ืืืืฉ ืื ืืงืื ืฉื ืืขืื ื ืกืืขื ืืืชืืกืก ืขื ืืขืืคืืช ืืฉืชืืฉ ื-Python:
ืกืืื ื ืกืืขืืช ืจืืฆื ืืืืืืฅ ืขื ืืขืื ืื ืกืืขื ืืืืืื ืืืืชืจ ืืืงืื ืืืชืืกืก ืขื ืืขืืคืืชืื. ื-LLM ืืกืืืข ืืืืจืื ืืืืฉ ืื ืืงืื ืืืขืืื ืืื ืืืืืื ืฉืืืคืฉืจืืืืช ืืจืืืื ืืืืช ืืืืชืจ ืืืฆืื.
- ืืืกืืฃ ืืขืืคืืช ืืืฉืชืืฉ.
- ืฉืืืคืช ืจืฉืืืช ืืขืื ื ืกืืขื ืคืืื ืฆืืืืืื.
- ืฉืืืืฉ ื-LLM ืืืืจืื ืืืืฉ ืื ืืงืื ืืืขืืื ืืืชืืกืก ืขื ืืขืืคืืช ืืืฉืชืืฉ.
ืื ื ืืชื ืืขืืื ืืช ืืืืืื ืืงืืืืช ืืฉืืืืฉ ืืฉืืจืืชื Azure OpenAI:
- ื ืืจืฉ ืื ืื Azure.
- ืฆืืจ ืืฉืื Azure OpenAI ืืงืื ืืช ืืคืชื ื-API ืฉืื.
import requests
import json
class TravelAgent:
def __init__(self, destinations):
self.destinations = destinations
def get_recommendations(self, preferences, api_key, endpoint):
# Generate a prompt for the Azure OpenAI
prompt = self.generate_prompt(preferences)
# Define headers and payload for the request
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_key}'
}
payload = {
"prompt": prompt,
"max_tokens": 150,
"temperature": 0.7
}
# Call the Azure OpenAI API to get the re-ranked and scored destinations
response = requests.post(endpoint, headers=headers, json=payload)
response_data = response.json()
# Extract and return the recommendations
recommendations = response_data['choices'][0]['text'].strip().split('\n')
return recommendations
def generate_prompt(self, preferences):
prompt = "Here are the travel destinations ranked and scored based on the following user preferences:\n"
for key, value in preferences.items():
prompt += f"{key}: {value}\n"
prompt += "\nDestinations:\n"
for destination in self.destinations:
prompt += f"- {destination['name']}: {destination['description']}\n"
return prompt
# Example usage
destinations = [
{"name": "Paris", "description": "City of lights, known for its art, fashion, and culture."},
{"name": "Tokyo", "description": "Vibrant city, famous for its modernity and traditional temples."},
{"name": "New York", "description": "The city that never sleeps, with iconic landmarks and diverse culture."},
{"name": "Sydney", "description": "Beautiful harbour city, known for its opera house and stunning beaches."},
]
preferences = {"activity": "sightseeing", "culture": "diverse"}
api_key = 'your_azure_openai_api_key'
endpoint = 'https://your-endpoint.com/openai/deployments/your-deployment-name/completions?api-version=2022-12-01'
travel_agent = TravelAgent(destinations)
recommendations = travel_agent.get_recommendations(preferences, api_key, endpoint)
print("Recommended Destinations:")
for rec in recommendations:
print(rec)-
ืืชืืื: ืืืืงืช
TravelAgentืืืืชืืืช ืขื ืจืฉืืืช ืืขืื ื ืกืืขื ืคืืื ืฆืืืืืื, ืฉืืื ืืื ืืื ืืฉ ืืืคืืื ืื ืืื ืฉื ืืชืืืืจ. -
ืงืืืช ืืืืฆืืช (ืฉืืืช
get_recommendations): ืฉืืื ืื ืืืืฆืจืช ืคืจืืืคื ืืฉืืจืืช Azure OpenAI ืืืชืืกืก ืขื ืืขืืคืืช ืืืฉืชืืฉ ืืืืฆืขืช ืืงืฉืช HTTP POST ื-API ืฉื Azure OpenAI ืืื ืืงืื ืืขืืื ืืืืจืืื ืืื ืืงืืื. -
ืืฆืืจืช ืคืจืืืคื (ืฉืืืช
generate_prompt): ืฉืืื ืื ืืื ื ืคืจืืืคื ืขืืืจ Azure OpenAI, ืืืืื ืืช ืืขืืคืืช ืืืฉืชืืฉ ืืจืฉืืืช ืืืขืืื. ืืคืจืืืคื ืื ืื ืืช ืืืืื ืืืจื ืืืืฉ ืืื ืงื ืืช ืืืขืืื ืืืชืืกืก ืขื ืืืขืืคืืช ืฉืกืืคืงื. -
ืงืจืืืช API: ืกืคืจืืืช
requestsืืฉืืฉืช ืืืืฆืืข ืืงืฉืช HTTP POST ืื ืงืืืช ืืงืฆื ืฉื Azure OpenAI. ืืชืืืื ืืืืื ืืช ืืืขืืื ืืืืืจืืื ืืืื ืืงืืื. -
ืืืืื ืืฉืืืืฉ: ืกืืื ืื ืกืืขืืช ืืืกืฃ ืืช ืืขืืคืืช ืืืฉืชืืฉ (ืืืฉื, ืขื ืืื ืืืชืจืื ืชืืืจืืชืืื ืืชืจืืืช ืืืืื ืช) ืืืฉืชืืฉ ืืฉืืจืืช Azure OpenAI ืืื ืืงืื ืืืืฆืืช ืืืืจืืืช ืืื ืืงืืืช ืืืขืื ื ืกืืขื.
ืืื ืืืืืืฃ ืืช your_azure_openai_api_key ืืืคืชื ื-API ืืืืืชื ืฉืื ืืืช https://your-endpoint.com/... ืืืชืืืช ื-URL ืืืืืชืืช ืฉื ื ืงืืืช ืืงืฆื ืฉื Azure OpenAI ืฉืื.
ืขื ืืื ื ืืฆืื ื-LLM ืืืืจืื ืืืืฉ ืื ืืงืื, ืกืืื ืื ืกืืขืืช ืืืื ืืกืคืง ืืืืฆืืช ื ืกืืขื ืืืชืืืืช ืืจืืืื ืืืืช ืืืชืจ ืืืงืืืืช, ืืืฉืคืจ ืืช ืืืืืื ืืืืืืช ืฉืืื.
ืืืื ื ืืงื ืืช ืกืืื ืื ืกืืขืืช ืืืืืื ืืื ืืจืืืช ืืืฆื ื ืืชื ืืืืฉื ืืืคืืฉ ืขื ืืืื ื.
-
ืืืกืืฃ ืืขืืคืืช ืืฉืชืืฉ
class Travel_Agent: def __init__(self): self.user_preferences = {} def gather_preferences(self, preferences): self.user_preferences = preferences
-
ืืื ืช ืืืื ืช ืืืฉืชืืฉ
def identify_intent(query): if "book" in query or "purchase" in query: return "transactional" elif "website" in query or "official" in query: return "navigational" else: return "informational"
-
ืืืืขืืช ืืืงืฉืจ
def analyze_context(query, user_history): # Combine current query with user history to understand context context = { "current_query": query, "user_history": user_history } return context
-
ืืืคืืฉ ืืืชืืื ืืืฉืืช ืฉื ืชืืฆืืืช
def search_with_intent(query, preferences, user_history): intent = identify_intent(query) context = analyze_context(query, user_history) if intent == "informational": search_results = search_information(query, preferences) elif intent == "navigational": search_results = search_navigation(query) elif intent == "transactional": search_results = search_transaction(query, preferences) personalized_results = personalize_results(search_results, user_history) return personalized_results def search_information(query, preferences): # Example search logic for informational intent results = search_web(f"best {preferences['interests']} in {preferences['destination']}") return results def search_navigation(query): # Example search logic for navigational intent results = search_web(query) return results def search_transaction(query, preferences): # Example search logic for transactional intent results = search_web(f"book {query} to {preferences['destination']}") return results def personalize_results(results, user_history): # Example personalization logic personalized = [result for result in results if result not in user_history] return personalized[:10] # Return top 10 personalized results
-
ืฉืืืืฉ ืืืืืื
travel_agent = Travel_Agent() preferences = { "destination": "Paris", "interests": ["museums", "cuisine"] } travel_agent.gather_preferences(preferences) user_history = ["Louvre Museum website", "Book flight to Paris"] query = "best museums in Paris" results = search_with_intent(query, preferences, user_history) print("Search Results:", results)
ืกืืื ืื ืืืฆืืจืช ืงืื ืืฉืชืืฉืื ืืืืืืื ืฉื ืืื ื ืืืืืืชืืช ืืืชืืื ืืืจืฆืช ืงืื, ืคืชืจืื ืืขืืืช ืืืจืืืืช ืืืืืืืฆืื ืฉื ืืฉืืืืช.
ืกืืื ืื ืืืฆืืจืช ืงืื ืืฉืชืืฉืื ืืืืืืื ืื ืจืืืืืื ืฉื ืืื ื ืืืืืืชืืช ืืืชืืื ืืืจืฆืช ืงืื. ืกืืื ืื ืืื ืืืืืื ืืคืชืืจ ืืขืืืช ืืืจืืืืช, ืืืืืืื ืืฉืืืืช ืืืกืคืง ืชืืื ืืช ืืฉืืืืช ืขื ืืื ืืฆืืจื ืืืจืฆื ืฉื ืงืื ืืฉืคืืช ืชืื ืืช ืฉืื ืืช.
- ืืฆืืจืช ืงืื ืืืืืืืืช: ืืฆืืจืช ืงืืขื ืงืื ืืืฉืืืืช ืกืคืฆืืคืืืช, ืืื ื ืืชืื ื ืชืื ืื, ืืจืืืช ืจืฉืช ืื ืืืืืช ืืืื ื.
- SQL ื-RAG: ืฉืืืืฉ ืืฉืืืืชืืช SQL ืืฉืืืคื ืืืขืืืื ื ืชืื ืื ืืืกืื ื ืชืื ืื.
- ืคืชืจืื ืืขืืืช: ืืฆืืจื ืืืจืฆื ืฉื ืงืื ืืคืชืจืื ืืขืืืช ืกืคืฆืืคืืืช, ืืื ืืืคืืืืืืฆืื ืฉื ืืืืืจืืชืืื ืื ื ืืชืื ื ืชืื ืื.
ืืืืื ื ืฉืืชื ืืขืฆืืื ืกืืื ืืืฆืืจืช ืงืื. ืื ืื ืขืฉืื ืืขืืื:
- ืืฉืืื: ื ืืชืื ืืขืจื ื ืชืื ืื ืืืืืื ืืืืืช ืืืคืืกืื.
- ืฉืืืื:
- ืืขืื ืช ืืขืจื ืื ืชืื ืื ืืืื ื ืืชืื ื ืชืื ืื.
- ืืฆืืจืช ืฉืืืืชืืช SQL ืืกืื ืื ืืืืจืืฆืื ืฉื ืื ืชืื ืื.
- ืืจืฆืช ืืฉืืืืชืืช ืืฉืืืคืช ืืชืืฆืืืช.
- ืฉืืืืฉ ืืชืืฆืืืช ืืืฆืืจืช ืืืืืืืืืฆืืืช ืืชืืื ืืช.
- ืืฉืืืื ื ืืจืฉืื: ืืืฉื ืืืขืจื ืื ืชืื ืื, ืืื ื ืืชืื ื ืชืื ืื ืืืืืืืช SQL.
- ื ืืกืืื: ืฉืืืืฉ ืืชืืฆืืืช ื ืืชืื ืงืืืืืช ืืฉืืคืืจ ืืืืืง ืืืจืืืื ืืืืช ืฉื ื ืืชืืืื ืขืชืืืืื.
ืืืืืื ืื, ื ืขืฆื ืกืืื ืืืฆืืจืช ืงืื, ืกืืื ื ืกืืขืืช, ืฉืืขืืืจ ืืืฉืชืืฉืื ืืชืื ืื ื ืกืืขืืช ืขื ืืื ืืฆืืจื ืืืจืฆื ืฉื ืงืื. ืกืืื ืื ืืืื ืืืคื ืืืฉืืืืช ืืื ืฉืืืคืช ืืคืฉืจืืืืช ื ืกืืขื, ืกืื ืื ืชืืฆืืืช ืืืจืืืช ืืกืืื ืืืืฆืขืืช ืืื ื ืืืืืืชืืช ืื ืจืืืืืช.
- ืืืกืืฃ ืืขืืคืืช ืืฉืชืืฉ: ืืืกืืฃ ืงืื ืืืืฉืชืืฉ ืืื ืืขื, ืชืืจืืื ื ืกืืขื, ืชืงืฆืื ืืชืืืื ืขื ืืื.
- ืืฆืืจืช ืงืื ืืฉืืืคืช ื ืชืื ืื: ืืฆืืจืช ืงืืขื ืงืื ืืฉืืืคืช ื ืชืื ืื ืขื ืืืกืืช, ืืืื ืืช ืืืืจืงืฆืืืช.
- ืืจืฆืช ืืงืื ืฉื ืืฆืจ: ืืจืฆืช ืืงืื ืฉื ืืฆืจ ืืฉืืืคืช ืืืืข ืืืื ืืืช.
- ืืฆืืจืช ืืกืืื ื ืกืืขื: ืืจืืืช ืื ืชืื ืื ืฉื ืฉืืคื ืืชืืื ืืช ื ืกืืขื ืืืชืืืช ืืืฉืืช.
- ืืชืืื ืขื ืืกืืก ืืฉืื: ืงืืืช ืืฉืื ืืืืฉืชืืฉ ืืืฆืืจืช ืงืื ืืืืฉ ืืืืืช ืืฆืืจื ืืฉืืคืืจ ืืชืืฆืืืช.
-
ืืืกืืฃ ืืขืืคืืช ืืฉืชืืฉ
class Travel_Agent: def __init__(self): self.user_preferences = {} def gather_preferences(self, preferences): self.user_preferences = preferences
-
ืืฆืืจืช ืงืื ืืฉืืืคืช ื ืชืื ืื
def generate_code_to_fetch_data(preferences): # Example: Generate code to search for flights based on user preferences code = f""" def search_flights(): import requests response = requests.get('https://api.example.com/flights', params={preferences}) return response.json() """ return code def generate_code_to_fetch_hotels(preferences): # Example: Generate code to search for hotels code = f""" def search_hotels(): import requests response = requests.get('https://api.example.com/hotels', params={preferences}) return response.json() """ return code
-
ืืจืฆืช ืืงืื ืฉื ืืฆืจ
def execute_code(code): # Execute the generated code using exec exec(code) result = locals() return result travel_agent = Travel_Agent() preferences = { "destination": "Paris", "dates": "2025-04-01 to 2025-04-10", "budget": "moderate", "interests": ["museums", "cuisine"] } travel_agent.gather_preferences(preferences) flight_code = generate_code_to_fetch_data(preferences) hotel_code = generate_code_to_fetch_hotels(preferences) flights = execute_code(flight_code) hotels = execute_code(hotel_code) print("Flight Options:", flights) print("Hotel Options:", hotels)
-
ืืฆืืจืช ืืกืืื ื ืกืืขื
def generate_itinerary(flights, hotels, attractions): itinerary = { "flights": flights, "hotels": hotels, "attractions": attractions } return itinerary attractions = search_attractions(preferences) itinerary = generate_itinerary(flights, hotels, attractions) print("Suggested Itinerary:", itinerary)
-
ืืชืืื ืขื ืืกืืก ืืฉืื
def adjust_based_on_feedback(feedback, preferences): # Adjust preferences based on user feedback if "liked" in feedback: preferences["favorites"] = feedback["liked"] if "disliked" in feedback: preferences["avoid"] = feedback["disliked"] return preferences feedback = {"liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"]} updated_preferences = adjust_based_on_feedback(feedback, preferences) # Regenerate and execute code with updated preferences updated_flight_code = generate_code_to_fetch_data(updated_preferences) updated_hotel_code = generate_code_to_fetch_hotels(updated_preferences) updated_flights = execute_code(updated_flight_code) updated_hotels = execute_code(updated_hotel_code) updated_itinerary = generate_itinerary(updated_flights, updated_hotels, attractions) print("Updated Itinerary:", updated_itinerary)
ืฉืืืืฉ ืืืื ื ืืืืื ืืืื ืืฉืคืจ ืืช ืชืืืื ืืฆืืจืช ืืฉืืืืชืืช ืขื ืืื ื ืืฆืื ืืืืขืืช ืกืืืืชืืช ืืืกืงืช ืืกืงื ืืช.
ืื ื ืืืืื ืืืฆื ื ืืชื ืืขืฉืืช ืืืช:
- ืืื ืช ืืืื ื: ืืืขืจืืช ืชืืื ืืช ืืื ื ืืืืื ืืชืฉืชืืฉ ืืืืืข ืื ืืื ืืืกืก ืืช ืืฆืืจืช ืืฉืืืืชืืช.
- ืืชืืื ืขื ืืกืืก ืืฉืื: ืืืขืจืืช ืชืชืืื ืืช ืืขืืคืืช ืืืฉืชืืฉ ืขื ืืกืืก ืืฉืื ืืชืกืืง ืืืื ืฉืืืช ืืืื ื ืืฉ ืืขืืื.
- ืืฆืืจื ืืืจืฆื ืฉื ืฉืืืืชืืช: ืืืขืจืืช ืชืืฆืืจ ืืชืืฆืข ืฉืืืืชืืช ืืฉืืืคืช ื ืชืื ื ืืืกืืช ืืืืื ืืช ืืขืืืื ืื ืขื ืืกืืก ืืขืืคืืช ืืืฉืืช.
ืื ื ืืืืืช ืงืื Python ืืขืืืื ืช ืฉืืืืฉืืช ืืช ืืจืขืืื ืืช ืืืื:
def adjust_based_on_feedback(feedback, preferences, schema):
# Adjust preferences based on user feedback
if "liked" in feedback:
preferences["favorites"] = feedback["liked"]
if "disliked" in feedback:
preferences["avoid"] = feedback["disliked"]
# Reasoning based on schema to adjust other related preferences
for field in schema:
if field in preferences:
preferences[field] = adjust_based_on_environment(feedback, field, schema)
return preferences
def adjust_based_on_environment(feedback, field, schema):
# Custom logic to adjust preferences based on schema and feedback
if field in feedback["liked"]:
return schema[field]["positive_adjustment"]
elif field in feedback["disliked"]:
return schema[field]["negative_adjustment"]
return schema[field]["default"]
def generate_code_to_fetch_data(preferences):
# Generate code to fetch flight data based on updated preferences
return f"fetch_flights(preferences={preferences})"
def generate_code_to_fetch_hotels(preferences):
# Generate code to fetch hotel data based on updated preferences
return f"fetch_hotels(preferences={preferences})"
def execute_code(code):
# Simulate execution of code and return mock data
return {"data": f"Executed: {code}"}
def generate_itinerary(flights, hotels, attractions):
# Generate itinerary based on flights, hotels, and attractions
return {"flights": flights, "hotels": hotels, "attractions": attractions}
# Example schema
schema = {
"favorites": {"positive_adjustment": "increase", "negative_adjustment": "decrease", "default": "neutral"},
"avoid": {"positive_adjustment": "decrease", "negative_adjustment": "increase", "default": "neutral"}
}
# Example usage
preferences = {"favorites": "sightseeing", "avoid": "crowded places"}
feedback = {"liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"]}
updated_preferences = adjust_based_on_feedback(feedback, preferences, schema)
# Regenerate and execute code with updated preferences
updated_flight_code = generate_code_to_fetch_data(updated_preferences)
updated_hotel_code = generate_code_to_fetch_hotels(updated_preferences)
updated_flights = execute_code(updated_flight_code)
updated_hotels = execute_code(updated_hotel_code)
updated_itinerary = generate_itinerary(updated_flights, updated_hotels, feedback["liked"])
print("Updated Itinerary:", updated_itinerary)- ืืืืขืืช ืืืื ื: ืืืืืื
schemaืืืืืจ ืืืฆื ืืฉ ืืืชืืื ืืขืืคืืช ืขื ืืกืืก ืืฉืื. ืืื ืืืื ืฉืืืช ืืืfavoritesื-avoid, ืขื ืืชืืืืช ืืชืืืืืช. - ืืชืืืช ืืขืืคืืช (
adjust_based_on_feedbackmethod): ืฉืืื ืื ืืชืืืื ืืขืืคืืช ืขื ืืกืืก ืืฉืื ืืฉืชืืฉ ืืืืื ื. - ืืชืืืืช ืืืืกืกืืช ืกืืืื (
adjust_based_on_environmentmethod): ืฉืืื ืื ืืชืืืื ืืช ืืืชืืืืช ืขื ืืกืืก ืืืื ื ืืืืฉืื. - ืืฆืืจื ืืืจืฆื ืฉื ืฉืืืืชืืช: ืืืขืจืืช ืืืฆืจืช ืงืื ืืฉืืืคืช ื ืชืื ื ืืืกืืช ืืืืื ืืช ืืขืืืื ืื ืขื ืืกืืก ืืขืืคืืช ืืืชืืืืช ืืืืื ืืช ืืืฆืืข ืืฉืืืืชืืช.
- ืืฆืืจืช ืืกืืื ื ืกืืขื: ืืืขืจืืช ืืืฆืจืช ืืกืืื ืืขืืืื ืขื ืืกืืก ื ืชืื ื ืืืกืืช, ืืืื ืืช ืืืืจืงืฆืืืช ืืืฉืื.
ืขื ืืื ืืคืืืช ืืืขืจืืช ืืืืืขืช ืืกืืืื ืืืกืงืช ืืกืงื ืืช ืขื ืืกืืก ืืืื ื, ื ืืชื ืืืฆืืจ ืฉืืืืชืืช ืืืืืงืืช ืืจืืืื ืืืืช ืืืชืจ, ืื ืฉืืืืื ืืืืืฆืืช ื ืกืืขื ืืืืืช ืืืชืจ ืืืืืืืช ืืฉืชืืฉ ืืืชืืืช ืืืฉืืช.
SQL (ืฉืคืช ืฉืืืืชืืช ืืืื ืืช) ืืื ืืื ืขืืฆืืชื ืืืื ืืจืืงืฆืื ืขื ืืกืื ื ืชืื ืื. ืืืฉืจ ืืฉืชืืฉืื ืื ืืืืง ืืืืฉื ืฉื ืฉืืืคื ืืืืืจืช (RAG), SQL ืืืืื ืืฉืืืฃ ื ืชืื ืื ืจืืืื ืืืื ืืืกืื ื ืชืื ืื ืืื ืืืืืข ืืืืฆืืจ ืชืืืืืช ืื ืคืขืืืืช ืืกืืื ื ืืื ื ืืืืืืชืืช. ืืืื ื ืืงืืจ ืืืฆื SQL ืืืืื ืืฉืืฉ ืืืื ืืงืช RAG ืืืงืฉืจ ืฉื ืกืืื ื ืกืืขืืช.
-
ืืื ืืจืืงืฆืื ืขื ืืกืื ื ืชืื ืื:
- SQL ืืฉืืฉืช ืืฉืืืืช ืืกืื ื ืชืื ืื, ืฉืืืคืช ืืืืข ืจืืืื ืื ืืขืืืื ื ืชืื ืื.
- ืืืืื: ืฉืืืคืช ืคืจืื ืืืกืืช, ืืืืข ืขื ืืืื ืืช ืืืืจืงืฆืืืช ืืืกื ื ืชืื ืื ืฉื ื ืกืืขืืช.
-
ืฉืืืื ืขื RAG:
- ืฉืืืืชืืช SQL ื ืืฆืจืืช ืขื ืืกืืก ืงืื ืืืขืืคืืช ืืืฉืชืืฉ.
- ืื ืชืื ืื ืฉื ืฉืืคื ืืฉืืฉืื ืืืฆืืจืช ืืืืฆืืช ืื ืคืขืืืืช ืืืชืืืืช ืืืฉืืช.
-
ืืฆืืจืช ืฉืืืืชืืช ืืื ืืืช:
- ืกืืื ืืืื ื ืืืืืืืชืืช ืืืฆืจ ืฉืืืืชืืช SQL ืืื ืืืืช ืขื ืืกืืก ืืืงืฉืจ ืืฆืจืื ืืืฉืชืืฉ.
- ืืืืื: ืืชืืืช ืฉืืืืชืืช SQL ืืกืื ืื ืชืืฆืืืช ืขื ืืกืืก ืชืงืฆืื, ืชืืจืืืื ืืชืืืื ืขื ืืื.
- ืืฆืืจืช ืงืื ืืืืืืืืช: ืืฆืืจืช ืงืืขื ืงืื ืืืฉืืืืช ืกืคืฆืืคืืืช.
- SQL ื-RAG: ืฉืืืืฉ ืืฉืืืืชืืช SQL ืืขืืืื ื ืชืื ืื.
- ืคืชืจืื ืืขืืืช: ืืฆืืจื ืืืจืฆื ืฉื ืงืื ืืคืชืจืื ืืขืืืช.
ืืืืื:
ืกืืื ื ืืชืื ื ืชืื ืื:
- ืืฉืืื: ื ืืชืื ืืขืจื ื ืชืื ืื ืืืฆืืืช ืืืืืช.
- ืฉืืืื:
- ืืขืื ืช ืืขืจื ืื ืชืื ืื.
- ืืฆืืจืช ืฉืืืืชืืช SQL ืืกืื ืื ื ืชืื ืื.
- ืืจืฆืช ืฉืืืืชืืช ืืฉืืืคืช ืชืืฆืืืช.
- ืืฆืืจืช ืืืืืืืืืฆืืืช ืืชืืื ืืช.
- ืืฉืืืื: ืืืฉื ืืืขืจื ืื ืชืื ืื, ืืืืืืช SQL.
- ื ืืกืืื: ืฉืืืืฉ ืืชืืฆืืืช ืงืืืืืช ืืฉืืคืืจ ื ืืชืืืื ืขืชืืืืื.
-
ืืืกืืฃ ืืขืืคืืช ืืฉืชืืฉ
class Travel_Agent: def __init__(self): self.user_preferences = {} def gather_preferences(self, preferences): self.user_preferences = preferences
-
ืืฆืืจืช ืฉืืืืชืืช SQL
def generate_sql_query(table, preferences): query = f"SELECT * FROM {table} WHERE " conditions = [] for key, value in preferences.items(): conditions.append(f"{key}='{value}'") query += " AND ".join(conditions) return query
-
ืืจืฆืช ืฉืืืืชืืช SQL
import sqlite3 def execute_sql_query(query, database="travel.db"): connection = sqlite3.connect(database) cursor = connection.cursor() cursor.execute(query) results = cursor.fetchall() connection.close() return results
-
ืืฆืืจืช ืืืืฆืืช
def generate_recommendations(preferences): flight_query = generate_sql_query("flights", preferences) hotel_query = generate_sql_query("hotels", preferences) attraction_query = generate_sql_query("attractions", preferences) flights = execute_sql_query(flight_query) hotels = execute_sql_query(hotel_query) attractions = execute_sql_query(attraction_query) itinerary = { "flights": flights, "hotels": hotels, "attractions": attractions } return itinerary travel_agent = Travel_Agent() preferences = { "destination": "Paris", "dates": "2025-04-01 to 2025-04-10", "budget": "moderate", "interests": ["museums", "cuisine"] } travel_agent.gather_preferences(preferences) itinerary = generate_recommendations(preferences) print("Suggested Itinerary:", itinerary)
-
ืฉืืืืชืช ืืืกืืช
SELECT * FROM flights WHERE destination='Paris' AND dates='2025-04-01 to 2025-04-10' AND budget='moderate';
-
ืฉืืืืชืช ืืืื ืืช
SELECT * FROM hotels WHERE destination='Paris' AND budget='moderate';
-
ืฉืืืืชืช ืืืจืงืฆืืืช
SELECT * FROM attractions WHERE destination='Paris' AND interests='museums, cuisine';
ืขื ืืื ืฉืืืืฉ ื-SQL ืืืืง ืืืื ืืงืช ืฉืืืคื ืืืืืจืช (RAG), ืกืืื ื ืืื ื ืืืืืืชืืช ืืื ืกืืื ื ืกืืขืืช ืืืืืื ืืฉืืืฃ ืืืืฉืชืืฉ ืื ืชืื ืื ืจืืืื ืืืื ืืืืคื ืืื ืื ืืื ืืกืคืง ืืืืฆืืช ืืืืืงืืช ืืืืชืืืืช ืืืฉืืช.
ืืื ืืืืืื ืืืฉืื ืฉื ืืื-ืงืืื ืืฆืื, ื ืืฆืืจ ืกืืื ืคืฉืื ืฉืืฉืงืฃ ืืช ืชืืืื ืงืืืช ืืืืืืืช ืฉืื ืชืื ืืื ืคืชืจืื ืืขืื. ืืืืืื ืื, ื ืื ื ืืขืจืืช ืฉืื ืกืืื ืื ืกื ืืืืืจ ืืืื ืืืคืืืืื, ืื ืืืืจ ืืื ืืขืจืื ืืช ืืืืืืื ืฉืื ืืืชืืื ืืช ืืืกืืจืืืื ืฉืื ืืืฉืจ ืืื ืืืฆืข ืืขืืืืช ืื ืืืืจืืช ืื ืืืคืืืืืืืช.
- ืืืืื ืจืืฉืื ืืช: ืืกืืื ืืืืจ ืืช ืืืืื ืืืื ืืืืชืจ, ืืืื ืืืืื ืืช ืืืฉืคืขื ืขื ืืืืืืช.
- ืจืคืืงืฆืื ืืืขืจืื: ืืืืจ ืืืืืจื ืืจืืฉืื ืืช, ืืกืืื ืืืืืง ืื ืืืืื ืืื "ืืืืจื ืืจืืขื" ืขื ืกืื ืืฉืื ืืฉืชืืฉ. ืื ืืืฆื ืฉืืืืืืช ื ืืืื ืืื, ืืื ืืฉืงืฃ ืขื ืืืืืืื ืฉืื.
- ืืชืืืช ืืกืืจืืืื: ืืกืืื ืืชืืื ืืช ืืืกืืจืืืื ืฉืื ืขื ืืกืืก ืืจืคืืงืฆืื ืืืขืืืจ ื"ืืื ืืืืชืจ" ื"ืืืืืช ืืืืืื ืืืืชืจ", ืืืื ืืฉืคืจ ืืช ืชืืืื ืงืืืช ืืืืืืืช ืฉืื ืืขืชืื.
ืื ื ืืืืื:
class HotelRecommendationAgent:
def __init__(self):
self.previous_choices = [] # Stores the hotels chosen previously
self.corrected_choices = [] # Stores the corrected choices
self.recommendation_strategies = ['cheapest', 'highest_quality'] # Available strategies
def recommend_hotel(self, hotels, strategy):
"""
Recommend a hotel based on the chosen strategy.
The strategy can either be 'cheapest' or 'highest_quality'.
"""
if strategy == 'cheapest':
recommended = min(hotels, key=lambda x: x['price'])
elif strategy == 'highest_quality':
recommended = max(hotels, key=lambda x: x['quality'])
else:
recommended = None
self.previous_choices.append((strategy, recommended))
return recommended
def reflect_on_choice(self):
"""
Reflect on the last choice made and decide if the agent should adjust its strategy.
The agent considers if the previous choice led to a poor outcome.
"""
if not self.previous_choices:
return "No choices made yet."
last_choice_strategy, last_choice = self.previous_choices[-1]
# Let's assume we have some user feedback that tells us whether the last choice was good or not
user_feedback = self.get_user_feedback(last_choice)
if user_feedback == "bad":
# Adjust strategy if the previous choice was unsatisfactory
new_strategy = 'highest_quality' if last_choice_strategy == 'cheapest' else 'cheapest'
self.corrected_choices.append((new_strategy, last_choice))
return f"Reflecting on choice. Adjusting strategy to {new_strategy}."
else:
return "The choice was good. No need to adjust."
def get_user_feedback(self, hotel):
"""
Simulate user feedback based on hotel attributes.
For simplicity, assume if the hotel is too cheap, the feedback is "bad".
If the hotel has quality less than 7, feedback is "bad".
"""
if hotel['price'] < 100 or hotel['quality'] < 7:
return "bad"
return "good"
# Simulate a list of hotels (price and quality)
hotels = [
{'name': 'Budget Inn', 'price': 80, 'quality': 6},
{'name': 'Comfort Suites', 'price': 120, 'quality': 8},
{'name': 'Luxury Stay', 'price': 200, 'quality': 9}
]
# Create an agent
agent = HotelRecommendationAgent()
# Step 1: The agent recommends a hotel using the "cheapest" strategy
recommended_hotel = agent.recommend_hotel(hotels, 'cheapest')
print(f"Recommended hotel (cheapest): {recommended_hotel['name']}")
# Step 2: The agent reflects on the choice and adjusts strategy if necessary
reflection_result = agent.reflect_on_choice()
print(reflection_result)
# Step 3: The agent recommends again, this time using the adjusted strategy
adjusted_recommendation = agent.recommend_hotel(hotels, 'highest_quality')
print(f"Adjusted hotel recommendation (highest_quality): {adjusted_recommendation['name']}")ืื ืงืืื ืืืจืืืืช ืืื ืืื ืืืืืชื ืฉื ืืกืืื:
- ืืืขืจืื ืืช ืืืืืจืืช ืืชืืืื ืงืืืช ืืืืืืืช ืืงืืื ืฉืื.
- ืืืชืืื ืืช ืืืกืืจืืืื ืฉืื ืขื ืืกืืก ืืจืคืืงืฆืื, ืืืืืจ, ืืื-ืงืืื ืืฆืื ืืคืขืืื.
ืืื ืืืฉืื ืคืฉืื ืฉื ืืื-ืงืืื ืืฆืื ืฉืื ืืืขืจืืช ืืกืืืืช ืืืชืืื ืืช ืชืืืื ืืืืืืื ืฉืื ืขื ืืกืืก ืืฉืื ืคื ืืื.
ืืื-ืงืืื ืืฆืื ืืื ืืื ืขืืฆืืชื ืฉืืืื ืืฉืคืจ ืืฉืืขืืชืืช ืืช ืืืืืืืช ืฉื ืกืืื ื ืืื ื ืืืืืืชืืช. ืขื ืืื ืฉืืืื ืชืืืืืื ืืื-ืงืืื ืืืืืืื, ื ืืชื ืืขืฆื ืกืืื ืื ืืืืื, ืืืืฉืื ืืืขืืืื ืืืชืจ. ืืฉืชืืฉื ืืืฉืืืื ืื ืืกืคืื ืืื ืืืขืืืง ืืขืืื ืืืจืชืง ืฉื ืืื-ืงืืื ืืฆืื ืืกืืื ื ืืื ื ืืืืืืชืืช.
ืืฆืืจืคื ื-Azure AI Foundry Discord ืืื ืืคืืืฉ ืืืืืื ื ืืกืคืื, ืืืฉืชืชืฃ ืืฉืขืืช ืงืืื ืืืงืื ืชืฉืืืืช ืืฉืืืืช ืฉืืื ืขื ืกืืื ื ืืื ื ืืืืืืชืืช.
ืืคืืก ืขืืฆืื ืจื-ืกืืื ืื
ืกืืื ื ืืื ื ืืืืืืชืืช ืืกืืืืช ืืืฆืืจ
ืืชื ืืืชืืจ:
ืืกืื ืื ืชืืจืื ืืืืฆืขืืช ืฉืืจืืช ืชืจืืื ืืืืกืก ืืื ื ืืืืืืชืืช Co-op Translator. ืืืจืืช ืฉืื ื ืฉืืืคืื ืืืืืง, ืืฉ ืืงืืช ืืืฉืืื ืฉืชืจืืืืื ืืืืืืืืื ืขืฉืืืื ืืืืื ืฉืืืืืช ืื ืื ืืืืงืื. ืืืกืื ืืืงืืจื ืืฉืคืชื ืืืงืืจืืช ืฆืจืื ืืืืืฉื ืืืงืืจ ืกืืืืชื. ืขืืืจ ืืืืข ืงืจืืื, ืืืืืฅ ืืืฉืชืืฉ ืืชืจืืื ืืงืฆืืขื ืขื ืืื ืืื. ืืื ื ื ื ืืฉืืื ืืืืจืืืช ืืื ืืื ืืช ืื ืืคืจืฉื ืืืืช ืฉืืืืืช ืื ืืืขืืช ืืฉืืืืฉ ืืชืจืืื ืื.

