File size: 1,080 Bytes
ad3c865
 
 
 
 
 
 
 
 
 
 
 
 
8fcc6ac
 
 
 
3ced757
 
 
ad3c865
 
3ced757
ad3c865
 
 
 
8fcc6ac
ad3c865
 
a92bc3d
ad3c865
 
 
 
 
 
 
 
 
a221d30
ad3c865
8fcc6ac
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- 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
import os



def open_file(filepath):
    with open(filepath, 'r' encoding='utf-8') as infile:
        return infile.read()

# %pdb on
openai.api_key = open_file('openaiapikey.text')

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()