Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
CSS = """.contain { display: flex; flex-direction: column; }
|
6 |
+
.gradio-container { height: 100vh !important; }
|
7 |
+
#component-0 { height: 100%; }
|
8 |
+
#chatbot { flex-grow: 1; overflow: auto;}
|
9 |
+
#chatbot .avatar-container {margin-right: 14px;}
|
10 |
+
#chatbot .avatar-image {padding: 0;}"""
|
11 |
+
|
12 |
+
saved_examples = []
|
13 |
+
try:
|
14 |
+
for line in open("upvote_log.jsonl").readlines():
|
15 |
+
j = json.loads(line)
|
16 |
+
entry = []
|
17 |
+
saved_examples.append(j)
|
18 |
+
except:
|
19 |
+
saved_examples = [
|
20 |
+
[
|
21 |
+
{"role": "user", "content": "Hi, I need help with my marketing campaign."},
|
22 |
+
],
|
23 |
+
]
|
24 |
+
|
25 |
+
|
26 |
+
def update_chatbot(index):
|
27 |
+
return saved_examples[index]
|
28 |
+
|
29 |
+
|
30 |
+
with gr.Blocks(css=CSS, theme="gradio/monochrome") as demo:
|
31 |
+
gr.Markdown(
|
32 |
+
"## *VariantX* Asset Performance Optimization & Insights for Performance Marketing\n"
|
33 |
+
)
|
34 |
+
options = gr.Dropdown(
|
35 |
+
choices=[i for i in range(len(saved_examples))],
|
36 |
+
value=0,
|
37 |
+
)
|
38 |
+
|
39 |
+
chat = gr.Chatbot(
|
40 |
+
type="messages",
|
41 |
+
bubble_full_width=False,
|
42 |
+
value=saved_examples[0],
|
43 |
+
elem_id="chatbot",
|
44 |
+
avatar_images=(
|
45 |
+
None,
|
46 |
+
"https://cdn2.iconfinder.com/data/icons/adobe-square-2/243/adobe-square-1024.png",
|
47 |
+
),
|
48 |
+
)
|
49 |
+
|
50 |
+
options.change(
|
51 |
+
update_chatbot,
|
52 |
+
inputs=[options],
|
53 |
+
outputs=[chat],
|
54 |
+
)
|
55 |
+
|
56 |
+
if __name__ == "__main__":
|
57 |
+
demo.launch(server_name="0.0.0.0", ssl_verify=False)
|