Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
@@ -32,34 +32,36 @@ def generate_text(prompt, max_length=150):
|
|
32 |
return generated_text
|
33 |
|
34 |
# Custom CSS for the UI
|
35 |
-
background_image_path = '
|
36 |
custom_css = f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
.message.pending {{
|
38 |
-
background: rgba(168, 196, 214, 0.
|
39 |
}}
|
40 |
-
/* Response message */
|
41 |
.message.bot.svelte-1s78gfg.message-bubble-border {{
|
42 |
-
border-color: rgba(38, 107, 153, 0.
|
43 |
background: rgba(255, 255, 255, 0.1);
|
44 |
}}
|
45 |
-
/* User message */
|
46 |
.message.user.svelte-1s78gfg.message-bubble-border {{
|
47 |
-
background: rgba(157, 221, 249, 0.
|
48 |
-
border-color: rgba(157, 221, 249, 0.
|
49 |
}}
|
|
|
50 |
/* For both user and response message as per the document */
|
51 |
span.md.svelte-8tpqd2.chatbot.prose p {{
|
52 |
color: #266B99;
|
53 |
}}
|
54 |
-
|
55 |
-
.gradio-container {{
|
56 |
-
color: white; /* Light text color */
|
57 |
-
background-image: url('{background_image_path}'); /* Add background image */
|
58 |
-
background-size: cover; /* Cover the entire container */
|
59 |
-
background-position: center; /* Center the image */
|
60 |
-
background-repeat: no-repeat; /* Do not repeat the image */
|
61 |
-
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent dark background */
|
62 |
-
}}
|
63 |
/* RED (Hex: #DB1616) for action buttons and links only */
|
64 |
.clear-btn {{
|
65 |
background: #DB1616;
|
@@ -87,35 +89,39 @@ span.md.svelte-8tpqd2.chatbot.prose p {{
|
|
87 |
content: url('file=Komal-patra/EU_AI_ACT/orcawise image.png');
|
88 |
margin-right: 8px;
|
89 |
}}
|
|
|
90 |
/* Enable scrolling for the chatbot messages */
|
91 |
.chatbot .messages {{
|
92 |
max-height: 500px; /* Adjust as needed */
|
93 |
overflow-y: auto;
|
94 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
"""
|
96 |
|
97 |
# Gradio interface setup
|
98 |
with gr.Blocks(css=custom_css) as demo:
|
99 |
-
gr.Markdown("<h1>Ask a question about the EU AI Act</h1>")
|
100 |
chatbot = gr.Chatbot()
|
101 |
-
msg = gr.Textbox(placeholder="Ask your question...", show_label=False)
|
102 |
submit_button = gr.Button("Submit", elem_classes="submit-btn")
|
103 |
clear = gr.Button("Clear", elem_classes="clear-btn")
|
104 |
|
105 |
-
# Function to handle user input
|
106 |
def user(user_message, history):
|
107 |
return "", history + [[user_message, None]]
|
108 |
|
109 |
-
# Function to handle bot response
|
110 |
def bot(history):
|
111 |
-
if len(history) == 1:
|
112 |
bot_message = "Hi there! How can I help you today?"
|
113 |
-
history[-1][1] = bot_message
|
114 |
else:
|
115 |
-
history[-1][1] = ""
|
116 |
-
previous_message = history[-1][0]
|
117 |
-
bot_message = generate_text(previous_message)
|
118 |
-
history[-1][1] = bot_message
|
119 |
return history
|
120 |
|
121 |
submit_button.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
|
|
32 |
return generated_text
|
33 |
|
34 |
# Custom CSS for the UI
|
35 |
+
background_image_path = '/mnt/data/image.png'
|
36 |
custom_css = f"""
|
37 |
+
/* Chatbot container */
|
38 |
+
.gradio-container {{
|
39 |
+
color: white; /* Light text color */
|
40 |
+
background-image: url('{background_image_path}'); /* Add background image */
|
41 |
+
background-size: cover; /* Cover the entire container */
|
42 |
+
background-position: center; /* Center the image */
|
43 |
+
background-repeat: no-repeat; /* Do not repeat the image */
|
44 |
+
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent dark background */
|
45 |
+
}}
|
46 |
+
|
47 |
+
/* Transparent message bubbles */
|
48 |
.message.pending {{
|
49 |
+
background: rgba(168, 196, 214, 0.1);
|
50 |
}}
|
|
|
51 |
.message.bot.svelte-1s78gfg.message-bubble-border {{
|
52 |
+
border-color: rgba(38, 107, 153, 0.1);
|
53 |
background: rgba(255, 255, 255, 0.1);
|
54 |
}}
|
|
|
55 |
.message.user.svelte-1s78gfg.message-bubble-border {{
|
56 |
+
background: rgba(157, 221, 249, 0.1);
|
57 |
+
border-color: rgba(157, 221, 249, 0.1);
|
58 |
}}
|
59 |
+
|
60 |
/* For both user and response message as per the document */
|
61 |
span.md.svelte-8tpqd2.chatbot.prose p {{
|
62 |
color: #266B99;
|
63 |
}}
|
64 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/* RED (Hex: #DB1616) for action buttons and links only */
|
66 |
.clear-btn {{
|
67 |
background: #DB1616;
|
|
|
89 |
content: url('file=Komal-patra/EU_AI_ACT/orcawise image.png');
|
90 |
margin-right: 8px;
|
91 |
}}
|
92 |
+
|
93 |
/* Enable scrolling for the chatbot messages */
|
94 |
.chatbot .messages {{
|
95 |
max-height: 500px; /* Adjust as needed */
|
96 |
overflow-y: auto;
|
97 |
}}
|
98 |
+
|
99 |
+
/* Transparent overall message container */
|
100 |
+
.gradio-chatbot .wrap {{
|
101 |
+
background: transparent; /* Make the container background transparent */
|
102 |
+
border: none; /* Remove any borders if necessary */
|
103 |
+
}}
|
104 |
"""
|
105 |
|
106 |
# Gradio interface setup
|
107 |
with gr.Blocks(css=custom_css) as demo:
|
|
|
108 |
chatbot = gr.Chatbot()
|
109 |
+
msg = gr.Textbox(placeholder="Ask your question...", show_label=False)
|
110 |
submit_button = gr.Button("Submit", elem_classes="submit-btn")
|
111 |
clear = gr.Button("Clear", elem_classes="clear-btn")
|
112 |
|
|
|
113 |
def user(user_message, history):
|
114 |
return "", history + [[user_message, None]]
|
115 |
|
|
|
116 |
def bot(history):
|
117 |
+
if len(history) == 1:
|
118 |
bot_message = "Hi there! How can I help you today?"
|
119 |
+
history[-1][1] = bot_message
|
120 |
else:
|
121 |
+
history[-1][1] = ""
|
122 |
+
previous_message = history[-1][0]
|
123 |
+
bot_message = generate_text(previous_message)
|
124 |
+
history[-1][1] = bot_message
|
125 |
return history
|
126 |
|
127 |
submit_button.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|