Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,9 @@ import PyPDF2
|
|
16 |
import io
|
17 |
import traceback
|
18 |
|
19 |
-
from git import Repo
|
20 |
|
21 |
-
Repo.clone_from("https://huggingface.co/unsloth/Llama-3.2-3B-bnb-4bit", "./local_model_dir")
|
22 |
|
23 |
|
24 |
|
@@ -41,6 +41,24 @@ model = None
|
|
41 |
tokenizer = None
|
42 |
generation_config = None
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
def initialize_model():
|
45 |
"""Separate model initialization with better error handling"""
|
46 |
global model, tokenizer, generation_config
|
@@ -695,6 +713,12 @@ def generate_podcast_gradio(input_text, input_file, language, speaker1, speaker2
|
|
695 |
return None, "\n".join(logs)
|
696 |
|
697 |
def create_interface():
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
"""Create the Gradio interface"""
|
699 |
language_options = [
|
700 |
"Auto Detect", "English", "German", "French", "Spanish", "Italian",
|
|
|
16 |
import io
|
17 |
import traceback
|
18 |
|
19 |
+
#from git import Repo
|
20 |
|
21 |
+
#Repo.clone_from("https://huggingface.co/unsloth/Llama-3.2-3B-bnb-4bit", "./local_model_dir")
|
22 |
|
23 |
|
24 |
|
|
|
41 |
tokenizer = None
|
42 |
generation_config = None
|
43 |
|
44 |
+
def test_llm_generation():
|
45 |
+
try:
|
46 |
+
test_prompt = "Hello, how are you today?"
|
47 |
+
inputs = tokenizer(test_prompt, return_tensors="pt").to(model.device)
|
48 |
+
with torch.no_grad():
|
49 |
+
outputs = model.generate(
|
50 |
+
**inputs,
|
51 |
+
max_new_tokens=10,
|
52 |
+
do_sample=False,
|
53 |
+
pad_token_id=tokenizer.pad_token_id,
|
54 |
+
eos_token_id=tokenizer.eos_token_id
|
55 |
+
)
|
56 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
57 |
+
add_log(f"🧪 Test LLM response: {result[:100]}")
|
58 |
+
except Exception as e:
|
59 |
+
add_log(f"❌ LLM quick test failed: {e}")
|
60 |
+
|
61 |
+
|
62 |
def initialize_model():
|
63 |
"""Separate model initialization with better error handling"""
|
64 |
global model, tokenizer, generation_config
|
|
|
713 |
return None, "\n".join(logs)
|
714 |
|
715 |
def create_interface():
|
716 |
+
|
717 |
+
model_loaded = initialize_model()
|
718 |
+
if model_loaded:
|
719 |
+
test_llm_generation()
|
720 |
+
|
721 |
+
|
722 |
"""Create the Gradio interface"""
|
723 |
language_options = [
|
724 |
"Auto Detect", "English", "German", "French", "Spanish", "Italian",
|