sarun25 commited on
Commit
a955034
·
1 Parent(s): 5eb84c2

fix: LLM API connection

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +2 -10
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ venv/
2
+ .env
app.py CHANGED
@@ -163,20 +163,12 @@ def validate_and_evaluate(description: str, code: str):
163
  return "", "", "", "⚠️ Please provide Python code to evaluate."
164
 
165
  # --- Check token is available ---
166
- if not HF_TOKEN:
167
- return "", "", "", "❌ HF_TOKEN secret is not set. Add it in Space Settings → Variables and secrets."
168
 
169
  # --- Pre-processing ---
170
  prompt = build_prompt(description, code)
171
 
172
- # Token length guard
173
- token_count = len(get_tokenizer().encode(prompt))
174
- if token_count > 2048:
175
- return "", "", "", (
176
- f"⚠️ Input too long ({token_count} tokens). "
177
- "Please shorten your description or code and try again."
178
- )
179
-
180
  # --- Generation ---
181
  try:
182
  raw_output = generate_response(prompt)
 
163
  return "", "", "", "⚠️ Please provide Python code to evaluate."
164
 
165
  # --- Check token is available ---
166
+ if not GOOGLE_API_KEY:
167
+ return "", "", "", "❌ GOOGLE_API_KEY secret is not set. Add it in Space Settings → Variables and secrets."
168
 
169
  # --- Pre-processing ---
170
  prompt = build_prompt(description, code)
171
 
 
 
 
 
 
 
 
 
172
  # --- Generation ---
173
  try:
174
  raw_output = generate_response(prompt)