File size: 773 Bytes
4a56e7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import openai
import gradio as gr

# Set your OpenAI API key
openai.api_key = "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"

# Define the chatbot function
def chatbot(input_text):
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[{"role": "user", "content": input_text}]
    )
    return response['choices'][0]['message']['content']

# Create a Gradio interface
interface = gr.Interface(
    fn=chatbot,
    inputs="text",
    outputs="text",
    title="ChatGPT Clone",
    description="A simple chatbot powered by OpenAI's GPT-3.5 Turbo."
)

# Launch the interface
interface.launch()