dylanmeca's picture
Create app.py
676f49f
raw
history blame
748 Bytes
import openai
import gradio as gr
# Getting responses using the OpenAI API
def answer_chatgpt(api_key, message):
# OPENAI API KEY
openai.api_key = api_key
prompt = (f"You are GPT-3 and answer my following message: {message}")
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=1024
)
# Displaying the answer on the screen
answer = response["choices"][0]["text"]
return answer
# User input
chatbot = gr.Interface(
fn=answer_chatgpt,
inputs=["text", "text"],
outputs="text",
title="πŸ€– ChatGPT-Python 🐍",
description="ChatGPT-Python is a software that allows you to talk to GPT-3 with a web interface using the openai api"
)
chatbot.launch()