Spaces:
Sleeping
Sleeping
import openai | |
# Set your OpenAI API key | |
openai.api_key = "your-openai-api-key" | |
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) | |