File size: 484 Bytes
2f43169
 
 
a284e58
2f43169
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import openai

# Set your OpenAI API key
openai.api_key = "c496d9094ba54ddb9d66eeeb35a6196f"

def call_openai(prompt, max_tokens=150):
    response = openai.Completion.create(
        model="text-davinci-003",
        prompt=prompt,
        max_tokens=max_tokens
    )
    return response['choices'][0]['text']

def get_ai_explanation(question):
    prompt = f"Explain the following machine learning concept in simple terms: {question}"
    return call_openai(prompt, max_tokens=150)