Spaces:
Build error
Build error
Commit History
-
feat(search): implement ClinicalTrials.gov filtering (Phase 03)
Added filters for Interventional studies and Active/Completed status to ClinicalTrials tool. This removes noise from observational or terminated studies.d55440b -
feat(search): implement PubMed query preprocessing (Phase 02)
Added query preprocessing to strip question words and expand medical synonyms (e.g., 'Long COVID' -> 'PASC'). This fixes poor search results for natural language queries.e502f0d -
refactor(tools): replace BioRxiv with Europe PMC (Phase 01)
Replaced broken BioRxivTool with EuropePMCTool which supports keyword search. Updated all agents, MCP tools, and examples to use the new tool. Deleted legacy BioRxiv implementation.2f8ae1f -
fix: exclude reference_repos from mypy and cleanup
- Add mypy exclude for reference_repos/ and examples/ to prevent scanning of local reference code that isn't part of the project - Fix string concatenation in orchestrator_magentic.py - Fix formatting in examples (spaces around operators) - Remove resolved bug documentation (001, 002, 003)0a480cb -
refactor: enhance Gradio UI for improved user experience
- Updated header to include a more descriptive title and streamlined text. - Enhanced chat interface with clearer example prompts and added settings accordion for configuration. - Improved footer to clarify research tool limitations and active MCP server connection. These changes aim to provide a more intuitive and informative interface for users interacting with the drug repurposing research agent.291b9e6 -
fix: simplify Gradio UI to fit single viewport
- Reduce header to 2 lines (title + one-line description) - Remove MCP Tools tabs UI (MCP server still active at /gradio_api/mcp/) - Simplify examples (just questions, no extra params shown) - Minimal footer with disclaimer and MCP endpoint - Remove unused mcp_tools imports from app.py This fixes the header cutoff issue in HuggingFace Spaces iframe by reducing total content to fit within standard viewport height.8dc3e50 -
fix: address CodeRabbit feedback and P0 blockers
Code Fixes (HIGH priority): - Add API key/provider validation to prevent silent auth failures - Fix hardcoded manager model in orchestrator_magentic.py (now uses settings.openai_model) - Add bounds checking to JSON extraction in judges.py (prevents IndexError) - Fix fragile test assertion in test_judges_hf.py Code Quality (MEDIUM priority): - Add explicit type annotation for models_to_try: list[str] - Fix structured logging (f-string → structured params) - Align fallback query count (3 queries) between handlers Test Improvements: - Add @pytest.mark.unit decorator to TestHFInferenceJudgeHandler Documentation Sync: - Update Phase 3 docs to match actual implementation: - __init__ signature (simplified, no inline imports) - _extract_json (string split with bounds checking) - _call_with_retry (tenacity decorator, asyncio.get_running_loop()) - assess method (simplified model loop) - Update Phase 4 docs with ChatInterface additional_inputs for BYOK All 104 tests pass.f985224 -
docs: add P0 blockers documentation for Magentic mode implementation
- Introduced a new markdown document outlining critical blockers in the Magentic mode implementation. - Highlighted issues such as hardcoded OpenAI models, dependency source ambiguity, and the lack of a "Free Tier" for users. - Provided detailed impacts and required fixes for each identified issue to ensure a stable deployment. This documentation aims to facilitate resolution of critical issues and improve the overall user experience in Magentic mode.c2f7da2 -
feat: implement Magentic ChatAgent pattern with semantic state management
- Add src/agents/state.py: Thread-safe MagenticState with contextvars - Evidence store for structured citation access - EmbeddingService integration for semantic deduplication - Add src/agents/tools.py: AIFunction tools that update shared state - search_pubmed, search_clinical_trials, search_preprints - get_bibliography for ReportAgent citations - Tools return strings to LLM AND update state - Add src/agents/magentic_agents.py: ChatAgent factories - SearchAgent with search tools - JudgeAgent, HypothesisAgent, ReportAgent - Each agent has internal OpenAIChatClient - Update src/orchestrator_magentic.py: Use ChatAgent pattern - Initialize MagenticState at workflow start - Properly stream events from MagenticBuilder - Fix type errors for pre-commit mypy compatibility Implements Phase 5 spec for correct Microsoft Agent Framework integration.645a051 -
feat: implement HFInferenceJudgeHandler for free-tier AI analysis
Replace MockJudgeHandler with real AI analysis using HuggingFace Inference API: - Add HFInferenceJudgeHandler with chat_completion API - Model fallback chain: Llama 3.1 → Mistral → Zephyr (ungated) - Robust JSON extraction (handles markdown blocks, nested braces) - Tenacity retry with exponential backoff for rate limits - Fix app.py to use HF Inference when no paid API keys present Priority: User API key → Env API key → HF Inference (free) Hackathon judges now get real AI analysis without needing API keys. Set HF_TOKEN as Space secret for best model (Llama 3.1).7fab6d4
-
fix: wire EmbeddingService to simple orchestrator + improve search quality
Major fixes: - Wire EmbeddingService to simple orchestrator for semantic deduplication (was built but not connected - see docs/bugs/005) - Expand BioRxiv stop words (~100) and require minimum 2 term matches to filter out irrelevant papers - Fix MockJudgeHandler to return honest message instead of garbage drug candidates extracted via broken heuristics The simple orchestrator now uses local sentence-transformers for semantic deduplication without requiring any API keys. Bug documentation added in docs/bugs/005_services_not_integrated.md2e4a760 -
fix: disable ssr_mode to resolve intermittent gradio hydration issues
420d8ba -
fix: resolve Gradio UI cutoff by removing fill_height=True and restructuring layout
87de5ef -
fix: correct UI layout ordering - title at top
e4a1129 -
fix: move title/description into ChatInterface for proper HF Spaces layout
Root cause: gr.Markdown above gr.ChatInterface with fill_height=True causes layout competition where ChatInterface consumes all viewport space, pushing the Markdown behind the HuggingFace banner. Solution: Use ChatInterface's native title/description parameters instead of a separate gr.Markdown block. This is the Gradio-intended pattern for full-height chat layouts. Investigation documented in docs/bugs/002_gradio_ui_investigation.md998d05d -
fix: upgrade Gradio SDK to 6.0.1 and add fill_height for HF Spaces UI fix
Root cause: HuggingFace Spaces was deploying with sdk_version 5.33.0, but the UI cutoff bug (top content hidden beneath HF banner) was fixed in Gradio 5.36 via PR #11427. Changes: - README.md: sdk_version "5.33.0" → "6.0.1" (latest stable) - src/app.py: Added fill_height=True to gr.Blocks() for proper layout - docs/bugs/001_gradio_ui_cutoff.md: Full investigation documentation Fixes #31 References: - https://github.com/gradio-app/gradio/issues/11417 - https://github.com/gradio-app/gradio/pull/11427f236de1 -
fix: address CodeRabbit review feedback
- Move network reachability check to runtime in test_clinicaltrials.py (avoids 5s delay at test collection time) - Add explicit api_provider validation in app.py (raises ValueError for unsupported providers instead of silent fallback)923641c -
chore: clean up env config and upgrade model defaults
- Remove dead HF_TOKEN from .env.example (not used in codebase) - Remove unused enable_modal_analysis config option - Add missing env vars: LLM_PROVIDER, SEARCH_TIMEOUT, model names - Update default models to latest: gpt-5.1, claude-sonnet-4-5-20250929 - Reorganize .env.example with clear sections - Remove personal attribution comments (group project) All env vars now properly wired end-to-end.9e9bc6b -
fix: use config settings for model names instead of hardcoded values
ClaudeUnverified signatureModel names in app.py were hardcoded to "gpt-4o" and "claude-sonnet-4-20250514". Now uses settings.openai_model and settings.anthropic_model from config, allowing model names to be configured via environment variables.f5747b1 -
feat: add demo mode warnings and BYOK (Bring Your Own Key) support
ClaudeUnverified signatureChanges: - Add clear "Demo Mode" warning when no API keys are configured - Add BYOK feature allowing users to input their own API key in Gradio UI - Improve MockJudgeHandler to extract meaningful info from real search results instead of hardcoded "Drug A", "Drug B" placeholders - Add API provider selection (OpenAI/Anthropic) for user-provided keys - Skip integration tests when external APIs are unreachable (SSL/network issues) This fixes the issue where users saw mock data ("Drug A", "Drug B", "Finding 1") without any indication they were in demo mode. Now: 1. Users are clearly informed when running in demo mode 2. Users can enter their own API key for full AI-powered analysis 3. Demo mode shows real search results with extracted findings4d87419 -
fix: upgrade Gradio to 5.32.0+ for MCP server support
- Update gradio[mcp]>=5.32.0 in pyproject.toml and requirements.txt - Set sdk_version: "5.33.0" in README.md for HuggingFace Spaces - Remove deprecated `type="messages"` param (messages is default in 6.x) - Keep `mcp_server=True` which works in both 5.32+ and 6.x This is the proper fix for HuggingFace Spaces deployment: - mcp_server param requires Gradio 5.32.0+ - Messages format is now default, no explicit type needed - 101 tests pass, 71% coverage1812a2a -
feat: add smoke tests and fix Gradio 6.x compatibility
- Add smoke tests for app initialization (catches config errors before deploy) - Fix Gradio 6.x breaking changes: - Remove `theme` param from gr.Blocks (removed in 6.x) - Remove `type` param from gr.ChatInterface (removed in 6.x) - Add typer to dev dependencies (required by Gradio CLI for smoke tests) Smoke tests would have caught the previous deployment failures: - Invalid examples format - Gradio API changes 101 tests passing, 71% coverage2bd9462 -
fix: Gradio examples format for additional_inputs
ChatInterface with additional_inputs requires nested list format where each example includes values for all inputs. Before: ['question1', 'question2', ...] After: [['question1', 'simple'], ['question2', 'simple'], ...]f66a862 -
fix: make ResearchReport.references optional with default
The LLM doesn't always return the references field, causing validation failures. Adding default_factory=list makes it optional. TDD: Added tests/unit/utils/test_models.py with coverage for this case. Fixes #23f882609 -
docs: sync AI agent context files and fix final nitpicks
- Update GEMINI.md, CLAUDE.md, AGENTS.md to Phase 13 status - Add HuggingFace Spaces collaboration guidelines - Remove redundant evidence[:10] slice (method handles internally) - Add CodeExecutionError handling to verify_sandbox.py demo8bac750 -
refactor: address CodeRabbit nitpick suggestions
- Use Literal type for verdict field (type safety) - Use lru_cache for thread-safe singleton pattern - Fix ellipsis only appended when content is truncated - Clarify docstrings for enable_modal_analysis vs modal_available - Surface execution failures in verify_sandbox.py demo - Gate StatisticalAnalyzer integration test on LLM keys901acc3 -
fix: address CodeRabbit review feedback for Phase 13
- Use .get() to prevent KeyError when execution dict lacks 'error' key - Use context manager for file read to prevent resource leak in testf32a2ca -
fix: wire analyze_hypothesis MCP tool into Gradio app
Senior review found that analyze_hypothesis existed in mcp_tools.py but wasn't exposed through the Gradio MCP interface. Fixed.521d97d -
feat: implement phase 13 modal pipeline integration
7cc8b69 -
feat: enhance Gradio UI with MCP server support and new tool interfaces
- Updated the Gradio app to include support for the MCP server, enabling integration with Claude Desktop. - Added new interfaces for PubMed, Clinical Trials, bioRxiv, and a comprehensive search tool, enhancing the research capabilities. - Modified the demo creation function to reflect these updates and ensure a seamless user experience. Files modified: - src/app.py10e234c -
feat: add MCP tool wrappers for biomedical search tools
- Introduced a new module `mcp_tools.py` that provides asynchronous search functions for PubMed, ClinicalTrials.gov, and bioRxiv. - Each function includes detailed Google-style docstrings and type hints, ensuring clarity and usability. - Implemented a comprehensive search function that aggregates results from all sources, enhancing the search capabilities for biomedical literature. Files added: - src/mcp_tools.pyc114650 -
feat: Phase 11 bioRxiv Preprint Integration (#19)
Unverified signature* feat: Implement Phase 11 (bioRxiv Preprint Integration) * chore: add .mypy_cache to .gitignore * fix: address CodeRabbit review feedback for bioRxiv tool - Catch httpx.RequestError for network failures (major issue) - Use SourceName type alias in Citation model (DRY) - Only add '...' suffix when abstract is truncated - Add test for network error handlinge67c99f -
refactor: centralize embedding configuration in Settings
- Add openai_embedding_model and local_embedding_model to Settings - Update LlamaIndexRAGService to use settings.openai_embedding_model - Update EmbeddingService to use settings.local_embedding_model - Both services now read from centralized config instead of hardcoding - Constraint (OpenAI-only for cloud embeddings) is now explicit in config20c7bad -
refactor: address final CodeRabbit feedback
- Fix Windows path escaping in verify_sandbox.py using .as_posix() - Improve verdict detection with robust regex matching (avoid false positives) - Wire allow_network parameter to Modal sandbox block_network - Add finally block for sandbox resource cleanup - Use lru_cache for thread-safe singleton pattern - Add OpenAI-only note to LlamaIndexRAGService docstringb50fffd -
fix(rag): address remaining CodeRabbit feedback
- Validate OPENAI_API_KEY before creating LLM/embedding instances - Re-raise exceptions in retrieve() instead of returning empty list - Re-raise exceptions in query() instead of returning error string2f0030b -
refactor: address CodeRabbit review feedback for Mario integration
CRITICAL fix: - Centralize sandbox library versions (SANDBOX_LIBRARIES constant) - Use shared config for both Modal image and LLM prompts - Prevent version mismatch between generated code and execution MAJOR fixes: - Use run_in_executor() for blocking Modal calls in async context - Lazy initialize code executor to avoid failing on import - Remove redundant hypothesis check (unreachable code) - Simplify semantic search placeholder (dead code paths) Minor fixes: - Update docs: Docker → Modal Sandbox terminology - Fix docstring claiming ConfigurationError (only warns)cbd94a4 -
fix(rag): use get_content() for BaseNode compatibility
3f90da8 -
fix(rag): apply lazy imports and use centralized config
- Remove unused TYPE_CHECKING block (imports are in __init__) - Use settings.openai_model instead of hard-coded "gpt-4o-mini" - Fix line length in clear_collection() method - Change Document type hint to Any for lazy import compatibility055a3a7 -
feat: Integrate Mario's Modal code execution + LlamaIndex RAG
Cherry-picked from mario-dev branch: - src/tools/code_execution.py: Modal sandbox for LLM-generated code - src/services/llamaindex_rag.py: LlamaIndex + ChromaDB RAG service - src/agents/analysis_agent.py: Statistical analysis agent - examples/modal_demo/: Demo scripts for code execution - docs/workflow-diagrams.md: Architecture documentation Dependencies added as optional [modal] group: - modal>=0.63.0, llama-index, chromadb Config additions: - MODAL_TOKEN_ID, MODAL_TOKEN_SECRET, CHROMA_DB_PATH Co-authored-by: Mario <mario@contributor>3aa91e9 -
refactor: address CodeRabbit nitpicks for Phase 10
- Centralize SourceName type alias in models.py - Update search_handler.py to use SourceName (reduces cast brittleness) - Update app.py intro text to mention ClinicalTrials.gov - Update run_search.py docstring for multi-source search - DRY test setup with mock_requests_get fixture - Speed up error test by patching tenacity retry stop condition1bc9785 -
feat: Implement Phase 10 (ClinicalTrials.gov) with requests
4e2ccbf -
feat: Complete Phase 9 Source Cleanup (Remove WebTool) (#14)
* feat: complete Phase 9 source cleanup - Removed WebTool (src/tools/websearch.py) and related tests - Updated SearchHandler and models to support only PubMed - Refactored all examples and tests to remove web search dependencies - Added verification tests to ensure no WebTool references remain - Fixed all unit tests to align with strict 'pubmed' source typing * fix: address CodeRabbit review feedback - Deduplicate tenacity dependency in pyproject.toml - Remove 'and web' from search agent description - Normalize Citation source to 'pubmed' in search agent - Update app.py markdown to remove web search references - Update embeddings demo with realistic PubMed URL/author - Enhance SearchHandler tests to verify multi-tool aggregation * refactor: replace mock data with real PubMed data in embeddings demo * fix: address CodeRabbit review feedback - Fix nested test_search_handler_pubmed_only (was inside another test, never ran) - Improve test_no_webtool_references to catch `from src.tool…cd004e1
-
fix(report): add explicit JSON structure guidance in prompt
The LLM was returning incorrect JSON structures: - hypotheses_tested: dict instead of list - references: string URLs instead of list of dicts Added explicit format examples in SYSTEM_PROMPT to guide the LLM to produce valid structured output that passes Pydantic validation. This fixes the full_stack_demo ReportAgent validation errors.d01e70d -
fix: address all CodeRabbit Phase 8 review feedback
Actionable issue: - Forward additional_properties in run_stream for consistent metadata Nitpicks addressed: - Report event now uses actual agent message instead of hardcoded text - Citation validator: documented in-place mutation, use exact title match - Log truncation uses constant _MAX_URL_DISPLAY_LENGTH - Test asserts final_report is stored - Handle empty lists in markdown (hypotheses, drugs, limitations, refs) - Edge case: show "Untested" when supported==contradicted==0 - Document citations field in ReportSection as reserved for future usef1e4e5b -
fix: apply lazy init pattern and pydantic-ai fixes to ReportAgent (#12)
Applies the same fixes as Phase 7 HypothesisAgent: - Lazy initialization via _get_agent() to avoid API key requirement at import - Use output_type instead of result_type (pydantic-ai API) - Use result.output instead of result.data - Fix line length issues in tests - Proper mocking of get_model in tests3139749 -
fix: address CodeRabbit Phase 7 nitpicks
- Add truncation helper to avoid ellipsis on short messages - Verify query and evidence args in test_hypothesis_agenta6398e4 -
fix: address CodeRabbit Phase 7 review feedback
- Lazy initialize HypothesisAgent's pydantic-ai Agent to avoid requiring API keys at import time (fixes CI failure) - Add explicit default=None to primary_hypothesis field for Pydantic v2 compliancebc74531 -
feat(phase7): implement Hypothesis Agent for mechanistic reasoning
Add HypothesisAgent that generates Drug → Target → Pathway → Effect hypotheses based on collected evidence. Key features: Models: - MechanismHypothesis: structured hypothesis with confidence scoring - HypothesisAssessment: container for hypotheses with knowledge gaps Utilities: - MMR (Maximal Marginal Relevance) for diverse evidence selection - Sentence-aware truncation for clean text processing Agent: - HypothesisAgent generates 2-4 testable hypotheses per query - Integrated with EmbeddingService for semantic evidence selection Orchestrator: - Refactored MagenticOrchestrator into smaller methods - Added "hypothesizing" event type for UI feedback - Workflow: Search → Hypothesize → Targeted Search → Judge Tests: 53/53 passing, mypy clean, ruff cleanc690006 -
fix: address CodeRabbit Phase 6 review feedback
- Dockerfile: Add curl for HEALTHCHECK, use specific extras (not --all-extras) - app.py: Tighten Magentic mode key detection to require OpenAI specifically - embeddings.py: Move structlog import to module level - test_embeddings.py: Remove redundant numpy import506a9c0 -
fix: address CodeRabbit Phase 5 review feedback
Critical fixes: - Fix invalid model names (gpt-5.1 → gpt-4o, claude-sonnet-4-5 → claude-sonnet-4-20250514) - Add OpenAI key validation in MagenticOrchestrator with clear error message - Document Magentic mode's OpenAI-only requirement Nitpicks: - Add streaming icon to AgentEvent.to_markdown() - Use exact equality for PubMed placeholder detection - Update app.py info text for API key requirements - Add language identifiers to markdown code blocks in docsd247864