Spaces:
Runtime error
Runtime error
import gradio as gr | |
import openai | |
# Set up your OpenAI API key for GPT-3.5 | |
openai.api_key = "YOUR_API_KEY_HERE" | |
# Function to interact with GPT-3.5 | |
def interact_with_gpt(prompt): | |
response = openai.Completion.create( | |
engine="text-davinci-003", | |
prompt=prompt, | |
max_tokens=100 | |
) | |
return response.choices[0].text.strip() | |
# Create Gradio interface | |
input_text = gr.inputs.Textbox(label="Input Text") | |
output_text = gr.outputs.Textbox(label="Output Text") | |
title = "GPT-3.5 Chatbot" | |
description = "Enter your text, and GPT-3.5 will respond." | |
gr.Interface(interact_with_gpt, input_text, output_text, title=title, description=description).launch() | |