File size: 806 Bytes
229346b
 
3f3ca2e
229346b
 
9e8c98b
229346b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11557a7
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
26
27
import gradio as gr
import openai
import os

# Replace the placeholder text with your actual OpenAI API key
openai.api_key = os.environ.get('OPENAPI_KEY')

def chat_with_gpt3(prompt):
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": prompt},
        ],
    )
    return response.choices[0].message["content"]

interface = gr.Interface(
    fn=chat_with_gpt3,
    inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
    outputs="text",
    title="Akhil's Chatbot (powered by GPT-3.5 Turbo)",
    description="This is a chatbot using OpenAI's GPT-3.5 Turbo. Ask it anything!",
)

if __name__ == "__main__":
    interface.launch()