Spaces:
Build error
Build error
gusreinaos
commited on
Commit
·
d401a5e
1
Parent(s):
e3e916c
Change UI and fix API not found
Browse files- README.md +1 -1
- app.py +46 -21
- requirements.txt +2 -2
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🦙
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app.py
CHANGED
|
@@ -44,7 +44,9 @@ def chat(message, history):
|
|
| 44 |
echo=False
|
| 45 |
)
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Clean terminal/hacker CSS
|
| 50 |
custom_css = """
|
|
@@ -75,10 +77,6 @@ h1 {
|
|
| 75 |
}
|
| 76 |
|
| 77 |
/* Chatbot messages */
|
| 78 |
-
.message-wrap {
|
| 79 |
-
background: #0c0c0c !important;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
.message {
|
| 83 |
background: #1a1a1a !important;
|
| 84 |
border-left: 3px solid #00ff00 !important;
|
|
@@ -170,24 +168,51 @@ pre, code {
|
|
| 170 |
}
|
| 171 |
"""
|
| 172 |
|
| 173 |
-
# Create interface using
|
| 174 |
-
|
| 175 |
-
fn=chat,
|
| 176 |
-
title="$ LLAMA TERMINAL",
|
| 177 |
-
description="```\n> System Online | Neural Network Active\n> Type your query below...\n```",
|
| 178 |
theme=gr.themes.Base(primary_hue="green"),
|
| 179 |
css=custom_css,
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
"
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
if __name__ == "__main__":
|
| 193 |
demo.queue()
|
|
|
|
| 44 |
echo=False
|
| 45 |
)
|
| 46 |
|
| 47 |
+
bot_response = response['choices'][0]['text'].strip()
|
| 48 |
+
history.append((message, bot_response))
|
| 49 |
+
return history, ""
|
| 50 |
|
| 51 |
# Clean terminal/hacker CSS
|
| 52 |
custom_css = """
|
|
|
|
| 77 |
}
|
| 78 |
|
| 79 |
/* Chatbot messages */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
.message {
|
| 81 |
background: #1a1a1a !important;
|
| 82 |
border-left: 3px solid #00ff00 !important;
|
|
|
|
| 168 |
}
|
| 169 |
"""
|
| 170 |
|
| 171 |
+
# Create interface using Blocks
|
| 172 |
+
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
| 173 |
theme=gr.themes.Base(primary_hue="green"),
|
| 174 |
css=custom_css,
|
| 175 |
+
title="$ LLAMA TERMINAL"
|
| 176 |
+
) as demo:
|
| 177 |
+
|
| 178 |
+
gr.Markdown(
|
| 179 |
+
"""
|
| 180 |
+
# $ LLAMA TERMINAL
|
| 181 |
+
```
|
| 182 |
+
> System Online | Neural Network Active
|
| 183 |
+
> Type your query below...
|
| 184 |
+
```
|
| 185 |
+
"""
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
chatbot = gr.Chatbot(height=600)
|
| 189 |
+
|
| 190 |
+
with gr.Row():
|
| 191 |
+
msg = gr.Textbox(
|
| 192 |
+
placeholder="$ Enter command...",
|
| 193 |
+
show_label=False,
|
| 194 |
+
scale=8,
|
| 195 |
+
container=False
|
| 196 |
+
)
|
| 197 |
+
submit = gr.Button("SEND", scale=1, variant="primary")
|
| 198 |
+
|
| 199 |
+
gr.Examples(
|
| 200 |
+
examples=[
|
| 201 |
+
"What is the capital of France?",
|
| 202 |
+
"Explain quantum computing",
|
| 203 |
+
"Write fibonacci in Python",
|
| 204 |
+
"Optimize sleep patterns",
|
| 205 |
+
"Continue: 2, 4, 6, 8...",
|
| 206 |
+
"Write a haiku about AI",
|
| 207 |
+
],
|
| 208 |
+
inputs=msg
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
clear = gr.ClearButton([msg, chatbot], value="CLEAR")
|
| 212 |
+
|
| 213 |
+
# Event handlers
|
| 214 |
+
submit.click(chat, [msg, chatbot], [chatbot, msg])
|
| 215 |
+
msg.submit(chat, [msg, chatbot], [chatbot, msg])
|
| 216 |
|
| 217 |
if __name__ == "__main__":
|
| 218 |
demo.queue()
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
gradio
|
| 2 |
-
huggingface_hub
|
| 3 |
llama-cpp-python==0.2.90
|
|
|
|
| 1 |
+
gradio==4.44.1
|
| 2 |
+
huggingface_hub==0.25.2
|
| 3 |
llama-cpp-python==0.2.90
|