roshnn24 commited on
Commit
2fead92
·
verified ·
1 Parent(s): a07279d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -20
app.py CHANGED
@@ -142,33 +142,24 @@ def init_db():
142
  conn.commit()
143
 
144
  def initialize_llm():
145
- """Initialize the LLM using the transformers library."""
146
  try:
147
  # Get API token
148
  api_token = os.environ.get('HF_TOKEN')
149
  if not api_token:
150
- raise ValueError("No Hugging Face API token found in environment variables.")
151
 
152
- # Define model repository ID
153
- model_name = "mistralai/Mistral-7B-Instruct-v0.3"
154
-
155
- # Load tokenizer and model
156
- print("Loading tokenizer...")
157
- tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=api_token)
158
-
159
- print("Loading model...")
160
- model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=api_token)
161
-
162
- # Test the model with a simple prompt
163
- print("Testing the model...")
164
- prompt = "Say hello"
165
- inputs = tokenizer(prompt, return_tensors="pt")
166
- outputs = model.generate(**inputs, max_length=50)
167
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
168
 
169
- print(f"Test response: {response}")
 
 
170
 
171
- return model, tokenizer
172
 
173
  except Exception as e:
174
  print(f"LLM initialization error: {str(e)}")
 
142
  conn.commit()
143
 
144
  def initialize_llm():
145
+ """Initialize the model in the simplest way possible"""
146
  try:
147
  # Get API token
148
  api_token = os.environ.get('HF_TOKEN')
149
  if not api_token:
150
+ raise ValueError("No API token found")
151
 
152
+ # Initialize with minimal settings
153
+ llm = HuggingFaceHub(
154
+ repo_id="microsoft/phi-4", # Using a simpler model for testing
155
+ huggingfacehub_api_token=api_token
156
+ )
 
 
 
 
 
 
 
 
 
 
 
157
 
158
+ # Quick test
159
+ test = llm("Say hello")
160
+ print(f"Test response: {test}")
161
 
162
+ return llm
163
 
164
  except Exception as e:
165
  print(f"LLM initialization error: {str(e)}")