Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,19 @@ import spaces
|
|
2 |
import json
|
3 |
import subprocess
|
4 |
import gradio as gr
|
5 |
-
from huggingface_hub import hf_hub_download
|
|
|
6 |
|
7 |
subprocess.run('pip install llama-cpp-python==0.2.75 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124', shell=True)
|
8 |
subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
css = """
|
16 |
.message-row {
|
@@ -30,10 +34,10 @@ css = """
|
|
30 |
}
|
31 |
"""
|
32 |
|
33 |
-
PLACEHOLDER = """
|
34 |
<div class="message-bubble-border" style="display:flex; max-width: 600px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); backdrop-filter: blur(10px);">
|
35 |
<figure style="margin: 0;">
|
36 |
-
<img src="
|
37 |
</figure>
|
38 |
<div style="padding: .5rem 1.5rem;">
|
39 |
<h2 style="text-align: left; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem;">Cognitive Computations</h2>
|
@@ -73,9 +77,7 @@ def respond(
|
|
73 |
from llama_cpp_agent.providers import LlamaCppPythonProvider
|
74 |
from llama_cpp_agent.chat_history import BasicChatHistory
|
75 |
from llama_cpp_agent.chat_history.messages import Roles
|
76 |
-
|
77 |
-
print(history)
|
78 |
-
|
79 |
llm = Llama(
|
80 |
model_path=f"models/{model}",
|
81 |
flash_attn=True,
|
@@ -88,7 +90,7 @@ def respond(
|
|
88 |
|
89 |
agent = LlamaCppAgent(
|
90 |
provider,
|
91 |
-
system_prompt="You are
|
92 |
predefined_messages_formatter_type=MessagesFormatterType.CHATML,
|
93 |
debug_output=True
|
94 |
)
|
@@ -148,8 +150,9 @@ demo = gr.ChatInterface(
|
|
148 |
step=0.1,
|
149 |
label="Repetition penalty",
|
150 |
),
|
151 |
-
|
152 |
-
|
|
|
153 |
],
|
154 |
theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue", neutral_hue="gray",font=[gr.themes.GoogleFont("Exo"), "ui-sans-serif", "system-ui", "sans-serif"]).set(
|
155 |
body_background_fill_dark="#0f172a",
|
|
|
2 |
import json
|
3 |
import subprocess
|
4 |
import gradio as gr
|
5 |
+
from huggingface_hub import hf_hub_download, snapshot_download
|
6 |
+
import os
|
7 |
|
8 |
subprocess.run('pip install llama-cpp-python==0.2.75 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124', shell=True)
|
9 |
subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)
|
10 |
|
11 |
+
####
|
12 |
+
space_link = "https://huggingface.co/spaces/Weyaxi/chat"
|
13 |
+
gguf_model_id = "bartowski/Einstein-v6.1-Llama3-8B-GGUF"
|
14 |
+
###
|
15 |
+
|
16 |
+
|
17 |
+
download_gguf_model_dir = snapshot_download(repo_id=gguf_model_id, allow_patterns=["*Q6_K.gguf"], local_dir = "./models")
|
18 |
|
19 |
css = """
|
20 |
.message-row {
|
|
|
34 |
}
|
35 |
"""
|
36 |
|
37 |
+
PLACEHOLDER = f"""
|
38 |
<div class="message-bubble-border" style="display:flex; max-width: 600px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); backdrop-filter: blur(10px);">
|
39 |
<figure style="margin: 0;">
|
40 |
+
<img src="{space_link}/resolve/main/dolphin.gif" alt="Logo" style="width: 100%; height: 100%; border-radius: 8px;">
|
41 |
</figure>
|
42 |
<div style="padding: .5rem 1.5rem;">
|
43 |
<h2 style="text-align: left; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem;">Cognitive Computations</h2>
|
|
|
77 |
from llama_cpp_agent.providers import LlamaCppPythonProvider
|
78 |
from llama_cpp_agent.chat_history import BasicChatHistory
|
79 |
from llama_cpp_agent.chat_history.messages import Roles
|
80 |
+
|
|
|
|
|
81 |
llm = Llama(
|
82 |
model_path=f"models/{model}",
|
83 |
flash_attn=True,
|
|
|
90 |
|
91 |
agent = LlamaCppAgent(
|
92 |
provider,
|
93 |
+
system_prompt="You are Einstein an AI assistant that helps humanity.",
|
94 |
predefined_messages_formatter_type=MessagesFormatterType.CHATML,
|
95 |
debug_output=True
|
96 |
)
|
|
|
150 |
step=0.1,
|
151 |
label="Repetition penalty",
|
152 |
),
|
153 |
+
|
154 |
+
files = [f for f in os.listdir(download_gguf_model_dir) if os.path.isfile(os.path.join(download_gguf_model_dir, f))]
|
155 |
+
gr.Dropdown(files, value=files[0], label="Model"),
|
156 |
],
|
157 |
theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue", neutral_hue="gray",font=[gr.themes.GoogleFont("Exo"), "ui-sans-serif", "system-ui", "sans-serif"]).set(
|
158 |
body_background_fill_dark="#0f172a",
|