Spaces:
Running
on
Zero
Running
on
Zero
Werner Geyer
commited on
Commit
•
405b12f
1
Parent(s):
68e345d
Initial version of gradio demo to build upon
Browse files- .gitignore +1 -0
- gg-gradio-demo.py +87 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.venv
|
gg-gradio-demo.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Content for each link
|
4 |
+
def update_content(link):
|
5 |
+
if link == "Link 1":
|
6 |
+
return gr.update(value="<div class='large-title'>Test Case 1</div>"), gr.update(label="Updated Label for Link 1", value="New Content for Link 1"), None, None, None
|
7 |
+
elif link == "Link 2":
|
8 |
+
return gr.update(value="<div class='large-title'>Test Case 2</div>"), gr.update(label="Updated Label for Link 2", value="New Content for Link 2"), None, None, None
|
9 |
+
else:
|
10 |
+
return gr.update(label="Updated Label for Link 3", value="New Content for Link 3"), None, None, None
|
11 |
+
|
12 |
+
|
13 |
+
def submit_action(editable_text):
|
14 |
+
return f"Submitted: {editable_text}"
|
15 |
+
|
16 |
+
with gr.Blocks(css="""
|
17 |
+
.link-button {
|
18 |
+
background-color: white;
|
19 |
+
color: blue;
|
20 |
+
text-decoration: underline;
|
21 |
+
border: none;
|
22 |
+
cursor: pointer;
|
23 |
+
padding: 0;
|
24 |
+
font-size: 16px;
|
25 |
+
}
|
26 |
+
.link-button:focus {
|
27 |
+
outline: none;
|
28 |
+
}
|
29 |
+
.link-container {
|
30 |
+
display: flex;
|
31 |
+
flex-direction: column;
|
32 |
+
gap: 10px;
|
33 |
+
}
|
34 |
+
.section-title {
|
35 |
+
font-weight: bold;
|
36 |
+
margin-bottom: 10px;
|
37 |
+
font-size: 16px;
|
38 |
+
}
|
39 |
+
.large-title {
|
40 |
+
font-size: 24px; /* Adjust font size for large title */
|
41 |
+
font-weight: bold;
|
42 |
+
text-align: center;
|
43 |
+
margin-bottom: 20px;
|
44 |
+
}
|
45 |
+
""") as demo:
|
46 |
+
with gr.Row():
|
47 |
+
with gr.Column(scale=3, elem_classes="link-container"):
|
48 |
+
|
49 |
+
title_display_left = gr.Markdown("<div class='large-title'>Test Cases</div>") # Dynamic title
|
50 |
+
|
51 |
+
|
52 |
+
# Separate Buttons styled as links inside the Column
|
53 |
+
link1 = gr.Button("Link 1", elem_classes="link-button")
|
54 |
+
link2 = gr.Button("Link 2", elem_classes="link-button")
|
55 |
+
link3 = gr.Button("Link 3", elem_classes="link-button")
|
56 |
+
|
57 |
+
with gr.Column(scale=7):
|
58 |
+
title_display = gr.HTML("<div class='large-title'>Initial Title</div>") # Dynamic title
|
59 |
+
|
60 |
+
|
61 |
+
# Top Section
|
62 |
+
gr.HTML("<div class='section-title'>Evaluation Criteria</div>")
|
63 |
+
|
64 |
+
tb_criteria = gr.Textbox(label="", lines=3, interactive=False)
|
65 |
+
|
66 |
+
# Middle Section
|
67 |
+
gr.Markdown("<div class='section-title'>Test Data</div>")
|
68 |
+
tb_context = gr.Textbox(label="Context", lines=3, interactive=True)
|
69 |
+
tb_user_message = gr.Textbox(label="User Message", lines=3, interactive=True)
|
70 |
+
tb_assistant_message = gr.Textbox(label="Assistant Message", lines=3, interactive=True)
|
71 |
+
|
72 |
+
submit_button = gr.Button("Evaluate")
|
73 |
+
|
74 |
+
# Bottom Section (for Submit Button and Result)
|
75 |
+
gr.Markdown("<div class='section-title'>Results</div>")
|
76 |
+
|
77 |
+
result_display = gr.Textbox(label="Result:", interactive=False)
|
78 |
+
|
79 |
+
# Event handling: Each link updates the right column content separately
|
80 |
+
link1.click(fn=lambda: update_content("Link 1"), inputs=[], outputs=[title_display, tb_criteria, tb_context, tb_user_message, tb_assistant_message])
|
81 |
+
link2.click(fn=lambda: update_content("Link 2"), inputs=[], outputs=[title_display, tb_criteria, tb_context, tb_user_message, tb_assistant_message])
|
82 |
+
link3.click(fn=lambda: update_content("Link 3"), inputs=[], outputs=[title_display, tb_criteria, tb_context, tb_user_message, tb_assistant_message])
|
83 |
+
|
84 |
+
# Action for submit button
|
85 |
+
submit_button.click(fn=submit_action, inputs=[tb_criteria], outputs=[result_display])
|
86 |
+
|
87 |
+
demo.launch()
|