Weyaxi commited on
Commit
d750300
1 Parent(s): 824ec3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
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
- download_gguf_model = hf_hub_download(repo_id="bartowski/Einstein-v6.1-Llama3-8B-GGUF", filename="Einstein-v6.1-Llama3-8B-Q6_K.gguf", local_dir = "./models")
11
- #hf_hub_download(repo_id="crusoeai/dolphin-2.9.1-llama-3-70b-GGUF", filename="dolphin-2.9.1-llama-3-70b.Q3_K_M.gguf", local_dir = "./models")
12
- # hf_hub_download(repo_id="bartowski/dolphin-2.9.1-yi-1.5-9b-GGUF", filename="dolphin-2.9.1-yi-1.5-9b-f32.gguf", local_dir = "./models")
13
- # hf_hub_download(repo_id="crusoeai/dolphin-2.9.1-llama-3-8b-GGUF", filename="dolphin-2.9.1-llama-3-8b.Q6_K.gguf", local_dir = "./models")
 
 
 
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="https://huggingface.co/spaces/Weyaxi/chat/resolve/main/dolphin.gif" alt="Logo" style="width: 100%; height: 100%; border-radius: 8px;">
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
- print(message)
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 Dolphin an AI assistant that helps humanity.",
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
- #models = ['dolphin-2.9.1-yi-1.5-34b-Q6_K.gguf', 'dolphin-2.9.1-llama-3-70b.Q3_K_M.gguf']
152
- gr.Dropdown(["Einstein-v6.1-Llama3-8B-Q6_K.gguf"], value="Einstein-v6.1-Llama3-8B-Q6_K.gguf", label="Model"),
 
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",