Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,11 +33,11 @@ hf_hub_download(
|
|
| 33 |
filename="UD-Q3_K_XL/GLM-4.5-Air-UD-Q3_K_XL-00001-of-00002.gguf",
|
| 34 |
local_dir = "./models"
|
| 35 |
)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
# --- CSS Styling ---
|
| 43 |
css = """
|
|
@@ -122,7 +122,6 @@ def respond(
|
|
| 122 |
|
| 123 |
chat_template = get_messages_formatter_type(model)
|
| 124 |
|
| 125 |
-
# Llama-Modell initialisieren oder wechseln, falls nötig
|
| 126 |
if llm is None or llm_model != model:
|
| 127 |
llm = Llama(
|
| 128 |
model_path=f"models/{model}",
|
|
@@ -154,15 +153,13 @@ def respond(
|
|
| 154 |
# Chat-Verlauf vorbereiten
|
| 155 |
messages = BasicChatHistory()
|
| 156 |
|
| 157 |
-
# KORREKTUR: Iteriere über die Gradio-Dictionaries und konvertiere sie
|
| 158 |
for msn in history:
|
| 159 |
-
# Sicherstellen, dass die Rolle korrekt konvertiert wird
|
| 160 |
if msn.get('role') == 'user':
|
| 161 |
role = Roles.user
|
| 162 |
elif msn.get('role') == 'assistant':
|
| 163 |
role = Roles.assistant
|
| 164 |
else:
|
| 165 |
-
continue
|
| 166 |
|
| 167 |
message_dict = {
|
| 168 |
'role': role,
|
|
@@ -170,7 +167,6 @@ def respond(
|
|
| 170 |
}
|
| 171 |
messages.add_message(message_dict)
|
| 172 |
|
| 173 |
-
# Antwort streamen
|
| 174 |
stream = agent.get_chat_response(
|
| 175 |
message,
|
| 176 |
llm_sampling_settings=settings,
|
|
@@ -209,10 +205,7 @@ PLACEHOLDER = """
|
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
"""
|
| 212 |
-
# --- Die Variable 'placeholder_html' ist nicht mehr notwendig und wird entfernt ---
|
| 213 |
-
|
| 214 |
|
| 215 |
-
# --- Zusätzliche Eingabekomponenten erstellen ---
|
| 216 |
model_dropdown = gr.Dropdown([
|
| 217 |
'granite-4.0-h-tiny-UD-Q3_K_XL.gguf',
|
| 218 |
'Llama-3.2-1B-Instruct-UD-Q2_K_XL.gguf',
|
|
@@ -247,13 +240,10 @@ repeat_penalty_slider = gr.Slider(
|
|
| 247 |
label="Repetition penalty",
|
| 248 |
)
|
| 249 |
|
| 250 |
-
|
| 251 |
# --- Gradio Chat Interface Definition (Fix implementiert) ---
|
| 252 |
demo = gr.ChatInterface(
|
| 253 |
respond,
|
| 254 |
type="messages",
|
| 255 |
-
# FIX: Verwende den HTML-String (PLACEHOLDER) direkt und setze label=False,
|
| 256 |
-
# damit Gradio es korrekt rendert.
|
| 257 |
chatbot=gr.Chatbot(placeholder=PLACEHOLDER, height=450, type="messages", label=False),
|
| 258 |
additional_inputs=[
|
| 259 |
model_dropdown,
|
|
|
|
| 33 |
filename="UD-Q3_K_XL/GLM-4.5-Air-UD-Q3_K_XL-00001-of-00002.gguf",
|
| 34 |
local_dir = "./models"
|
| 35 |
)
|
| 36 |
+
hf_hub_download(
|
| 37 |
+
repo_id="unsloth/GLM-4.5-Air-GGUF",
|
| 38 |
+
filename="UD-Q3_K_XL/GLM-4.5-Air-UD-Q3_K_XL-00002-of-00002.gguf",
|
| 39 |
+
local_dir = "./models"
|
| 40 |
+
)
|
| 41 |
|
| 42 |
# --- CSS Styling ---
|
| 43 |
css = """
|
|
|
|
| 122 |
|
| 123 |
chat_template = get_messages_formatter_type(model)
|
| 124 |
|
|
|
|
| 125 |
if llm is None or llm_model != model:
|
| 126 |
llm = Llama(
|
| 127 |
model_path=f"models/{model}",
|
|
|
|
| 153 |
# Chat-Verlauf vorbereiten
|
| 154 |
messages = BasicChatHistory()
|
| 155 |
|
|
|
|
| 156 |
for msn in history:
|
|
|
|
| 157 |
if msn.get('role') == 'user':
|
| 158 |
role = Roles.user
|
| 159 |
elif msn.get('role') == 'assistant':
|
| 160 |
role = Roles.assistant
|
| 161 |
else:
|
| 162 |
+
continue
|
| 163 |
|
| 164 |
message_dict = {
|
| 165 |
'role': role,
|
|
|
|
| 167 |
}
|
| 168 |
messages.add_message(message_dict)
|
| 169 |
|
|
|
|
| 170 |
stream = agent.get_chat_response(
|
| 171 |
message,
|
| 172 |
llm_sampling_settings=settings,
|
|
|
|
| 205 |
</div>
|
| 206 |
</div>
|
| 207 |
"""
|
|
|
|
|
|
|
| 208 |
|
|
|
|
| 209 |
model_dropdown = gr.Dropdown([
|
| 210 |
'granite-4.0-h-tiny-UD-Q3_K_XL.gguf',
|
| 211 |
'Llama-3.2-1B-Instruct-UD-Q2_K_XL.gguf',
|
|
|
|
| 240 |
label="Repetition penalty",
|
| 241 |
)
|
| 242 |
|
|
|
|
| 243 |
# --- Gradio Chat Interface Definition (Fix implementiert) ---
|
| 244 |
demo = gr.ChatInterface(
|
| 245 |
respond,
|
| 246 |
type="messages",
|
|
|
|
|
|
|
| 247 |
chatbot=gr.Chatbot(placeholder=PLACEHOLDER, height=450, type="messages", label=False),
|
| 248 |
additional_inputs=[
|
| 249 |
model_dropdown,
|