ग्राहक को उत्तर जनरेट करना

OpenAI API के साथ मल्टी-मॉडल सिस्टम

James Chapman

Curriculum Manager, DataCamp

रीमाइंडर

print(corrected_text)

सुधारा हुआ टेक्स्ट (हाइलाइटेड)

OpenAI API के साथ मल्टी-मॉडल सिस्टम

केस स्टडी प्लान

$$

  • ग्राहक संदेश मॉडरेशन

$$

  • उत्तर जनरेट करना

$$

  • उत्तर मॉडरेशन

केस स्टडी के चरण

OpenAI API के साथ मल्टी-मॉडल सिस्टम

ग्राहक संदेश मॉडरेशन

from openai import OpenAI

client = OpenAI(api_key="ENTER YOUR KEY HERE")

response = client.moderations.create( input=corrected_text )
# Extract scores and convert to dictionary scores = response.results[0].category_scores.model_dump()
OpenAI API के साथ मल्टी-मॉडल सिस्टम

ग्राहक संदेश मॉडरेशन

print(scores)
{'harassment': 1.0383088920207229e-05,
  ...
 'hate': 6.848756015642721e-07,
  ...
 'violence': 6.475193367805332e-05,
 ...}
OpenAI API के साथ मल्टी-मॉडल सिस्टम

ग्राहक संदेश मॉडरेशन

# Extract violence score
violence_score = scores['violence']

# Check if violence score is above 0.7 if violence_score > 0.7: print("Content flagged for violence!") else: print("Content is safe from violence.")
Content is safe from violence.
OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर जनरेट करना

print(FAQs)
Q: How can I upgrade my subscription?
A: You can upgrade your plan anytime in your account settings under 'Billing'. 
...

$$

print(content_overview)
Content Type: Career Track // Title: Associate AI Engineer for Developers // 
...
OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर जनरेट करना

रोल-निर्दिष्ट प्रॉम्प्ट

OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर जनरेट करना

प्रॉम्प्ट को संसाधन पास करना

OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर जनरेट करना

पूरा प्रॉम्प्ट

OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर जनरेट करना

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": instruction_prompt},
        {"role": "user", "content": corrected_text}
    ],
    max_completion_tokens=400
)
OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर जनरेट करना

# Extract chatbot response
chatbot_reply = response.choices[0].message.content

चैटबॉट उत्तर हाइलाइटेड

OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर मॉडरेशन

response = client.moderations.create(
    input=chatbot_reply
)

scores = response.results[0].category_scores.model_dump()
OpenAI API के साथ मल्टी-मॉडल सिस्टम

उत्तर मॉडरेशन

# Check if any scores exceed 0.7
if any(score > 0.7 for score in scores.values()):
    print("AI Response flagged for moderation!")
    chatbot_reply = """I'm sorry, but I can't provide a response to that request.
    Please contact [email protected] for further assistance."""
else:
    print("AI Response is safe.")
AI Response is safe.
OpenAI API के साथ मल्टी-मॉडल सिस्टम

रीकैप

चेकमार्क के साथ केस स्टडी चरण

OpenAI API के साथ मल्टी-मॉडल सिस्टम

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

OpenAI API के साथ मल्टी-मॉडल सिस्टम

Preparing Video For Download...