(इस पाठ का वीडियो देखने के लिए ऊपर चित्र पर क्लिक करें)
एआई एजेंट्स में मेटाकॉग्निशन
एआई एजेंट्स में मेटाकॉग्निशन पर इस पाठ में आपका स्वागत है! यह अध्याय उन शुरुआती लोगों के लिए डिज़ाइन किया गया है जो यह जानने के लिए उत्सुक हैं कि एआई एजेंट अपने स्वयं के सोचने की प्रक्रियाओं के बारे में कैसे सोच सकते हैं। इस पाठ के अंत तक, आप मुख्य अवधारणाओं को समझेंगे और मेटाकॉग्निशन को एआई एजेंट डिज़ाइन में लागू करने के लिए व्यावहारिक उदाहरणों से लैस होंगे।
इस पाठ को पूरा करने के बाद, आप सक्षम होंगे:
मेटाकॉग्निशन उच्च-स्तरीय संज्ञानात्मक प्रक्रियाओं को संदर्भित करता है जो अपनी सोच के बारे में सोचने में शामिल हैं। एआई एजेंट्स के लिए, इसका अर्थ है कि वे आत्म-जागरूकता और पिछले अनुभवों के आधार पर अपने कार्यों का मूल्यांकन और समायोजन कर सकें। मेटाकॉग्निशन, या “सोच के बारे में सोच,” एजेंटिक एआई प्रणालियों के विकास में एक महत्वपूर्ण अवधारणा है। इसमें एआई सिस्टम अपने आंतरिक प्रक्रियाओं के प्रति जागरूक होते हैं और अपनी व्यवहार को मॉनिटर, नियंत्रित और अनुकूलित करने में सक्षम होते हैं। ठीक उसी तरह जैसे हम किसी कमरे की परिस्थिति पढ़ते हैं या किसी समस्या को देखते हैं। यह आत्म-जागरूकता एआई सिस्टम को बेहतर निर्णय लेने, त्रुटियाँ पहचानने और समय के साथ प्रदर्शन सुधारने में मदद कर सकती है — यह फिर से ट्यूरिंग टेस्ट और यह बहस से जुड़ती है कि क्या एआई दुनिया पर कब्ज़ा कर लेगा।
एजेंटिक एआई प्रणालियों के संदर्भ में, मेटाकॉग्निशन कई चुनौतियों को संबोधित करने में मदद कर सकती है, जैसे कि:
मेटाकॉग्निशन, या “सोच के बारे में सोच,” एक उच्च-स्तरीय संज्ञानात्मक प्रक्रिया है जो आत्म-जागरूकता और अपनी संज्ञानात्मक प्रक्रियाओं के स्व-नियमन में शामिल है। एआई के क्षेत्र में, मेटाकॉग्निशन एजेंट्स को उनकी रणनीतियों और क्रियाओं का मूल्यांकन करने और अनुकूलित करने में सक्षम बनाता है, जिससे समस्या-समाधान और निर्णय-निर्माण क्षमताओं में सुधार होता है। मेटाकॉग्निशन को समझकर, आप ऐसे एआई एजेंट डिजाइन कर सकते हैं जो न केवल अधिक बुद्धिमान हों बल्कि अधिक अनुकूलनीय और प्रभावी भी हों। सच्चे मेटाकॉग्निशन में, आप देखेंगे कि एआई स्पष्ट रूप से अपने तर्क के बारे में तर्क कर रहा है।
उदाहरण: “मैंने सस्ते फ्लाइट को प्राथमिकता दी क्योंकि… मुझे डायरेक्ट फ्लाइट्स से चूक हो सकती है, इसलिए मैं पुनः जाँच करता हूँ।” यह ट्रैक रखना कि उसने किस प्रकार या क्यों किसी विशेष मार्ग का चयन किया।
मेटाकॉग्निशन कई कारणों से एआई एजेंट डिज़ाइन में महत्वपूर्ण भूमिका निभाता है:

