Spaces:
Sleeping
Sleeping
Commit History
-
fix: letter lost the duration sentence when AI paraphrasing dropped the 'ภายใน X วัน' signal — (1) build_letter falls back to the raw TOR clause when cleaning loses it, (2) generate_body rejects AI bodies missing the supplied day-number
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NQMBLPhJZUBCX7io3uwEnRb9e493a -
Auto-form: remove the OpenRouter backend entirely (org policy) — AI Builder flow is the only AI backend
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>3f28237 -
Auto-form: AI backend via Power Automate + AI Builder (AI_BACKEND env, OpenRouter kept for rollback)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>38e26ff
-
Auto-form: same-model failover across accounts (seamless key rotation)
Reorder _complete to model-outer / key-inner: for the preferred model, rotate across ALL accounts before downgrading to the next model, and switch accounts immediately on a 429 (no wait). So a rate-limited account fails over to the other account on the SAME model, keeping output consistent; errors stay caught (caller falls back to deterministic text). Verified ordering with stubbed calls. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>18b092a -
Auto-form: rotate across multiple OpenRouter API keys on rate limit
Support more than one OpenRouter account and auto-switch when one is limited: - _api_keys(): collect keys from OPENROUTER_API_KEY (may hold several, comma/ whitespace separated) + OPENROUTER_API_KEY_2.._5, deduped, order preserved. - _complete(): shared key x model x retry loop; rotates to the NEXT key as soon as the current account stays 429 after retries (free-tier limits are account- wide), still trying other models for transient errors. generate_body and clean_delivery now use it; deterministic/raw fallback when all keys exhausted. Verified: key parsing (multi-in-one-secret, _2.._5, dedupe) and rotation (account A 429 -> account B serves; all-limited -> None -> deterministic). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>9879d74 -
Auto-form: soften body verb -> 'ได้มีข้อตกลงในการจัดซื้อ/จัดจ้างกับ'
'ได้ตกลงซื้อ <vendor>' read too blunt. Use the procurement-style phrasing 'ได้มีข้อตกลงในการจัดซื้อกับ <vendor>' (งานซื้อ) and the parallel 'ได้มีข้อตกลงในการจัดจ้างกับ <vendor>' (งานจ้าง), in both the deterministic compose_body and the AI prompt template. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>b462261 -
Auto-form: robust กำหนดส่งมอบ extraction (no wrong-section pulls)
The browser TOR fetch picked the FIRST detail part whose title+content merely contained 'การส่งมอบงาน', so a passing mention in an earlier section (e.g. 'หลักฐานการส่งมอบงาน' in คุณสมบัติผู้ยื่นข้อเสนอ) or a look-alike heading (สถานที่ส่งมอบ / การจ่ายเงิน / ค่าปรับ) could be pulled instead of the real delivery clause. Section position is not fixed across TOR types either. - signer_lookup.py: score every TOR section — title is a delivery heading wins, look-alike sections are excluded, and a content-only match must carry a real duration/งวด signal (ภายใน X วัน / งวดที่ N / งวดเดียว / นับถัดจาก). Broadened the accepted headings (ระยะเวลาส่งมอบ / กำหนดส่งมอบ / ระยะเวลาดำเนินงาน …). - ai_clean.py: _duration_from_tor tolerates a spelled-out คำอ่าน between the number and วัน, e.g. 'ภายใน 160 (หนึ่งร้อยหกสิบ) วัน'. Verified: real selection logic (extracted from the file) picks the correct section for both sample TORs (1191001682 งวดเดียว 160 วัน, 1141000533 4 งวด) over the trap/look-…24f2f2e -
Auto-form: switch body to the "ตกลงว่าจ้าง…ให้ดำเนินการ" format, TOR-driven duration
Per the user's example: para 1 = "ตามที่ <unit> บริษัท ปตท. จำกัด (มหาชน) (ปตท.) ได้ตกลง [ว่าจ้าง/ซื้อ] <vendor> ให้ดำเนินการ <work> โดยกำหนดให้แล้วเสร็จภายใน X วัน [(วันหยุด)] นับถัดจาก <เหตุ> ทั้งนี้ไม่นับรวมระยะเวลาที่ ปตท. ไม่อนุญาตให้เข้าดำเนินงาน/สั่งหยุดงาน"; para 2 = "<unit> จึงขอแจ้งให้ <vendor> เริ่มเข้าดำเนินการได้นับถัดจากวันที่ <date> เป็นต้นไป". The "ภายใน X วัน … นับถัดจาก <เหตุ>" duration is now lifted from the TOR delivery clause (_duration_from_tor), falling back to daySLA + the standard event. Work keeps its full title. unit ← prCreatorUnitName leads para 1 and is the subject of para 2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>fce7fb0 -
Auto-form: generate the body in the exact PTT 2-paragraph format
The body is now an AI-generated เนื้อความ matching the real letters: para 1 context ("ตามที่ ปตท. ได้ดำเนินการ[จัดจ้าง/จัดซื้อ] <work> โดย <vendor> เป็น[ผู้รับจ้าง/ผู้ขาย]นั้น") and para 2 instruction ("<unit> ขอแจ้งให้บริษัทของท่านเริ่มเข้าดำเนินการ[ปฏิบัติงาน/ส่งมอบสินค้า] ได้นับถัดจากวันที่ <date> เป็นต้นไป [จนกว่างานจะแล้วเสร็จ…ไม่เกิน X วัน] ตาม[ใบสั่งจ้าง/ใบสั่งซื้อ] ที่อ้างถึงนั้น"). procurementType drives the ซื้อ/จ้าง swaps. - ai_clean: generate_body() (AI primary + IDENTICAL-format deterministic compose_body fallback so it's always on-format despite free-model 429s); thai_date(); งวด-aware เรื่อง suffix kept. - form1.docx: body replaced by a single [เนื้อความ] block; form_logic inserts the 2 paragraphs (first-line indent preserved) via insert_body_paragraphs(). - streamlit: start-date picker (วันที่เริ่มดำเนินการ); unit from prCreatorUnitName; gathers fields and calls generate_body during the AI animation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropi…256df8f -
Auto-form: always show งวด selector (single-งวด had no dropdown)
Single-งวด TORs previously showed only a caption, so there was no งวด to select. Now the งวด selector is always a selectbox: TOR-enumerated งวด when several exist, otherwise งวดเดียว + manual งวดที่ 1..12 (for On call / per-งวด letters). The AI prompt handles a manually-picked งวดที่ N over a งวดเดียว clause by reusing the overall timing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>83ce937 -
Auto-form: AI-clean กำหนดส่งมอบ into the document + งวด selector
- ai_clean.py (new): parse_nguad() lists selectable งวด (deterministic); clean_delivery() rewrites the chosen งวด's TOR clause into clean letter Thai via OpenRouter (gemma-4-31b-it:free primary, llama-3.3-70b + gpt-oss-120b free fallbacks, retry on 429, raw-text fallback so generation never hard-fails). Key from OPENROUTER_API_KEY env. - streamlit_app: งวดส่งมอบ selector (from the TOR กำหนดส่งมอบ); generate button renamed "สร้างเอกสารด้วย AI"; on generate, AI-clean the selected งวด and pass it + a "(งวดที่ N)" เรื่อง suffix to the form. - form1.docx + form_logic: new [กำหนดส่งมอบ] body block (filled or dropped if empty); fill the existing จำนวนวัน token from daySLA. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>0941280