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