मेटाकॉग्निटिव प्रक्रियाओं में गहराई से जाने से पहले, यह समझना आवश्यक है कि एक एआई एजेंट के बुनियादी घटक क्या हैं। एक एआई एजेंट आमतौर पर नीचे से बना होता है:
ये घटक मिलकर एक “विशेषज्ञता इकाई” बनाते हैं जो विशिष्ट कार्य कर सकती है।
उदाहरण: एक ट्रैवल एजेंट का उदाहरण लें, जो न केवल आपकी छुट्टियों की योजना बनाता है बल्कि वास्तविक समय के डेटा और पिछले ग्राहक यात्रा अनुभवों के आधार पर अपने रास्ते को समायोजित भी करता है।
कल्पना करें कि आप एआई संचालित ट्रैवल एजेंट सेवा डिज़ाइन कर रहे हैं। यह एजेंट, “ट्रैवल एजेंट,” उपयोगकर्ताओं की छुट्टियों की योजना बनाने में मदद करता है। मेटाकॉग्निशन को शामिल करने के लिए, ट्रैवल एजेंट को आत्म-जागरूकता और पिछले अनुभवों के आधार पर अपनी क्रियाओं का मूल्यांकन और समायोजन करना होगा। यहां बताया गया है कि मेटाकॉग्निशन कैसे भूमिका निभा सकता है:
वर्तमान कार्य एक उपयोगकर्ता की पेरिस यात्रा की योजना बनाने में मदद करना है।
ट्रैवल एजेंट अपने प्रदर्शन का मूल्यांकन करने और पिछले अनुभवों से सीखने के लिए मेटाकॉग्निशन का उपयोग करता है। उदाहरण के लिए:
यहाँ एक सरलीकृत उदाहरण है कि मेटाकॉग्निशन को शामिल करते हुए ट्रैवल एजेंट का कोड कैसा दिख सकता है:
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)
# उदाहरण उपयोग
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)
मेटाकॉग्निशन को शामिल करके, ट्रैवल एजेंट अधिक व्यक्तिगत और सटीक यात्रा सिफारिशें प्रदान कर सकता है, जिससे कुल उपयोगकर्ता अनुभव में सुधार होगा।
योजना बनाना एआई एजेंट के व्यवहार का एक महत्वपूर्ण घटक है। इसमें लक्ष्य प्राप्त करने के लिए आवश्यक कदमों की रूपरेखा बनाना शामिल है, जिसमें वर्तमान स्थिति, संसाधन और संभावित बाधाओं पर विचार किया जाता है।
उदाहरण: यहां वे चरण दिए गए हैं जिनका पालन ट्रैवल एजेंट को उपयोगकर्ता की यात्रा की प्रभावी योजना बनाने में मदद करने के लिए करना होगा:
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)
# booing अनुरोध के भीतर उदाहरण उपयोग
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 तकनीकों का उपयोग करके त्रुटियों को सुधारने और एआई एजेंट की सटीकता बढ़ाने पर केंद्रित है। इसमें शामिल हैं:
कल्पना करें कि एक खोज एजेंट उपयोगकर्ता क्वेरी का उत्तर देने के लिए वेब से जानकारी प्राप्त करता है। सुधारात्मक RAG दृष्टिकोण में शामिल हो सकता है:
सुधारात्मक RAG (रिट्रीवल-ऑगमेंटेड जनरेशन) एआई की जानकारी प्राप्त करने और उत्पन्न करने की क्षमता को बढ़ाता है, साथ ही त्रुटियों को सुधारता है। आइए देखें कि ट्रैवल एजेंट कैसे सुधारात्मक RAG दृष्टिकोण का उपयोग करके अधिक सटीक और प्रासंगिक यात्रा सिफारिशें प्रदान कर सकता है।
इसमें शामिल हैं:
उदाहरण:
preferences = {
"destination": "Paris",
"dates": "2025-04-01 to 2025-04-10",
"budget": "moderate",
"interests": ["museums", "cuisine"]
}
उदाहरण:
flights = search_flights(preferences)
hotels = search_hotels(preferences)
attractions = search_attractions(preferences)
उदाहरण:
itinerary = create_itinerary(flights, hotels, attractions)
print("Suggested Itinerary:", itinerary)
उदाहरण:
feedback = {
"liked": ["Louvre Museum"],
"disliked": ["Eiffel Tower (too crowded)"]
}
उदाहरण:
if "disliked" in feedback:
preferences["avoid"] = feedback["disliked"]
उदाहरण:
new_attractions = search_attractions(preferences)
new_itinerary = create_itinerary(flights, hotels, new_attractions)
print("Updated Itinerary:", new_itinerary)
उदाहरण:
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)
यहाँ ट्रैवल एजेंट में सुधारात्मक RAG दृष्टिकोण को शामिल करने वाला एक सरल Python कोड उदाहरण है:
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
# उदाहरण उपयोग
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):
# लोकप्रिय गंतव्यों और उनकी जानकारी को पहले से लोड करें
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):
# पूर्व-लोड किए गए संदर्भ से गंतव्य जानकारी प्राप्त करें
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}."
# उदाहरण उपयोग
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']
# उदाहरण उपयोग
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 मेथड): यह मेथड वर्तमान योजना की कुल लागत की गणना करता है, जिसमें संभावित नया गंतव्य भी शामिल है।
स्पष्ट लक्ष्य (जैसे ग्राहक संतुष्टि को अधिकतम करना) के साथ योजना को बूटस्ट्रैप करके और योजना को परिष्कृत करने के लिए पुनरावृत्त करके, ट्रैवल एजेंट ग्राहक के लिए एक अनुकूलित और अनुकूलित यात्रा कार्यक्रम बना सकता है। यह तरीका सुनिश्चित करता है कि यात्रा योजना शुरू से ही ग्राहक की प्राथमिकताओं और बजट के अनुरूप हो और प्रत्येक पुनरावृत्ति के साथ बेहतर होती जाए।
बड़े भाषा मॉडल (LLMs) का उपयोग पुनः रैंकिंग और स्कोरिंग के लिए किया जा सकता है, जो पुनः प्राप्त दस्तावेजों या उत्पन्न प्रतिक्रियाओं की प्रासंगिकता और गुणवत्ता का मूल्यांकन करते हैं। यह कैसे काम करता है:
पुनः प्राप्ति: प्रारंभिक पुनः प्राप्ति चरण क्वेरी के आधार पर प्रत्याशी दस्तावेजों या प्रतिक्रियाओं का एक सेट लाता है।
पुनः रैंकिंग: LLM इन उम्मीदवारों का मूल्यांकन करता है और उनकी प्रासंगिकता और गुणवत्ता के आधार पर पुनः रैंक करता है। यह कदम यह सुनिश्चित करता है कि सबसे प्रासंगिक और उच्च गुणवत्ता वाली जानकारी पहले प्रस्तुत हो।
स्कोरिंग: LLM हर उम्मीदवार को उनके प्रासंगिकता और गुणवत्ता को दर्शाने वाले स्कोर सौंपता है। इससे उपयोगकर्ता के लिए सबसे अच्छा जवाब या दस्तावेज़ चुनने में मदद मिलती है।
पुनः रैंकिंग और स्कोरिंग के लिए LLMs का लाभ उठाकर, सिस्टम अधिक सटीक और संदर्भानुकूल जानकारी प्रदान कर सकता है, जिससे समग्र उपयोगकर्ता अनुभव बेहतर होता है।
यहाँ एक उदाहरण है कि ट्रैवल एजेंट उपयोगकर्ता की प्राथमिकताओं के आधार पर ट्रैवल गंतव्यों को पुनः रैंकिंग और स्कोरिंग करने के लिए Python में बड़े भाषा मॉडल (LLM) का उपयोग कैसे कर सकता है:
एक ट्रैवल एजेंट ग्राहक की प्राथमिकताओं के आधार पर सर्वश्रेष्ठ यात्रा गंतव्य सुझाना चाहता है। LLM गंतव्यों को पुनः रैंक और स्कोर करने में मदद करेगा ताकि सबसे प्रासंगिक विकल्प प्रस्तुत हो सकें।
यहाँ बताया गया है कि आप पिछले उदाहरण को Azure OpenAI Services का उपयोग करने के लिए कैसे अपडेट कर सकते हैं:
import requests
import json
class TravelAgent:
def __init__(self, destinations):
self.destinations = destinations
def get_recommendations(self, preferences, api_key, endpoint):
# Azure OpenAI के लिए एक प्रॉम्प्ट तैयार करें
prompt = self.generate_prompt(preferences)
# अनुरोध के लिए हेडर और पेलोड परिभाषित करें
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_key}'
}
payload = {
"prompt": prompt,
"max_tokens": 150,
"temperature": 0.7
}
# रैंकिंग और स्कोर किए गए गंतव्यों को प्राप्त करने के लिए Azure OpenAI API कॉल करें
response = requests.post(endpoint, headers=headers, json=payload)
response_data = response.json()
# सिफारिशों को निकालें और वापस करें
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
# उदाहरण उपयोग
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 सेवा के लिए एक प्रॉम्प्ट बनाता है और पुनः रैंकिंग और स्कोरिंग के लिए Azure OpenAI API को HTTP POST अनुरोध करता है।
प्रॉम्प्ट जनरेट करना (generate_prompt मेथड): यह मेथड उपयोगकर्ता की प्राथमिकताओं और गंतव्यों की सूची सहित Azure OpenAI के लिए एक प्रॉम्प्ट बनाता है। प्रॉम्प्ट मॉडल को निर्देश देता है कि वह दी गई प्राथमिकताओं के आधार पर गंतव्यों को पुनः रैंक और स्कोर करे।
API कॉल: requests लाइब्रेरी का उपयोग Azure OpenAI API एंडपॉइंट पर HTTP POST अनुरोध करने के लिए किया जाता है। प्रतिक्रिया में पुनः रैंकिंग और स्कोरिंग वाले गंतव्य होते हैं।
उदाहरण उपयोग: ट्रैवल एजेंट उपयोगकर्ता की प्राथमिकताओं (जैसे सैर की रुचि और विविध संस्कृति) को इकट्ठा करता है और Azure OpenAI सेवा का उपयोग करके पुनः रैंकिंग और स्कोरिंग वाले सिफारिश प्राप्त करता है।
सुनिश्चित करें कि your_azure_openai_api_key को अपनी वास्तविक Azure OpenAI API कुंजी से और https://your-endpoint.com/... को अपने Azure OpenAI परिनियोजन के वास्तविक एंडपॉइंट URL से बदलें।
LLM का उपयोग पुनः रैंकिंग और स्कोरिंग के लिए करके, ट्रैवल एजेंट ग्राहकों को अधिक व्यक्तिगत और प्रासंगिक यात्रा सिफारिशें प्रदान कर सकता है, जिससे उनका समग्र अनुभव बेहतर होता है।
Retrieval-Augmented Generation (RAG) AI एजेंट विकास में एक प्रॉम्प्टिंग तकनीक और एक उपकरण दोनों हो सकता है। दोनों के बीच अंतर को समझना आपको अपने परियोजनाओं में RAG का अधिक प्रभावी ढंग से उपयोग करने में मदद कर सकता है।
यह क्या है?
यह कैसे काम करता है:
ट्रैवल एजेंट में उदाहरण:
यह क्या है?
यह कैसे काम करता है:
ट्रैवल एजेंट में उदाहरण:
| पहलू | प्रॉम्प्टिंग तकनीक | उपकरण |
|---|---|---|
| मैनुअल vs स्वचालित | प्रत्येक क्वेरी के लिए मैनुअल प्रॉम्प्ट तैयार करना। | पुनः प्राप्ति और सृजन के लिए स्वचालित प्रक्रिया। |
| नियंत्रण | पुनः प्राप्ति प्रक्रिया पर अधिक नियंत्रण प्रदान करता है। | पुनः प्राप्ति और सृजन को सुव्यवस्थित और स्वचालित करता है। |
| लचीलापन | विशिष्ट आवश्यकताओं के अनुसार अनुकूलित प्रॉम्प्ट की अनुमति देता है। | बड़े पैमाने पर कार्यान्वयन के लिए अधिक प्रभावी। |
| जटिलता | प्रॉम्प्ट बनाने और संशोधित करने की जरूरत होती है। | AI एजेंट की संरचना में एकीकृत करना आसान। |
प्रॉम्प्टिंग तकनीक उदाहरण:
def search_museums_in_paris():
prompt = "Find top museums in Paris"
search_results = search_web(prompt)
return search_results
museums = search_museums_in_paris()
print("Top Museums in Paris:", museums)
उपकरण उदाहरण:
class Travel_Agent:
def __init__(self):
self.rag_tool = RAGTool()
def get_museums_in_paris(self):
user_input = "I want to visit museums in Paris."
response = self.rag_tool.retrieve_and_generate(user_input)
return response
travel_agent = Travel_Agent()
museums = travel_agent.get_museums_in_paris()
print("Top Museums in Paris:", museums)
प्रासंगिकता का मूल्यांकन AI एजेंट के प्रदर्शन का एक महत्वपूर्ण पहलू है। यह सुनिश्चित करता है कि एजेंट द्वारा प्राप्त और उत्पन्न जानकारी उपयोगकर्ता के लिए उपयुक्त, सटीक, और उपयोगी हो। आइए देखें कि AI एजेंट में प्रासंगिकता का मूल्यांकन कैसे करें, व्यावहारिक उदाहरण और तकनीकों सहित।
उदाहरण:
def relevance_score(item, query):
score = 0
if item['category'] in query['interests']:
score += 1
if item['price'] <= query['budget']:
score += 1
if item['location'] == query['destination']:
score += 1
return score
उदाहरण:
def filter_and_rank(items, query):
ranked_items = sorted(items, key=lambda item: relevance_score(item, query), reverse=True)
return ranked_items[:10] # शीर्ष 10 संबंधित आइटम लौटाएं
उदाहरण:
def process_query(query):
# उपयोगकर्ता के प्रश्न से मुख्य जानकारी निकालने के लिए NLP का उपयोग करें
processed_query = nlp(query)
return processed_query
उदाहरण:
def adjust_based_on_feedback(feedback, items):
for item in items:
if item['name'] in feedback['liked']:
item['relevance'] += 1
if item['name'] in feedback['disliked']:
item['relevance'] -= 1
return items
यहाँ एक व्यावहारिक उदाहरण है कि ट्रैवल एजेंट यात्रा सिफारिशों की प्रासंगिकता का मूल्यांकन कैसे कर सकता है:
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()
ranked_hotels = self.filter_and_rank(hotels, self.user_preferences)
itinerary = create_itinerary(flights, ranked_hotels, attractions)
return itinerary
def filter_and_rank(self, items, query):
ranked_items = sorted(items, key=lambda item: self.relevance_score(item, query), reverse=True)
return ranked_items[:10] # शीर्ष 10 संबंधित आइटम वापस करें
def relevance_score(self, item, query):
score = 0
if item['category'] in query['interests']:
score += 1
if item['price'] <= query['budget']:
score += 1
if item['location'] == query['destination']:
score += 1
return score
def adjust_based_on_feedback(self, feedback, items):
for item in items:
if item['name'] in feedback['liked']:
item['relevance'] += 1
if item['name'] in feedback['disliked']:
item['relevance'] -= 1
return items
# उदाहरण उपयोग
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)"]}
updated_items = travel_agent.adjust_based_on_feedback(feedback, itinerary['hotels'])
print("Updated Itinerary with Feedback:", updated_items)
मंशा के साथ खोज का मतलब है उपयोगकर्ता की क्वेरी के पीछे छुपे उद्देश्य या लक्ष्य को समझना और व्याख्या करना ताकि सबसे प्रासंगिक और उपयोगी जानकारी पुनः प्राप्त और उत्पन्न की जा सके। इस दृष्टिकोण में केवल कीवर्ड मिलान से परे जाकर उपयोगकर्ता की वास्तविक आवश्यकताओं और संदर्भ को समझा जाता है।
आइए ट्रैवल एजेंट को एक उदाहरण के रूप में लें और देखें कि मंशा के साथ खोज कैसे कार्यान्वित हो सकती है।
उपयोगकर्ता की प्राथमिकताएँ एकत्रित करना
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):
# संदर्भ समझने के लिए वर्तमान क्वेरी को उपयोगकर्ता इतिहास के साथ संयोजित करें
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):
# सूचना संबंधी इरादे के लिए उदाहरण खोज तर्क
results = search_web(f"best {preferences['interests']} in {preferences['destination']}")
return results
def search_navigation(query):
# नेविगेशनल इरादे के लिए उदाहरण खोज तर्क
results = search_web(query)
return results
def search_transaction(query, preferences):
# लेन-देन संबंधी इरादे के लिए उदाहरण खोज तर्क
results = search_web(f"book {query} to {preferences['destination']}")
return results
def personalize_results(results, user_history):
# उदाहरण वैयक्तिकीकरण तर्क
personalized = [result for result in results if result not in user_history]
return personalized[:10] # शीर्ष 10 वैयक्तिकृत परिणाम वापस करें
उदाहरण उपयोग
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)
कोड जनरेटिंग एजेंट AI मॉडल का उपयोग कोड लिखने और चलाने के लिए करते हैं, जटिल समस्याओं को हल करते हैं और कार्यों को स्वचालित करते हैं।
कोड जनरेटिंग एजेंट जनरेटिव AI मॉडल का उपयोग कोड लिखने और चलाने के लिए करते हैं। ये एजेंट जटिल समस्याओं को हल कर सकते हैं, कार्यों को स्वचालित कर सकते हैं, और विभिन्न प्रोग्रामिंग भाषाओं में कोड जनरेट और रन करके मूल्यवान अंतर्दृष्टि प्रदान कर सकते हैं।
मान लें कि आप एक कोड जनरेटिंग एजेंट डिजाइन कर रहे हैं। यह इस प्रकार काम कर सकता है:
इस उदाहरण में, हम एक कोड जनरेटिंग एजेंट, यात्रा एजेंट, डिज़ाइन करेंगे जो उपयोगकर्ताओं की यात्रा योजना में सहायता करेगा कोड जनरेट और चलाकर। यह एजेंट उड़ान विकल्प प्राप्त करना, परिणाम फ़िल्टर करना, और जेनरेटिव AI के उपयोग से एक यात्रा कार्यक्रम संकलित करना जैसे कार्य कर सकता है।
उपयोगकर्ता की प्राथमिकताएं एकत्र करना
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):
# उदाहरण: उपयोगकर्ता की प्राथमिकताओं के आधार पर उड़ानों की खोज करने के लिए कोड生成 करें
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):
# उदाहरण: होटलों की खोज करने के लिए कोड生成 करें
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):
# 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):
# उपयोगकर्ता प्रतिक्रिया के आधार पर पसंदीदा समायोजित करें
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)
# अपडेट किए गए पसंदीदा के साथ कोड पुनः उत्पन्न करें और निष्पादित करें
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):
# उपयोगकर्ता प्रतिक्रिया के आधार पर प्राथमिकताएं समायोजित करें
if "liked" in feedback:
preferences["favorites"] = feedback["liked"]
if "disliked" in feedback:
preferences["avoid"] = feedback["disliked"]
# अन्य संबंधित प्राथमिकताओं को समायोजित करने के लिए स्कीमा के आधार पर तर्क
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):
# स्कीमा और प्रतिक्रिया के आधार पर प्राथमिकताओं को समायोजित करने के लिए कस्टम लॉजिक
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):
# अपडेट की गई प्राथमिकताओं के आधार पर फ्लाइट डेटा प्राप्त करने के लिए कोड उत्पन्न करें
return f"fetch_flights(preferences={preferences})"
def generate_code_to_fetch_hotels(preferences):
# अपडेट की गई प्राथमिकताओं के आधार पर होटल डेटा प्राप्त करने के लिए कोड उत्पन्न करें
return f"fetch_hotels(preferences={preferences})"
def execute_code(code):
# कोड के निष्पादन का अनुकरण करें और नकली डेटा वापस करें
return {"data": f"Executed: {code}"}
def generate_itinerary(flights, hotels, attractions):
# फ्लाइट, होटल और आकर्षण के आधार पर यात्रा कार्यक्रम उत्पन्न करें
return {"flights": flights, "hotels": hotels, "attractions": attractions}
# उदाहरण स्कीमा
schema = {
"favorites": {"positive_adjustment": "increase", "negative_adjustment": "decrease", "default": "neutral"},
"avoid": {"positive_adjustment": "decrease", "negative_adjustment": "increase", "default": "neutral"}
}
# उदाहरण उपयोग
preferences = {"favorites": "sightseeing", "avoid": "crowded places"}
feedback = {"liked": ["Louvre Museum"], "disliked": ["Eiffel Tower (too crowded)"]}
updated_preferences = adjust_based_on_feedback(feedback, preferences, schema)
# अपडेट की गई प्राथमिकताओं के साथ कोड पुनः उत्पन्न करें और निष्पादित करें
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_feedback मेथड): यह मेथड उपयोगकर्ता की प्रतिक्रिया और स्कीमा के आधार पर प्राथमिकताओं को समायोजित करता है।adjust_based_on_environment मेथड): यह मेथड स्कीमा और प्रतिक्रिया के आधार पर समायोजन को अनुकूलित करता है।सिस्टम को पर्यावरण-आधारित और स्कीमा के आधार पर तर्कशील बनाकर, यह अधिक सटीक और प्रासंगिक क्वेरियाँ जनरेट कर सकता है, जिससे बेहतर यात्रा सिफारिशें और अधिक व्यक्तिगत उपयोगकर्ता अनुभव मिलता है।
SQL (Structured Query Language) डेटाबेस के साथ संवाद करने का एक शक्तिशाली उपकरण है। जब इसे Retrieval-Augmented Generation (RAG) दृष्टिकोण के हिस्से के रूप में उपयोग किया जाता है, तो SQL डेटाबेस से प्रासंगिक डेटा पुनः प्राप्त कर सकता है जिससे AI एजेंटों में प्रतिक्रियाओं या क्रियाओं का सृजन किया जा सके। आइए देखें कि यात्रा एजेंट के संदर्भ में SQL को RAG तकनीक के रूप में कैसे उपयोग किया जा सकता है।
उदाहरण: डेटा विश्लेषण एजेंट:
उपयोगकर्ता प्राथमिकताएं एकत्र करना
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';
Retrieval-Augmented Generation (RAG) तकनीक के हिस्से के रूप में SQL का उपयोग करके, यात्रा एजेंट जैसे AI एजेंट प्रासंगिक डेटा गतिशील रूप से पुनर्प्राप्त और उपयोग कर सकते हैं ताकि सटीक और व्यक्तिगत सिफारिशें प्रदान की जा सकें।
तो मेटाकॉग्निशन के एक कार्यान्वयन को प्रदर्शित करने के लिए, आइए एक साधारण एजेंट बनाएं जो समस्या हल करते समय अपने निर्णय प्रक्रिया पर प्रतिबिंबित करता है। इस उदाहरण के लिए, हम एक सिस्टम बनाएंगे जहां एजेंट होटल के चयन को अनुकूलित करने की कोशिश करता है, लेकिन फिर अपनी तर्कशीलता का मूल्यांकन करता है और गलतियों या उपयुक्त चयन न करने पर अपनी रणनीति समायोजित करता है।
हम इसे एक बेसिक उदाहरण के रूप में सिम्युलेट करेंगे जहाँ एजेंट कीमत और गुणवत्ता के संयोजन पर आधारित होटल चुनता है, लेकिन यह अपने निर्णयों पर “प्रतिबिंबित” करता है और उसके अनुसार समायोजित करता है।
यहाँ एक उदाहरण है:
class HotelRecommendationAgent:
def __init__(self):
self.previous_choices = [] # पहले चुने गए होटलों को संग्रहीत करता है
self.corrected_choices = [] # सुधारी गई पसंदों को संग्रहीत करता है
self.recommendation_strategies = ['cheapest', 'highest_quality'] # उपलब्ध रणनीतियाँ
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]
# मान लें कि हमारे पास कुछ उपयोगकर्ता प्रतिक्रिया है जो बताती है कि पिछली पसंद अच्छी थी या नहीं
user_feedback = self.get_user_feedback(last_choice)
if user_feedback == "bad":
# अगर पिछली पसंद असंतोषजनक थी तो रणनीति समायोजित करें
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"
# होटलों की एक सूची का अनुकरण करें (मूल्य और गुणवत्ता)
hotels = [
{'name': 'Budget Inn', 'price': 80, 'quality': 6},
{'name': 'Comfort Suites', 'price': 120, 'quality': 8},
{'name': 'Luxury Stay', 'price': 200, 'quality': 9}
]
# एक एजेंट बनाएं
agent = HotelRecommendationAgent()
# चरण 1: एजेंट "सबसे सस्ता" रणनीति का उपयोग करके एक होटल की सिफारिश करता है
recommended_hotel = agent.recommend_hotel(hotels, 'cheapest')
print(f"Recommended hotel (cheapest): {recommended_hotel['name']}")
# चरण 2: एजेंट अपनी पसंद पर विचार करता है और आवश्यक होने पर रणनीति समायोजित करता है
reflection_result = agent.reflect_on_choice()
print(reflection_result)
# चरण 3: एजेंट फिर से सिफारिश करता है, इस बार समायोजित रणनीति का उपयोग करते हुए
adjusted_recommendation = agent.recommend_hotel(hotels, 'highest_quality')
print(f"Adjusted hotel recommendation (highest_quality): {adjusted_recommendation['name']}")
मुख्य बात यह है कि एजेंट में क्षमता है:
यह मेटाकॉग्निशन का एक सरल रूप है जहाँ सिस्टम आंतरिक प्रतिक्रिया के आधार पर अपनी तर्क प्रक्रिया को समायोजित करने में सक्षम है।
मेटाकॉग्निशन एक शक्तिशाली उपकरण है जो AI एजेंटों की क्षमताओं को महत्वपूर्ण रूप से बढ़ा सकता है। मेटाकॉग्निटिव प्रक्रियाओं को शामिल करके, आप एजेंट डिजाइन कर सकते हैं जो अधिक बुद्धिमान, अनुकूलनीय, और कुशल हों। अतिरिक्त संसाधनों का उपयोग करके AI एजेंटों में मेटाकॉग्निशन की रोमांचक दुनिया की खोज जारी रखें।
अन्य शिक्षार्थियों से मिलने, कार्यालय समय में भाग लेने और अपने AI एजेंट प्रश्नों के उत्तर पाने के लिए Microsoft Foundry Discord में शामिल हों।
अस्वीकरण: इस दस्तावेज़ का अनुवाद AI अनुवाद सेवा Co-op Translator का उपयोग करके किया गया है। जबकि हम सटीकता के लिए प्रयास करते हैं, कृपया ध्यान दें कि स्वचालित अनुवादों में त्रुटियाँ या अशुद्धियाँ हो सकती हैं। मूल दस्तावेज़ अपनी मूल भाषा में ही प्रामाणिक स्रोत माना जाना चाहिए। महत्वपूर्ण जानकारी के लिए, पेशेवर मानव अनुवाद की सिफारिश की जाती है। इस अनुवाद के उपयोग से उत्पन्न किसी भी गलतफहमी या गलत व्याख्या के लिए हम उत्तरदायी नहीं हैं।