Spaces:
Sleeping
Sleeping
Commit History
-
Pad token budgets by a reasoning allowance in HF fallback mode
pebaryan +1: Claude Fable 5The provider serving Qwen3.5-9B generates reasoning unconditionally (/no_think is ignored too) and it counts against max_tokens, so any budget under the reasoning length returned finish_reason=length with empty content — surat triage (1024 tokens) failed JSON parsing. Pad max_tokens by 4096 in _call whenever chat_template_kwargs is unsupported, covering chat and chat_with_tools alike, replacing the too-small 2048 floor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>87cc83e -
Fix HF Inference 400: fall back when chat_template_kwargs is rejected
pebaryan +1: Claude Fable 5The provider now serving Qwen3.5-9B rejects chat_template_kwargs with a bare 400, so every call failed. Detect rejection on first call, retry without extra_body, and remember the answer. Since thinking can no longer be disabled provider-side: floor max_tokens at 2048 so reasoning does not eat small budgets (with a one-shot retry for the detection call itself) and strip any <think> blocks from content. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>55e7211 -
Add MBG keracunan pangan example to Surat Konstituen tab
pebaryan +1: Claude Fable 5A parents-association letter about a school MBG food-poisoning incident (SPPG kitchen, distribution delay) — exercises triage, multi-request extraction, and pasal.id verification of food-safety regulations in one demo click. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>9f88afd -
Space card: short_description, backyard track tags, demo video up top
pebaryan +1: Claude Fable 5Lead the README with the problem story, the 18B model budget, the 51-second demo video, and the Taufik Basari usage credit so judges see the Backyard AI criteria answered before scrolling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>a05a3ef -
Stream live per-agent activity in the Gradio UI
pebaryan +1: Claude Fable 5Each run now captures the agents' rich Console log and streams it into an "Aktivitas Agen" chatbot panel, so the multi-agent pipeline (query expansion, canonical probes, parallel search, synthesis, ethics check) is visible live instead of a fake 3-step progress bar. Also passes console= through to the agents and degrades gracefully across Gradio 5/6 Chatbot APIs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>a08a3cb
-
Fix Space build dependency range
pebaryan0211060 -
Improve hackathon polish and use 9B models
pebaryana2d448c
-
chore: remove upload instruction, video already on YouTube
pebaryanaa36197 -
chore: set YouTube video ID jgYXyij1P9Q
pebaryan1e62ad3 -
chore: update final video (44s, 720p30, audio)
pebaryanab1f856 -
chore: update video ref to manim version (33s, 720p)
pebaryanb3153ac -
docs: add @ilhamfputra credit for pasal.id API on Kredit tab
pebaryanbe8d600 -
docs: add YouTube guide video section to Beranda tab
pebaryanfc0781c -
feat: add ethics guardrails, verifier, beranda + kredit tabs
pebaryan- Added Nilai-nilai Demokrasi & HAM to all 4 agent system prompts - Created ethics.py verifier (post-processing guardrail using SMALL LLM) - Added ethics_verify call to all 4 Gradio agent wrappers - Added Beranda tab with welcome, quick guide, and values framework - Added Kredit tab with Taufik Basari quote and credentials - Inpsired by feedback from @taufikbasari (DPR RI 2019-2024)00ce06b -
feat: add token setup guide in Settings tab for new users
pebaryan475ac07 -
fix: don't embed HF_TOKEN/PASAL_API_TOKEN in frontend HTML/JS
pebaryanafcfc32 -
fix: shared global rate limiter for pasal.id across all instances (1.5s delay)
pebaryan2bbcadf -
fix: enable Gradio queue for progress reporting
pebaryan704a7cf -
fix: add rate limiter + retry on 429 to pasal.id client
pebaryan010a05a -
fix: detect model IDs (no ://) as HF InferenceClient, not OpenAI
pebaryan4b0f200 -
fix: add Settings import in _pasal_settings
pebaryanacc89c0 -
fix: add missing LLMConfig/Settings import in custom endpoint branch
pebaryan9dc9f58 -
SMALL→Qwen3.5-9B, add extra_body(enable_thinking=False) to HFLLM
pebaryan1e0b0d8 -
Fix: use huggingface_hub InferenceClient as default backend
pebaryan- New hf_llm.py: HFLLM/HFLLMPool wrappers using InferenceClient (reliable on HF Spaces, unlike raw OpenAI client DNS resolution) - build_pool auto-selects HFLLMPool for HF defaults, LLMPool for custom - Defaults: BIG=Qwen3.5-27B, SMALL=Qwen3-8B (confirmed working!) - Settings tab: paste model IDs for HF, or full URLs for custom endpoints689c526 -
Switch to Qwen3-32B (BIG) and Qwen3-8B (SMALL) — confirmed working on HF API
pebaryan2706be4 -
Fix load_ruu_text: guard against long text being treated as file path
pebaryand57d141 -
Fix build_pool: don't call load_settings(), use env vars/HF defaults directly
pebaryan8377dcd -
Swap defaults: BIG→Qwen3.6-27B, SMALL→Qwen3.6-35B-A3B
pebaryan3ddf854 -
Remove -e . from requirements, add rich dep
pebaryanf98f213 -
Drop sdk_version — let HF resolve from requirements.txt
pebaryancfc7cb7 -
Fix colorTo value for HF metadata
pebaryanc6d2dda -
Bump Gradio to 6.x (latest is 6.14)
pebaryan69f1732 -
Add HF Space for Build Small Hackathon
pebaryan- app.py: Gradio web UI wrapping all 4 agents (analis_ruu, peneliti, penyusun, surat) as tabs - Default LLM backend: HF Inference API (Qwen3-30B-A3B + Qwen3-8B), zero-config for the demo - Settings tab lets users override endpoints / pasal.id token - requirements.txt: gradio, openai, httpx, pypdf, pydantic, dotenv All agent modules imported and tested. Branch: hackathon-space.72e8f1c
-
Expand canonical probes to remaining 10 sectors + fix surat strict toggle
pebaryan +1: Claude Opus 4.7Round-trips the 10 new fixtures' citation gap analysis from this session into 22 new canonical probes covering all DPR Komisi domains we hadn't yet covered. Probes added (all verified 'berlaku' on pasal.id pre-commit): Hukum / KPK kelembagaan (Komisi III): UU 8/1981 (KUHAP), UU 30/2002 (KPK), UU 19/2019 (KPK perubahan) Sosial / Bencana / Anak (Komisi VIII): UU 24/2007 (Penanggulangan Bencana) UU 35/2014 (Perlindungan Anak) UU 23/2004 (PKDRT) UU 11/2009 (Kesejahteraan Sosial) Diplomasi (Komisi I): UU 37/1999 (Hubungan Luar Negeri) UU 24/2000 (Perjanjian Internasional) Pertanian / Pangan (Komisi IV): UU 41/2009 (Perlindungan LP2B) BUMN / Perdagangan / Standardisasi (Komisi VI): UU 19/2003 (BUMN), UU 7/2014 (Perdagangan), UU 20/2014 (Standardisasi) UMKM (Komisi VII): UU 20/2008 (UMKM) Keuangan (Komisi XI): UU 4/2023 (P2SK), UU 21/2011 (OJK), UU 7/2021 (HPP) Energi / Lingkungan / Tambang (Komisi XII): UU 30/2007 (Ener…3a01e32
-
Add trusted_recent override for fresh regulations not yet on pasal.id
pebaryan +1: Claude Opus 4.7Closes the corpus-freshness gap surfaced when a user asked legawa to verify Perpres 8/2026 (RAN PE counter-extremism, signed 9 Feb 2026, publicly disseminated May 2026). pasal.id's 2026 corpus contains only Perpres 1/2026 — anything later is unverifiable through the normal search path even though the regulations are real. Mechanism: - New module src/legawa/tools/trusted_recent.py with TRUSTED_RECENT dict keyed by normalized citation reference (the form extract_citations produces, e.g. "Perpres 8/2026"). Each entry has full title, frbr_uri, status, signed_date, source_url, and a removal-timing note. - verify_citation now consults the trusted store as a fallback in two places: (a) when pasal.id search returns no matching hit, and (b) when pasal.id is unreachable entirely (auth failure, network error, 5xx). Topical-overlap is enforced against the trusted title — we don't blanket-whitelist a (number, year) tuple; the model still needs to claim the right subject. - Pasal…e1893c1
-
Test 6: MBG Keracunan Grobogan — multi-Komisi + sosial sector validation
pebaryan +1: Claude Opus 4.7Sixth live validation, on the most politically substantive topic to date: the Makan Bergizi Gratis (MBG) program post-keracunan incidents (Grobogan 9 Jan 2026, ~1,929 victims across 6 provinces in Jan 2026). Validates the Komisi-portfolio injection (ea8eaf7) on a four-Komisi cross-cut (IX + VIII + X + XI all relevant). Surat reply correctly addressed Komisi IX as primary with X/VIII/XI tembusan, pulling bracketed portfolios verbatim from the injected reference table. Classifier output: 'sektor=sosial_kemasyarakatan' (first run) / 'sektor=kesehatan' (second run) — sixth distinct sector across the test series, both valid framings for cross-cutting MBG topic. Patches: - Added 4 MBG-related canonical probes (Perpres 83/2024 BGN, Perpres 115/2025 MBG ops, UU 18/2012 Pangan, UU 8/1999 Perlindungan Konsumen). All 4 verified berlaku on pasal.id pre-commit. Closes the recurring retrieval-gap pattern that surfaced in Tests 3, 4, 5. - Refreshed scripts/regression_baseline.json: 19 → 23 …ca23118 -
Add corpus-drift regression check script + baseline
pebaryan +1: Claude Opus 4.7Replacement for the originally-planned remote scheduled agent (the routine API was unreachable). Local-only script that probes pasal.id for the static corpus dependencies legawa relies on: - 19 canonical-probe FRBR URIs in agents/peneliti._CANONICAL_PROBES - 21 regulation references across tests/fixtures/*.txt (extracted via the same extractor the agents use) For each, fetches current title + status + Dicabut oleh / Diubah oleh relationships and snapshots into scripts/regression_baseline.json. Future runs diff against the baseline and exit non-zero if any URI has acquired a new repeal/amendment marker, changed title or status, or if a fixture adds/removes references. Crucially does NOT re-run the live agents (which depend on the user's local llama.cpp endpoints and pasal.id token); only validates the static corpus dependencies. The user still needs to manually run legawa surat / research / draft to validate end-to-end behaviour after a model swap. Usage: python scripts/regres…5031740
-
Inject DPR Komisi 2024-2029 portfolio reference into agent prompts
pebaryan +1: Claude Opus 4.7Closes the persistent Komisi-number mismatch surfaced in Test 5: the BIG model addressed transport memos to Komisi IV (pertanian/kelautan) instead of Komisi V (infrastruktur/perhubungan). Generic Indonesian govt knowledge the model has weak/outdated training-time priors on, especially since the 2024-2029 period restructured into 13 commissions (was 11 in earlier periods). Adds KOMISI_DPR_2024_2029 constant in agents/penyusun.py — a 13-line authoritative table covering all current commissions with their primary bidang. Injected into: - penyusun SYSTEM_TEMPLATE (memo / pidato / naskah_akademik / siaran_pers) - surat REPLY_PROMPT (constituent reply drafts) Both system prompts now end with the Komisi reference and an explicit instruction: "Bila konstituen sudah menyebut Komisi tertentu, hormati pilihan tersebut" — so when the constituent letter explicitly addresses e.g. Komisi V, the reply respects that. Live re-run on the Test 5 Bekasi memo now correctly addresses 'Komisi V dan Komisi…ea8eaf7 -
Test 5: Bekasi train+EV taxi accident — transport sector + extractor fixes
pebaryan +1: Claude Opus 4.7Fifth live validation, on the 27 April 2026 KA Argo Bromo Anggrek collision with a stopped KRL involving a Green SM electric taxi at Bekasi Timur Station (16 fatalities, ongoing investigation). Surfaces and fixes three real defects in the same patch. Defects fixed: 1. Extractor missed Kemenhub's "PM <n>" numbering. Permenhub citations like "Permenhub No. PM 94 Tahun 2018" extracted as nothing — verifier never even saw them, so any Permenhub hallucination shipped silently. Added (?:(?:PM|KP|KEP|PER)\.?\s*)? to the regex between optional "Nomor" prefix and the digit group. 2. Extractor broke on parenthetical-aliased citations. "Peraturan Menteri Perhubungan (Permenhub) No. PM 94 Tahun 2018" wouldn't extract because closing paren between label and number wasn't tolerated. Widened the spacer to allow ) ] * _ characters. 3. Greedy ministry-suffix backtracking. "Peraturan Menteri Perhubungan Nomor PM 73 Tahun 2018" extracted as "Permen 3/2018" — the unbounded s…850ff59 -
Add amendment-chain probe to citation verifier (advisory only)
pebaryan +1: Claude Opus 4.7Closes the operative-vs-existed blind spot surfaced in Tests 2 and 4. After a citation matches by (kind, number, year) and topical alignment, the verifier now also fetches the regulation's relationships graph via get_law and surfaces 'Dicabut oleh' / 'Diubah oleh' findings as advisory notes for staff review. Two pasal.id quirks worked around: 1. The 'status' field is unreliable — UU 36/2014 still shows status=berlaku even though it was superseded by UU 17/2023 (omnibus). The relationships graph captures this correctly. 2. pasal.id mirrors relationships in both directions. UU 13/2003's 'Dicabut oleh' list contains UU 25/1997 (the older law UU 13/2003 actually revoked), not just newer successors. The disambiguator compares years extracted from FRBR URIs (akn/id/act/uu/<year>/<n>) and only treats relationships as authoritative when the related work is NEWER than the cited regulation. Pasal.id's relationships graph still has data-quality issues beyond the year-mirr…b01393f -
Extend canonical FRBR-URI probes to dosen and medical-education sectors
pebaryan +1: Claude Opus 4.7Closes the recurring retrieval gap surfaced in Test 3 (gaji dosen) and Test 4 (PPDS/internsip): pasal.id /search ranking missed several operative statutes that the constituent letters explicitly cited. Adds 7 new canonical probes, all verified 'berlaku' on pasal.id before adding: Pendidikan & kesejahteraan dosen: UU 14/2005 — Guru dan Dosen (akn/id/act/uu/2005/14) UU 12/2012 — Pendidikan Tinggi (akn/id/act/uu/2012/12) Perpres 19/2025 — Tukin Kemendiktisaintek (akn/id/act/perpres/2025/19) Kesehatan & pendidikan kedokteran: UU 17/2023 — Kesehatan omnibus (akn/id/act/uu/2023/17) PP 28/2024 — Pelaksanaan UU 17/2023 (akn/id/act/pp/2024/28) UU 20/2013 — Pendidikan Kedokteran (akn/id/act/uu/2013/20) Permenkes 7/2022 — Penyelenggaraan Internsip (akn/id/act/permenkes/2022/7) Live re-run of Test 3 dosen research now surfaces UU 14/2005 explicitly as primary instrument and quotes Perpres 19/2025 Pasal verbatim — both were absent before this commit. The synthesis…2a72bfe -
Add Test 4 — PPDS dan internsip dokter (cross-sector kesehatan validation)
pebaryan +1: Claude Opus 4.7Fourth live validation, designed as a cross-sector health-domain test covering PPDS perundungan, status hukum residen, beban finansial, and internsip placement at DTPK. No _CASE_FACTS entry — the SMALL-model domain classifier is the only domain anchor. Fixture: synthetic joint letter from a Residen Bedah year-3 at RSUP Hasan Sadikin and a Dokter Internsip in Sorong Selatan, on behalf of Forum Komunikasi Dokter Muda Indonesia (FKDMI). Cites UU 17/2023 (Pasal 193), PP 28/2024, Permenkes 7/2022, UU 20/2013 — multiple substantive asks to Komisi IX gabungan Komisi X. Results: - Surat: PT/kesehatan framing intact, cites UU 17/2023 + PP 28/2024 + Pasal 193, three legislator-scoped tindak lanjut, strict-mode passed. - Peneliti: 6 query expansions, 41 unique hits. Strikingly honest — flags 4 distinct retrieval gaps ("tidak ditemukan") rather than fabricating. Surfaces UU 17/2023, Peraturan MA 2/2023, PMK 66/2023. - Penyusun memo: classifier output 'sektor=kesehatan jenjang=- kasus=-' …805f292 -
Add Test 3 — gaji dan tunjangan dosen (PT-domain validation)
pebaryan +1: Claude Opus 4.7Third live validation, designed as the inverse of Test 2 (Kasus Ibam, K-12): this targets a Perguruan Tinggi topic with no _CASE_FACTS entry, so the SMALL-model domain classifier is the only domain anchor in play. Fixture: synthetic letter from a Lektor at UNS Surakarta, writing on behalf of Forum Dosen Indonesia (FDI) wilayah Jawa Tengah. Four substantive concerns: ASN-PTS disparity post-Permendiktisaintek 52/2025, status of dosen kontrak/honorer, RUU Sisdiknas relocation risk for UU 14/2005's tunjangan provisions, slow Serdos disbursement. Results: - Surat: PT framing intact, cites UU 14/2005 + PP 41/2009 + Perpres 19/2025, three legislator-scoped tindak lanjut, strict-mode passed. - Peneliti: 6 query expansions, 45 unique hits. Correctly identifies Permendiktisaintek 52/2025 as new operative regulation, traces evolution from Permendikbudristek 44/2024, cites PP 41/2009 + Permenristekdikti 20/2017 with proper FRBR URIs. Honestly flags that draft RUU Sisdiknas and UU 14/20…de87feb
-
Correct Kasus Ibam case status: tuntutan, not vonis
pebaryan +1: Claude Opus 4.7The 16 April 2026 hearing was the Jaksa Penuntut Umum's tuntutan reading (15 tahun penjara, denda Rp 1 miliar, uang pengganti Rp 16,92 miliar). The vonis hearing was scheduled for 12 Mei 2026 and has not been delivered. As of 2026-05-01 Ibrahim Arief is a TERDAKWA in an ongoing trial, not a terpidana — asas praduga tak bersalah applies. The original _CASE_FACTS block treated him as already convicted, which propagated into every memo this run produced and into the whitepaper. This commit: - Rewrites _CASE_FACTS in agents/penyusun.py to use 'terdakwa' / 'tuntutan' / 'sedang menjalani persidangan' language and explicitly forbids 'terpidana' / 'divonis' / 'dihukum'. - Corrects tests/fixtures/surat-chromebook-sekolah.txt to describe the prosecution's tuntutan reading rather than a fictitious putusan. - Adds an erratum at the top of the Kasus Ibam whitepaper documenting the error, its origin (misread WebSearch summary), and the Indonesian legal terminology that distinguishes tunt…1c88af7 -
Tighten verifier: institutional-context tokens don't count as topical match
pebaryan +1: Claude Opus 4.7Closes the "blind spot A" surfaced during the gemma4 Kasus Ibam diagnostic: the model cited Permen 24/2018 claiming an audit-mechanism topic, when the actual title is "Pengelolaan Arsip Terjaga di Lingkungan Kementerian Pendidikan dan Kebudayaan". The previous overlap check passed because claim and title shared "kementerian / pendidikan / kebudayaan" — institutional context, not topic. _topics_overlap now requires at least one shared token to be NON- institutional. Adds _INSTITUTIONAL_TOKENS frozenset covering generic government context (kementerian / pemerintah / lingkungan / instansi / lembaga / wilayah / kantor) and ministry/sector markers (pendidikan / kebudayaan / kesehatan / keuangan / ketenagakerjaan / pertanian / etc.). The acronym-expansion path is unaffected — institutional acronyms (MPR / DPR / KPK) still match their spelled-out forms because their expansion tokens (majelis / dewan / komisi / pemberantasan) are deliberately kept out of the institutional list. Tests: 4 new…ed43ddd -
Add SMALL-model domain classifier for Penyusun
pebaryan +1: Claude Opus 4.7Replaces the keyword-only domain anchor with a learned classifier that extracts (sektor, jenjang, instansi, kasus_terkait, kerangka_hukum, anti_drift) from topic + research + extra_instructions. The keyword path remains as a fallback for when the SMALL model produces unparseable JSON. Composition in _derive_domain_constraints: 1. _CASE_FACTS keyword overrides — always applied for known cases (e.g. Kasus Ibam) since hand-curated facts beat generated ones. 2. classify_domain() SMALL-model call — produces DomainAnalysis, rendered as constraint string into the BIG system prompt. 3. _keyword_domain_constraints fallback — fires only when classifier raises (parse error, transport error, validation error). Few-shot prompt with two worked examples (pendidikan + ketenagakerjaan) locks the output shape; Pydantic validation rejects malformed responses. 10 new unit tests cover parsing (clean / code-fence / prepended-text), classifier integration, render_constraints output, a…6dd4102 -
Add Kasus Ibam whitepaper — failure analysis, hardening, post-fix validation
pebaryan +1: Claude Opus 4.7Documents the second live validation run end-to-end: - The K-12 procurement corruption case stresses the system on a topic adjacent to (rather than contained in) pasal.id's regulatory corpus. - First-pass exposed five failure modes (domain drift K-12 to PT, date hallucination, content-blind citation verifier, missed canonical Tipikor laws, query-expansion noise). - Ten hardening patches applied (runtime context injection, citation module, strict post-generation verification, bidirectional context capture, acronym expansion, malformed-title guard, UUD whitelist, Permen-with-space regex, domain anchor + case-fact injection, canonical FRBR-URI probes, cache thread-safety). - Post-fix re-run produces a memo that passes strict citation verification with correct K-12 framing, accurate case facts (Ibrahim Arief, vonis 16 April 2026), and proper canonical citations (UU 31/1999 jo UU 20/2001, Perpres 16/2018 jo Perpres 12/2021). Verdict: legawa is fit for staff-augmentation…4291a50 -
Harden citation pipeline + add comprehensive test suite
pebaryan +1: Claude Opus 4.7Patches addressing all defects discovered during Kasus Ibam validation: - Citation extraction: bidirectional context capture (parenthetical-alias pattern catches "X (ALIAS) melalui CITATION"), citation-chain awareness (in "UU N/Y jo UU M/Y ... tentang Z" the topic attaches only to the closest citation), Permen-with-space and Perppu support. - Citation verification: content alignment via topical-token overlap with Indonesian institutional acronym expansion (MPR/DPR/KPK/BPK/SAKIP/...), malformed-title guard for pasal.id's echoed-title responses, UUD 1945 whitelist for the constitution. - Penyusun domain anchor: K-12 vs Perguruan Tinggi keyword triggers with mutual exclusion; case-fact injection (_CASE_FACTS) prepends authoritative facts to the system prompt for known cases (e.g. Kasus Ibam) so the BIG model can't drift to a stronger but wrong prior. - Peneliti canonical FRBR-URI probes: when topic touches Tipikor / pengadaan / outsourcing keywords, fetch the operativ…b4a776c
-
Add whitepaper documenting first live validation run
pebaryan +1: Claude Opus 4.7Documents end-to-end test of legawa against a real Indonesian hot topic (outsourcing Permenaker / #BuruhBersuaraBukanAnarkis), including: - Test methodology and scenario selection rationale - Results from Surat (triage + verified reply) and Peneliti (legal research) - Quality assessment against citation discipline, scope, and Bahasa register - Three defects discovered and fixed during the run - Reproduction steps Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>d7fd786 -
Fix three Windows/Qwen3 issues uncovered by first live run
pebaryan +1: Claude Opus 4.7- UTF-8 reconfigure stdio on Windows so rich glyphs ('OK', 'FAIL', etc.) don't crash on legacy cp1252 console. - Disable Qwen3 thinking mode by default via chat_template_kwargs; thinking tokens were exhausting max_tokens on classification calls before any answer was produced. Callers can opt back in with think=True. - Strip <think>...</think> blocks centrally in llm.chat so agents never see reasoning bleed into final content. Add tests/fixtures/surat-buruh-outsourcing.txt — synthetic constituent letter referencing UU 13/2003, UU 6/2023, and Putusan MK 27/PUU-IX/2011 for end-to-end smoke testing of surat agent. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>3265a18