(coll)
| 68 | |
| 69 | |
| 70 | def load(coll): |
| 71 | with open(os.path.join(HERE, f"{coll}.json")) as f: |
| 72 | items = json.load(f) |
| 73 | out = [] |
| 74 | for it in items: |
| 75 | fields = it.get("fields") or {} |
| 76 | if isinstance(fields, str): |
| 77 | try: |
| 78 | fields = json.loads(fields) |
| 79 | except Exception: |
| 80 | fields = {} |
| 81 | out.append({"ref": it["ref"], "title": it["title"], "content": (it.get("content") or "")[:MAX_BODY], |
| 82 | "fields": fields, "collection": coll}) |
| 83 | return out |
| 84 | |
| 85 | |
| 86 | def call(key, model, state, questions, retries=5): |