Files changed (1) hide show
  1. app.py +0 -50
app.py DELETED
@@ -1,50 +0,0 @@
1
- import os
2
- import openai
3
- import gradio as gr
4
-
5
- openai.api_key = "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"
6
-
7
- start_sequence = "\nAI:"
8
- restart_sequence = "\nHuman: "
9
-
10
- prompt = "The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.\n\nHuman: Hello, who are you?\nAI: I am an AI created by OpenAI. How can I help you today?\nHuman: "
11
-
12
- def openai_create(prompt):
13
-
14
- response = openai.Completion.create(
15
- model="text-davinci-003",
16
- prompt=prompt,
17
- temperature=0.9,
18
- max_tokens=150,
19
- top_p=1,
20
- frequency_penalty=0,
21
- presence_penalty=0.6,
22
- stop=[" Human:", " AI:"]
23
- )
24
-
25
- return response.choices[0].text
26
-
27
-
28
- def chatgpt_clone(input, history):
29
- history = history or []
30
- s = list(sum(history, ()))
31
- s.append(input)
32
- inp = ' '.join(s)
33
- output = openai_create(inp)
34
- history.append((input, output))
35
- return history, history
36
-
37
-
38
- block = gr.Blocks()
39
-
40
-
41
- with block:
42
- gr.Markdown("""<h1><center>Ask Something With TheoAI</center></h1>
43
- """)
44
- chatbot = gr.Chatbot()
45
- message = gr.Textbox(placeholder=prompt)
46
- state = gr.State()
47
- submit = gr.Button("SEND")
48
- submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot, state])
49
-
50
- block.launch()