फंक्शन-कॉलिंग टूल्स: फंक्शन परिभाषित करना

OpenAI Responses API के साथ काम करना

James Chapman

AI Curriculum Manager, DataCamp

फंक्शन-कॉलिंग टूल्स

 

  • फंक्शन-कॉलिंग टूल्स: LLMs द्वारा प्रोग्राम्ड फंक्शन कॉल करना
    • लगभग किसी भी काम के लिए बनाए जा सकते हैं!
  • convert_currency()
    • amount: धनराशि
    • from_currency: मूल मुद्रा
    • to_currency: लक्ष्य मुद्रा

frankfurter.png

1 https://frankfurter.dev/
OpenAI Responses API के साथ काम करना

फंक्शन-कॉलिंग टूल्स

fct1.jpg

OpenAI Responses API के साथ काम करना

फंक्शन-कॉलिंग टूल्स

fct2.jpg

OpenAI Responses API के साथ काम करना

फंक्शन-कॉलिंग टूल्स

fct3.jpg

OpenAI Responses API के साथ काम करना

फंक्शन-कॉलिंग टूल्स

fct4.jpg

OpenAI Responses API के साथ काम करना

फंक्शन-कॉलिंग टूल्स

fct5.jpg

OpenAI Responses API के साथ काम करना

ฟंक्शन-कॉलिंग टूल्स

fct6.jpg

OpenAI Responses API के साथ काम करना
def convert_currency(amount, from_currency, to_currency):

url = f"https://api.frankfurter.dev/v1/latest?base={from_currency}&symbols={to_currency}"
try: response = requests.get(url) response.raise_for_status()
data = response.json() rate = data['rates'].get(to_currency)
if rate is None: return f"Could not find exchange rate for {from_currency} to {to_currency}"
converted_amount = amount * rate return f"{amount} {from_currency} = {converted_amount:.2f} {to_currency} (Rate: {rate})"
except requests.exceptions.RequestException as e: return f"Error converting currency: {str(e)}"
OpenAI Responses API के साथ काम करना

हमारा फंक्शन

print(convert_currency(100, "USD", "EUR"))
100 USD = 86.62 EUR (Rate: 0.86625)
OpenAI Responses API के साथ काम करना

अभ्यास करते हैं!

OpenAI Responses API के साथ काम करना

Preparing Video For Download...