ChatGPT-Clone / app.py
mrprycep069's picture
Update on the API-key
8fcc6ac
raw
history blame
1.03 kB
# -*- coding: utf-8 -*-
"""ChatGPT Clone & Text to Image Generator.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1OoArwT6lYDyxjBUGRznDfFv1xQF8szJV
"""
# Commented out IPython magic to ensure Python compatibility.
import openai
import gradio
from dotenv import load_dotenv
import os
def configure():
load_dotenv()
# %pdb on
openai.api_key = os.getenv('api_key')
menulist = [{"role": "system", "content": "You are ChatGPT Clone AI Robot"}]
def ChatGPTclone(input):
configure()
menulist.append({"role": "user", "content": input})
response = openai.ChatCompletion.create(
model = "gpt-3.5-turbo-16k-0613",
messages = menulist
)
reply = response['choices'][0]['message']['content']
menulist.append({"role": "user", "content": reply})
return reply
def application():
app = gradio.Interface(fn=ChatGPTclone, inputs="text", outputs="text", title="ChatGPT Clone")
return app.launch()
application()