MrAli813 commited on
Commit
78e2d06
·
1 Parent(s): 332f303

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+
4
+ openai.api_key = "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"
5
+
6
+ def predict(message, history):
7
+ history_openai_format = []
8
+ for human, assistant in history:
9
+ history_openai_format.append({"role": "user", "content": human })
10
+ history_openai_format.append({"role": "assistant", "content":assistant})
11
+ history_openai_format.append({"role": "user", "content": message})
12
+
13
+ response = openai.ChatCompletion.create(
14
+ model='gpt-3.5-turbo',
15
+ messages= history_openai_format,
16
+ temperature=1.0,
17
+ stream=True
18
+ )
19
+
20
+ partial_message = ""
21
+ for chunk in response:
22
+ if len(chunk['choices'][0]['delta']) != 0:
23
+ partial_message = partial_message + chunk['choices'][0]['delta']['content']
24
+ yield partial_message
25
+
26
+ A1 = gr.ChatInterface(predict,
27
+ title="PeachTalk+",
28
+ description="An AI Powered Chatbot with Computer Vision and Image Generation Capabilities Currently Under Development By Peach State Innovation and Technology. Ask Me About Question About Anything...From Georgia and Beyond...And I'll Give You An Answer!",
29
+ theme= gr.themes.Glass(primary_hue="amber", neutral_hue="lime"),
30
+ retry_btn=None,
31
+ clear_btn="Clear")
32
+
33
+ A2 = gr.load(
34
+ "huggingface/google/vit-base-patch16-224",
35
+ title="Upon Further Review - AI Vision and Identity Technology",
36
+ theme= gr.themes.Glass(primary_hue="amber", neutral_hue="lime"))
37
+
38
+ A3 = gr.load("huggingface/google/vit-base-patch16-224")
39
+
40
+ pcp = gr.TabbedInterface([A1, A2], ["Chat", "Vision"], theme= gr.themes.Glass(primary_hue="amber", neutral_hue="lime"))
41
+ pcp.queue().launch()