File size: 1,736 Bytes
ad3c865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- 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
"""

!pip install gradio

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch()





!pip install -Uqq ipdb

import ipdb

# Commented out IPython magic to ensure Python compatibility.
# %pdb on

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch()

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch()

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch(share=True)

!pip install openai

# Commented out IPython magic to ensure Python compatibility.
import openai
import gradio
import ipdb

# %pdb on
openai.api_key = "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"

menulist = [{"role": "system", "content": "You are ChatGPT Clone AI Robot"}]

def ChatGPTclone(input):
    menulist.append({"role": "user", "content": input})
    response = openai.ChatCompletion.create(
       model = "gpt-3.5-turbo",
       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(share=True)

application()