Checkbox-aware autofill + expose field type in list_forms
This commit is contained in:
13
app.py
13
app.py
@@ -77,16 +77,21 @@ def _autofill_values(uid, form_id):
|
||||
profile = store.get_profile(uid) if uid else {}
|
||||
about = profile.get("about_me", "")
|
||||
display = profile.get("display_name", "")
|
||||
field_desc = ", ".join(f"{f['key']} ({f.get('label', '')})" for f in fm)
|
||||
field_desc = ", ".join(
|
||||
f"{f['key']} ({f.get('label', '')})"
|
||||
+ (" [CHECKBOX — output 'X' to check, '' to leave blank]" if f.get('type') == 'checkbox' else "")
|
||||
for f in fm
|
||||
)
|
||||
prompt = (
|
||||
"You are filling a Washington State court form. Map the user's facts to the form fields.\n"
|
||||
f"Form: {spec['name']}\n"
|
||||
f"Fields: {field_desc}\n\n"
|
||||
f"User's display name: {display or '(not set)'}\n"
|
||||
f"User's information (About Me):\n{about or '(not provided)'}\n\n"
|
||||
"Output ONLY valid JSON like {\"county\": \"...\", \"petitioner\": \"...\"}. "
|
||||
"For any field you cannot determine, output an empty string \"\". "
|
||||
"Petitioner is the user themself (use the display name); respondent is their spouse."
|
||||
"Output ONLY valid JSON. For text fields, output the value (or empty string if unknown). "
|
||||
"For CHECKBOX fields, output 'X' to check the box when the user's facts match that option, "
|
||||
"otherwise output ''. Petitioner is the user themself (use the display name); "
|
||||
"respondent is their spouse."
|
||||
)
|
||||
try:
|
||||
resp = _ollama_chat(RAG_MODEL, [{"role": "user", "content": prompt}],
|
||||
|
||||
3
forms.py
3
forms.py
@@ -51,7 +51,8 @@ def list_forms():
|
||||
out = []
|
||||
for fid, spec in FORM_NAMES.items():
|
||||
fm = FIELDMAP.get(fid, [])
|
||||
fields = [{"key": f["key"], "label": f.get("label", f["key"])} for f in fm]
|
||||
fields = [{"key": f["key"], "label": f.get("label", f["key"]),
|
||||
"type": f.get("type", "text")} for f in fm]
|
||||
out.append({"id": fid, "name": spec["name"], "description": spec["description"],
|
||||
"fields": fields})
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user