Update app.py
Browse files
app.py
CHANGED
|
@@ -10,10 +10,7 @@ pipe = None
|
|
| 10 |
with open("facts.json", "r") as f:
|
| 11 |
WPI_FACTS = json.load(f)
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
fancy_css = """ ... """ # Keep your previous CSS here
|
| 15 |
-
|
| 16 |
-
# --- Gompei chatbot response ---
|
| 17 |
def respond(
|
| 18 |
message,
|
| 19 |
history: list[dict[str, str]],
|
|
@@ -36,7 +33,6 @@ def respond(
|
|
| 36 |
|
| 37 |
response = ""
|
| 38 |
|
| 39 |
-
|
| 40 |
print("[MODE] api")
|
| 41 |
token_value = None
|
| 42 |
if hf_token and getattr(hf_token, "token", None):
|
|
@@ -64,7 +60,7 @@ def respond(
|
|
| 64 |
response += token
|
| 65 |
yield response
|
| 66 |
|
| 67 |
-
#
|
| 68 |
chatbot = gr.ChatInterface(
|
| 69 |
fn=respond,
|
| 70 |
additional_inputs=[
|
|
@@ -98,7 +94,7 @@ chatbot = gr.ChatInterface(
|
|
| 98 |
],
|
| 99 |
)
|
| 100 |
|
| 101 |
-
#
|
| 102 |
with gr.Blocks(css=fancy_css) as demo:
|
| 103 |
with gr.Row():
|
| 104 |
gr.Markdown("<h1 id='title'>🐐 Chat with Gompei</h1>")
|
|
|
|
| 10 |
with open("facts.json", "r") as f:
|
| 11 |
WPI_FACTS = json.load(f)
|
| 12 |
|
| 13 |
+
# Gompei chatbot response
|
|
|
|
|
|
|
|
|
|
| 14 |
def respond(
|
| 15 |
message,
|
| 16 |
history: list[dict[str, str]],
|
|
|
|
| 33 |
|
| 34 |
response = ""
|
| 35 |
|
|
|
|
| 36 |
print("[MODE] api")
|
| 37 |
token_value = None
|
| 38 |
if hf_token and getattr(hf_token, "token", None):
|
|
|
|
| 60 |
response += token
|
| 61 |
yield response
|
| 62 |
|
| 63 |
+
# Chat Interface
|
| 64 |
chatbot = gr.ChatInterface(
|
| 65 |
fn=respond,
|
| 66 |
additional_inputs=[
|
|
|
|
| 94 |
],
|
| 95 |
)
|
| 96 |
|
| 97 |
+
# Blocks layout
|
| 98 |
with gr.Blocks(css=fancy_css) as demo:
|
| 99 |
with gr.Row():
|
| 100 |
gr.Markdown("<h1 id='title'>🐐 Chat with Gompei</h1>")
|