Spaces:
Running
Running
Commit History
30 days ago
-
fix(index): cache the LanceDB connection (#30)
Clawdinho +1: ClawdinhoUnverified signatureOpening the dataset was the expensive part: every access to db created a new connection and re-resolved the manifest, and search() touches it several times per call. One benchmark run issued thousands of requests and died on the HF rate limit, losing 41 of 50 cases. The connection is now cached per instance. Table handles stay plain properties: open_table() is one manifest read, and caching them would need invalidation after index() writes. Co-authored-by: Clawdinho <bot@users.noreply.github.com>f6dbdbf
-
refactor(scraper): extract flat extract_image_filename helper
Matheus Couto0a3cc53 -
fix(scraper): extract image from custom wikitext param for interactive comics
Matheus Couto41391d6 -
refactor(ingest): concurrent batch scraping and strip template inline comments
Matheus Couto654e000 -
fix(app): type annotate gradio components to satisfy ty check
Matheus Couto54f1847 -
refactor: native SearchIndex, ExplainXKCDScraper, and eject langchain-core
Matheus Couto1078c48
-
refactor: optimize ingest upserts, modularize tests, and add CI workflow
Matheus Coutob03103a
-
refactor: simplify codebase, split MCP server, drop xkcd.com ingestion
Matheus Couto5d85c1b
-
feat: add deepeval retrieval evaluation suite and explainxkcd sampler
Matheus Couto3a4c210 -
refactor: streamline codebase, prune unneeded tests and docs, polish SKILL and README per guidelines
Matheus Couto655a159 -
fix: use explicit is not None check for table initialization
Matheus Couto4bb8786 -
refactor: simplify src modules, remove server.py indirection, test public interfaces only
Matheus Couto4cc21c7 -
feat: modernize xkcd search with LanceDB, FastMCP native routes, and Hugging Face stack
Matheus Couto47f56d4
-
fix: center comic images in search results
Matheus CoutoThe card CSS set text-align:center, but Gradio's reset renders the image as display:block, which text-align does not center. Center with margin:0 auto so the block image sits in the middle of the card.040d616 -
feat: simplify search UI to clickable comic images
Matheus CoutoCards render as a single clickable image linking to the xkcd page, dropping the title, number, and alt-text caption. The controls stack as two rows: Query (80%) + number-of-comics input (20%) on top, a full-width Search button below, then the image results. Removes the page description and the (K) suffix from the number input label.06075eb -
fix: stop 403-rate-limit boot crashes from the GitHub API
Matheus CoutoThe server fetched the index by calling api.github.com/releases/latest, which rate-limits unauthenticated requests per-IP (60/hr). The HF Space's shared egress IP exhausted that quota, the download raised, and the whole app died at import. Switch to the direct releases/latest/download URL, which streams from the asset CDN and is not rate-limited, and route boot through _bootstrap() so a failed download logs loudly and starts on an empty schema-only index instead of crashing. Regression tests pin the direct-URL download and the no-crash boot.099c41a -
feat: add top-K input and rename app title to 'xkcd search'
Matheus CoutoThe search button now sits directly under the query box (per the chosen layout) instead of beside it. A Number input controls K, the number of comics returned, defaulting to 5 and capped at 20. The in-app title drops the hyphen. render_cards takes k and coerces ints for safety.a73b445 -
feat: add evals CLI for hit@k and MRR retrieval metrics
Matheus Coutouv run evals --index <path> runs the committed eval set through the query_top_k retrieval path the search_xkcd tool serves and prints hit@1, hit@5, MRR, and total/run/skipped counts. hit_at_k and mrr are hand-rolled pure functions; the runner takes an injectable retriever so tests use a stub with no index or network. Expected comics absent from the index are skipped, not failed. Fixes #9.01e1f86 -
fix: keep search button next to query box above results
Matheus CoutoThe Search button rendered after the Results output, so tall comic cards pushed it to the bottom of the page and every new search started with a scroll back up. Group the query box and button in a gr.Row above the results, and add a layout-order regression test.c9725d3 -
feat: compose search app and MCP endpoint behind build_app()
Matheus CoutoRetire the landing page and boot the search app and MCP endpoint from one process: build_app() returns an ASGI app serving the search UI at / and the streamable-http endpoint at /mcp, reusing the existing FastMCP object and index connection. A dedicated app.py entry avoids the double-boot trap so the index downloads exactly once; the Dockerfile entry updates to match. gradio is imported only inside build_app(), so server boot and the MCP test suite never pay its import cost. Composition-seam tests drive the composed app over ASGI HTTP: / serves the search app, /mcp answers MCP initialize + tools/call, and a subprocess check proves importing the server never imports gradio.babfee1
-
feat: add search app surface with ComicCard and a Gradio UI
Matheus CoutoImplements the domain seam search_cards(query, k=5) -> list[ComicCard] plus a thin Gradio UI over it: a text input whose submit renders up to 5 comic cards (image, title, number, link to the comic's url, and the alt text as a caption). Empty queries are a no-op; empty results show a "no comics found" message. Adds gradio as a runtime dependency. Pin torch to the CPU-only build: uv's [tool.uv.sources] only applies to direct dependencies, so torch is declared directly and resolved from download.pytorch.org/whl/cpu, dropping the ~3GB CUDA stack (nvidia, cuda-toolkit, triton) from the lock. Dev machines and the HF Space run without a GPU. Closes #6564b5ac
-
Simplify retry decorator and add builder dependency group
OpenClaw- Use tenacity.retry_if_exception() with custom predicate instead of incorrect retry_if_exception_type() & pattern - Change imports to 'import tenacity' style as requested - Add lazy import for mwparserfromhell (builder-only dependency) - Move tenacity and mwparserfromhell to [dependency-groups.builder] - Update index-daily workflow to sync with --group builder - Runtime image (HF Space) no longer installs builder-only deps Fixes #338a5f5c -
Add retry logic for explainxkcd 503 errors (#2)
Clawdinho +2: Clawdinho, ClawdinhoUnverified signature* Add retry logic with exponential backoff for explainxkcd API The daily indexing job was failing with 503 errors from explainxkcd.com. Added retry logic for transient HTTP errors (429, 500, 502, 503, 504) with exponential backoff (2s, 4s, 8s delays). Closes #1 * Refactor retry logic to use tenacity library Replace manual retry implementation with tenacity decorator. - Add tenacity>=9.0.0 dependency - Use @retry decorator with exponential backoff - Simplify fetch_explainxkcd from 27 lines to 15 lines - Remove time import (no longer needed) This addresses the review feedback to use a retry library instead of custom implementation. --------- Co-authored-by: Clawdinho <clawdinhobot@users.noreply.github.com> Co-authored-by: Clawdinho <clawdinhobot@users.norereply.github.com>b3cfcc4
-
simplify: use FastMCP custom_route for landing page
Matheus Couto- Use @mcp.custom_route decorator instead of manual Starlette app - Condensed landing HTML - Removed manual route mounting logicf19f95b -
fix: use Starlette directly to avoid FastAPI trailing slash redirect
Matheus Couto- Combine MCP app routes with landing route using Starlette - Remove fastapi dependency (starlette included in fastmcp) - Landing page for browsers, 406 for MCP clients at rootc160b13 -
feat: add browser landing page for MCP endpoint
Matheus Couto- Serve friendly HTML landing page when users visit root URL in browser - Return 406 for MCP clients (correct protocol behavior) - Mount FastMCP streamable-http app at /mcp - Add fastapi dependency for web framework - Browser detection via Accept headera032fe6 -
docs: add sync comments for EMBED_MODEL across builder, Dockerfile, workflow
Matheus Coutofb90855 -
refactor: simplify codebase
Matheus Couto- Use Docker ARG for embedding model name (single source of truth) - Rename iter_known_comics to get_indexed_comics with clear docstring - Simplify None check: article.wikitext if article else None - Update CLAUDE.md to reflect HF Spaces API restart instead of empty commitb6b5545 -
fix: lint issues and make tests compatible with deployed index
Matheus Couto87d30f2 -
fix: add module docstring to __init__.py for uv_build compatibility
Matheus Coutob39beca -
refactor: simplify cleanup from /simplify review
Matheus Couto +1: Claude Opus 4.7- Use new_client() in _download_index (adds User-Agent, removes duplication) - Add follow_redirects param to new_client (GitHub asset downloads need it) - Atomic index download: write to .tmp then rename to avoid partial files - Set row_factory=sqlite3.Row in open_connection; use dict(row) in search_xkcd to eliminate magic positional indices - Dockerfile: split uv sync into --no-install-project + model download + src so model layer is only invalidated by dep changes, not source changes - sync-to-hf: drop fetch-depth=0, shallow clone is sufficient for force push Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>b23b932 -
migrate to Hugging Face Spaces; consolidate builder module
Matheus Couto +1: Claude Opus 4.7- Add Dockerfile (Docker SDK Space, port 7860, bakes embedding model) - Switch server __main__ to HTTP transport (mcp.run transport=http) - Add HF Spaces YAML front-matter to README; update endpoint URL - Relax OAuth in test fixture: only applies to fastmcp.app hosts - Consolidate indexer into single builder.py; drop old split modules (config, embeddings, index_builder, indexer_main, release, sources) - Remove VCR cassettes; tests are live integration tests by design - Update workflow and pyproject for new layout Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>dd2f894
-
fix(server): don't let transient refresh errors kill the poll thread
Matheus Coutobf67018 -
refactor: avoid duplicate int() cast in get_comic
Matheus Coutofd5a782 -
refactor: drop unused upload_release; workflow uses gh CLI directly
Matheus Couto80cae99 -
feat: add get_comic tool for direct lookups by number
Matheus Coutoce72dad -
feat: resilient indexer with retry, limit, and incremental cache
Matheus Couto- Retry transient HTTP failures (5xx, 429, timeouts) with exponential backoff so a single flaky upstream doesn't discard a long run. - Accept XKCD_INDEXER_LIMIT to cap per-run work, enabling fast CI iteration before committing to the full ~3000-comic rebuild. - Cache build dir across workflow runs; the indexer skips already- indexed comics so partial runs accumulate into a full index. - workflow_dispatch inputs for limit and publish gate; release upload is skipped when a limit is set so debug runs don't publish partials.3971321 -
refactor: apply /simplify review
Matheus CoutoConsolidate duplicated test fixtures (client, fixture_numbers) into conftest. Replace hardcoded 384 with EMBED_DIM. Drop duplicate _open_readonly in server in favour of open_connection(read_only=True). Inline one-line helpers. Performance: batch top-k comic fetch into one IN query; delete chunks in two statements instead of N executemany rounds; skip connection swap in the hourly poll when the release asset is unchanged; replace iter_known_comics scan with COUNT queries at end of indexer run.9e3f8db -
feat: add xkcd semantic search MCP server with daily indexing
Matheus Couto8241729