Sarolanda commited on
Commit
77c7fef
·
1 Parent(s): d7508c7

adds error treat

Browse files
Files changed (1) hide show
  1. core/ai.py +25 -12
core/ai.py CHANGED
@@ -27,17 +27,15 @@ PROMPT = (
27
  "FIRST: Is there a dog or cat clearly visible?\n"
28
  "If NO dog or cat is present, respond with exactly: {\"is_animal\": false}\n\n"
29
  "If YES, respond with ONLY valid JSON (no markdown, no explanation):\n"
30
- '{\'
31
- '"is_animal": true, '
32
- '"species": "dog or cat", '
33
- '"breed_estimate": "identify the most likely specific breed (e.g. Shih Tzu, Labrador, Poodle, Pitbull, Beagle, Golden Retriever, Siames, Persa) — use SRD only if truly unidentifiable", '
34
- '"size": "pequeno, medio or grande", '
35
- '"primary_color": "cor principal em portugues: caramelo, preto, branco, cinza, marrom, dourado, laranja, tigrado, mesclado", '
36
- '"secondary_colors": ["outras cores em portugues, ou lista vazia"], '
37
- '"distinctive_marks": ["marcas em portugues: ex. mancha branca no peito, coleira vermelha, cicatriz — ou lista vazia"], '
38
- '"condition": "saudavel, magro or ferido", '
39
- '"description_text": "one concise English sentence for semantic identity matching of this specific animal"'
40
- '}'
41
  )
42
 
43
 
@@ -186,4 +184,19 @@ class AnimalAI:
186
  marks = d.get("distinctive_marks", [])
187
  if marks:
188
  parts.append("with " + ", ".join(marks))
189
- return "
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  "FIRST: Is there a dog or cat clearly visible?\n"
28
  "If NO dog or cat is present, respond with exactly: {\"is_animal\": false}\n\n"
29
  "If YES, respond with ONLY valid JSON (no markdown, no explanation):\n"
30
+ "{\"is_animal\": true,"
31
+ " \"species\": \"dog or cat\","
32
+ " \"breed_estimate\": \"identify the most likely specific breed (e.g. Shih Tzu, Labrador, Poodle, Pitbull, Beagle, Golden Retriever, Siames, Persa) — use SRD only if truly unidentifiable\","
33
+ " \"size\": \"pequeno, medio or grande\","
34
+ " \"primary_color\": \"cor principal em portugues: caramelo, preto, branco, cinza, marrom, dourado, laranja, tigrado, mesclado\","
35
+ " \"secondary_colors\": [\"outras cores em portugues, ou lista vazia\"],"
36
+ " \"distinctive_marks\": [\"marcas em portugues: ex. mancha branca no peito, coleira vermelha, cicatriz — ou lista vazia\"],"
37
+ " \"condition\": \"saudavel, magro or ferido\","
38
+ " \"description_text\": \"one concise English sentence for semantic identity matching of this specific animal\"}"
 
 
39
  )
40
 
41
 
 
184
  marks = d.get("distinctive_marks", [])
185
  if marks:
186
  parts.append("with " + ", ".join(marks))
187
+ return " ".join(filter(None, parts))
188
+
189
+ @staticmethod
190
+ def _fallback() -> dict:
191
+ return {
192
+ "is_animal": True,
193
+ "_ai_success": False,
194
+ "species": "dog",
195
+ "breed_estimate": "SRD",
196
+ "size": "médio",
197
+ "primary_color": "caramelo",
198
+ "secondary_colors": [],
199
+ "distinctive_marks": [],
200
+ "condition": "saudável",
201
+ "description_text": "stray dog of unknown breed",
202
+ }