einfachalf commited on
Commit
a70a29d
·
1 Parent(s): 17305a7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import gradio as gr
3
+ import openai
4
+
5
+ openai.api_type = "azure"
6
+ openai.api_base = "https://hrangaopenaillm.openai.azure.com"
7
+ openai.api_version = "2023-03-15-preview"
8
+ openai.api_key = "e951b48da7c548e18af601a15cb6aefa"
9
+
10
+
11
+ def gptresponse(message, history):
12
+ system_prompt = "You are OpenGPT chatbot developed by Achyuth to help people. Your developer is 13 years old and a young programmer."
13
+
14
+ messages = [{"role":"system","content":system_prompt}]
15
+ for human, assistant in history:
16
+ messages.append({"role":"user", "content":human})
17
+ messages.append({"role":"assistant", "content":assistant})
18
+
19
+ if message != '':
20
+ messages.append({"role":"user", "content":message})
21
+
22
+ response = openai.ChatCompletion.create(engine = "NGA_AI_ASSISTANT",
23
+ messages = messages,
24
+ temperature =0.7,
25
+ max_tokens = 4000,
26
+ top_p = 0.95,
27
+ frequency_penalty = 0,
28
+ presence_penalty = 0,
29
+ stop = None)
30
+
31
+ return response["choices"][0]["message"]["content"]
32
+
33
+ title = "NeonAI Chat✨"
34
+
35
+ gr.HTML(title)
36
+
37
+ gr.ChatInterface(gptresponse, title=title).launch()