Spaces:
Sleeping
Sleeping
293droid commited on
Commit ·
2ef9c19
1
Parent(s): ddbe441
fix: shea butter parser, superfat display, stop hallucination tokens
Browse files48 unmodified lines4950515253545513 unmodified lines697071727374757677787948 unmodified lines{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": full_prompt}],max_tokens=800,)return response.choices[0].message.contentexcept Exception as e:13 unmodified linesweight = float(weight_str)oil_fragment = oil_fragment.strip().rstrip(',').strip()matched_key = Nonefor key in OILS:key_words = key.replace('(', '').replace(')', '').split()if any(word in oil_fragment for word in key_words if len(word) > 3):matched_key = keybreakif matched_key and weight > 0:recipe[matched_key] = recipe.get(matched_key, 0) + weightreturn recipe48 unmodified lines495051525354555613 unmodified lines7071727374757677787980818283848586878848 unmodified lines{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": full_prompt}],max_tokens=500,stop=["user ", "User ", "\nuser", "\nUser"],)return response.choices[0].message.contentexcept Exception as e:13 unmodified linesweight = float(weight_str)oil_fragment = oil_fragment.strip().rstrip(',').strip()matched_key = None# Try exact match firstfor key in OILS:if key == oil_fragment.strip():matched_key = keybreak# Then try word matchif not matched_key:for key in OILS:key_words = key.replace('(','').replace(')','').split()scored_words = [w for w in key_words if len(w) > 4 and w not in ["butter","oil","seed","palm"]]if scored_words and all(w in oil_fragment for w in scored_words):matched_key = keybreakif matched_key and weight > 0:recipe[matched_key] = recipe.get(matched_key, 0) + weightreturn recipe
app.py+12-3