Spaces:
Paused
Paused
Increase max_tokens for generation settings and enhance JSON extraction to handle various markdown formats
Browse filesFiles changed (2)
- config/environments/default.yaml+5-5
- utils.py+23-17
22 unmodified lines232425262728293031323322 unmodified lines# Generation Settingsgeneration:max_tokens:openai: 512anthropic: 512gemini: 512deepseek: 512max_tokens_analysis: 2000temperature: 0.5# Model Providers Configuration22 unmodified lines232425262728293031323322 unmodified lines# Generation Settingsgeneration:max_tokens:openai: 1024anthropic: 1024gemini: 1024deepseek: 1024max_tokens_analysis: 4000temperature: 0.5# Model Providers Configuration
155 unmodified lines1561571581591601611621631641651661671681691701 unmodified line172173174175176177178179180181182183184185155 unmodified lines# 2. Try to find JSON within markdown or other texttext_to_parse = text.strip()# Remove markdown code blocksif "```json" in text_to_parse:parts = text_to_parse.split("```json")if len(parts) > 1:text_to_parse = parts[1].split("```")[0].strip()elif "```" in text_to_parse:parts = text_to_parse.split("```")if len(parts) > 1:text_to_parse = parts[1].strip()try:return json.loads(text_to_parse)1 unmodified linepass# 3. Last resort: find the first { and last }start_idx = text_to_parse.find('{')end_idx = text_to_parse.rfind('}')if start_idx != -1 and end_idx != -1:text_to_parse = text_to_parse[start_idx:end_idx + 1]try:return json.loads(text_to_parse)except json.JSONDecodeError:passreturn None155 unmodified lines1561571581591601611621631641651661671681691701711721731741 unmodified line176177178179180181182183184185186187188189190191155 unmodified lines# 2. Try to find JSON within markdown or other texttext_to_parse = text.strip()# Remove markdown code blocks with triple backticks or triple single quotesfor delimiter in ["```json", "'''json", "```", "'''"]:if delimiter in text_to_parse:try:parts = text_to_parse.split(delimiter)if len(parts) > 1:# Take the first content block after the delimitercandidate = parts[1].split(delimiter.replace("json", ""))[0].strip()if candidate:text_to_parse = candidatebreakexcept Exception:continuetry:return json.loads(text_to_parse)1 unmodified linepass# 3. Last resort: find the first { and last }# Try to balance braces to handle potential truncation or trailing noisestart_idx = text_to_parse.find('{')if start_idx != -1:# Step backwards from the end to find the last valid-looking closing bracefor end_idx in range(len(text_to_parse) - 1, start_idx, -1):if text_to_parse[end_idx] == '}':candidate = text_to_parse[start_idx:end_idx + 1]try:return json.loads(candidate)except json.JSONDecodeError:continuereturn None
config/environments/default.yaml+5-5
utils.py+23-17