Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,9 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
"""
|
@@ -6,58 +11,60 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
6 |
"""
|
7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
|
|
|
|
|
|
|
9 |
|
10 |
-
def
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
],
|
59 |
-
)
|
60 |
|
|
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
+
from model_loader import load_model
|
4 |
+
from retriever import setup_retriever
|
5 |
+
from llm_chain import setup_llm_chain
|
6 |
+
from utils import generate_response
|
7 |
from huggingface_hub import InferenceClient
|
8 |
|
9 |
"""
|
|
|
11 |
"""
|
12 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
13 |
|
14 |
+
# Load necessary components
|
15 |
+
retriever = setup_retriever()
|
16 |
+
llm_chain = setup_llm_chain()
|
17 |
|
18 |
+
def main():
|
19 |
+
interface = gr.Interface
|
20 |
+
(
|
21 |
+
fn=lambda question: generate_response(question, retriever, llm_chain),
|
22 |
+
inputs=gr.Textbox(placeholder="Ask your question...", label="Your Question", lines=2),
|
23 |
+
outputs=gr.Textbox(label="Bloodraven's Response", lines=5, interactive=False),
|
24 |
+
title="Bloodraven Chatbot",
|
25 |
+
description="Ask any question and receive cryptic, prophetic answers from the Bloodraven from A Song of Ice and Fire.",
|
26 |
+
css="""
|
27 |
+
.gradio-container {
|
28 |
+
font-family: 'Arial', sans-serif; /* Simple, clear font */
|
29 |
+
background-color: #f9f9f9; /* Light gray background */
|
30 |
+
color: #333333; /* Dark gray text for contrast */
|
31 |
+
}
|
32 |
+
.input_textbox, .output_textbox {
|
33 |
+
border-radius: 5px; /* Rounded corners */
|
34 |
+
border: 2px solid #007bff; /* Bright blue border */
|
35 |
+
background-color: #ffffff; /* White background for input/output boxes */
|
36 |
+
color: #333333; /* Dark gray text for visibility */
|
37 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Subtle shadow */
|
38 |
+
}
|
39 |
+
.input_textbox:focus, .output_textbox:focus {
|
40 |
+
border-color: #ff4500; /* Bright orange-red border on focus */
|
41 |
+
}
|
42 |
+
.title {
|
43 |
+
font-size: 36px; /* Larger title */
|
44 |
+
font-weight: bold; /* Bold title */
|
45 |
+
text-align: center; /* Centered title */
|
46 |
+
color: #007bff; /* Bright blue for title */
|
47 |
+
}
|
48 |
+
.description {
|
49 |
+
font-size: 20px; /* Larger description font */
|
50 |
+
text-align: center; /* Centered description */
|
51 |
+
margin-bottom: 20px; /* Space below description */
|
52 |
+
color: #555555; /* Medium gray for description */
|
53 |
+
}
|
54 |
+
.footer {
|
55 |
+
text-align: center; /* Center footer text */
|
56 |
+
margin-top: 20px; /* Space above footer */
|
57 |
+
color: #888888; /* Light gray for footer text */
|
58 |
+
}
|
59 |
+
""",
|
60 |
+
examples=[
|
61 |
+
["How are Daenerys and Jon Snow related?"],
|
62 |
+
["What is the fate of Bran Stark?"],
|
63 |
+
["Tell me about the Iron Throne."],
|
64 |
+
],
|
65 |
+
)
|
|
|
|
|
66 |
|
67 |
+
interface.launch()
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
+
main()
|