cpg716 commited on
Commit
b949952
·
verified ·
1 Parent(s): 726139a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -3
app.py CHANGED
@@ -3,7 +3,7 @@ import torch
3
  import sys
4
  import traceback
5
  import os
6
- from huggingface_hub import login
7
 
8
  def system_info():
9
  try:
@@ -27,6 +27,40 @@ def system_info():
27
  except Exception as e:
28
  return f"Error: {str(e)}\n\n{traceback.format_exc()}"
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  def test_gemma3():
31
  try:
32
  result = []
@@ -50,9 +84,22 @@ def test_gemma3():
50
 
51
  # Use Gemma 3 GGUF model
52
  model_id = "google/gemma-3-27b-it-qat-q4_0-gguf"
53
- model_filename = "gemma-3-27b-it-qat-q4_0.gguf"
54
 
55
- result.append(f"Downloading {model_id} if not already present...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  from huggingface_hub import hf_hub_download
57
 
58
  model_path = hf_hub_download(
@@ -118,6 +165,19 @@ with gr.Blocks(title="StaffManager AI Assistant") as demo:
118
  outputs=[info_result]
119
  )
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  with gr.Tab("Gemma 3 Test"):
122
  with gr.Row():
123
  with gr.Column():
 
3
  import sys
4
  import traceback
5
  import os
6
+ from huggingface_hub import login, list_repo_files
7
 
8
  def system_info():
9
  try:
 
27
  except Exception as e:
28
  return f"Error: {str(e)}\n\n{traceback.format_exc()}"
29
 
30
+ def list_gemma3_files():
31
+ try:
32
+ result = []
33
+ result.append("Listing files in Gemma 3 repository...")
34
+
35
+ # Get token from environment
36
+ token = os.environ.get("HUGGINGFACE_TOKEN", "")
37
+ if token:
38
+ result.append(f"Token found: {token[:5]}...")
39
+ else:
40
+ result.append("No token found in environment variables!")
41
+ return "\n".join(result)
42
+
43
+ # Login to Hugging Face
44
+ try:
45
+ login(token=token)
46
+ result.append("Successfully logged in to Hugging Face Hub")
47
+ except Exception as e:
48
+ result.append(f"Error logging in: {e}")
49
+ return "\n".join(result)
50
+
51
+ # List files in the repository
52
+ model_id = "google/gemma-3-27b-it-qat-q4_0-gguf"
53
+ result.append(f"Listing files in {model_id}...")
54
+
55
+ files = list_repo_files(model_id, token=token)
56
+ result.append("Files found:")
57
+ for file in files:
58
+ result.append(f"- {file}")
59
+
60
+ return "\n".join(result)
61
+ except Exception as e:
62
+ return f"Error: {str(e)}\n\n{traceback.format_exc()}"
63
+
64
  def test_gemma3():
65
  try:
66
  result = []
 
84
 
85
  # Use Gemma 3 GGUF model
86
  model_id = "google/gemma-3-27b-it-qat-q4_0-gguf"
 
87
 
88
+ # First, list the files to find the correct filename
89
+ result.append(f"Listing files in {model_id} to find the model file...")
90
+ from huggingface_hub import list_repo_files
91
+
92
+ files = list_repo_files(model_id, token=token)
93
+ gguf_files = [f for f in files if f.endswith('.gguf')]
94
+
95
+ if not gguf_files:
96
+ result.append("No GGUF files found in the repository!")
97
+ return "\n".join(result)
98
+
99
+ model_filename = gguf_files[0] # Use the first GGUF file found
100
+ result.append(f"Found model file: {model_filename}")
101
+
102
+ result.append(f"Downloading {model_id}/{model_filename}...")
103
  from huggingface_hub import hf_hub_download
104
 
105
  model_path = hf_hub_download(
 
165
  outputs=[info_result]
166
  )
167
 
168
+ with gr.Tab("List Gemma 3 Files"):
169
+ with gr.Row():
170
+ with gr.Column():
171
+ list_files_button = gr.Button("List Gemma 3 Files")
172
+ with gr.Column():
173
+ list_files_result = gr.Textbox(label="Files in Repository", lines=20)
174
+
175
+ list_files_button.click(
176
+ fn=list_gemma3_files,
177
+ inputs=[],
178
+ outputs=[list_files_result]
179
+ )
180
+
181
  with gr.Tab("Gemma 3 Test"):
182
  with gr.Row():
183
  with gr.Column():