Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
# Define CSS
|
4 |
blue_theme_css = """
|
5 |
body {background-color: #e0f7fa;} /* Light blue background */
|
6 |
.gradio-app {color: #0d47a1;} /* Dark blue text for general elements */
|
@@ -8,6 +8,26 @@ body {background-color: #e0f7fa;} /* Light blue background */
|
|
8 |
.button:hover {background-color: #1e88e5 !important;} /* Darker blue on hover */
|
9 |
"""
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Define a blue-themed CSS for the interface
|
4 |
blue_theme_css = """
|
5 |
body {background-color: #e0f7fa;} /* Light blue background */
|
6 |
.gradio-app {color: #0d47a1;} /* Dark blue text for general elements */
|
|
|
8 |
.button:hover {background-color: #1e88e5 !important;} /* Darker blue on hover */
|
9 |
"""
|
10 |
|
11 |
+
# Define the assistant prompt to provide context
|
12 |
+
assistant_prompt = "You are a helpful assistant. Answer questions concisely and helpfully."
|
13 |
+
|
14 |
+
# Define a function to interact with the model, taking input and adding context
|
15 |
+
def assistant_response(user_input):
|
16 |
+
# Here, you'd modify this to pass the assistant_prompt to your model API
|
17 |
+
response = gr.load("models/meta-llama/Llama-3.2-3B-Instruct")(f"{assistant_prompt} {user_input}")
|
18 |
+
return response
|
19 |
+
|
20 |
+
# Create the Gradio Interface for the API
|
21 |
+
app = gr.Interface(
|
22 |
+
fn=assistant_response,
|
23 |
+
inputs="text",
|
24 |
+
outputs="text",
|
25 |
+
css=blue_theme_css,
|
26 |
+
title="Helpful Assistant API",
|
27 |
+
description="Ask me anything, and I'll do my best to help!",
|
28 |
+
examples=["What's the weather like today?", "Explain Python decorators."],
|
29 |
+
allow_flagging="never"
|
30 |
+
)
|
31 |
+
|
32 |
+
# Launch the app and make it API accessible
|
33 |
+
app.launch(enable_queue=True, api_name="get_help")
|