akhilhsingh's picture
Update app.py
11557a7 verified
raw
history blame
820 Bytes
import gradio as gr
import openai
# Replace the placeholder text with your actual OpenAI API key
openai.api_key = "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"
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()