Spaces:
Build error
Build error
Commit History
-
Merge branch 'feature/iterative-deep-research-workflows' of https://github.com/Josephrp/DeepCritical-HFSpace into feature/iterative-deep-research-workflows
Joseph PollackUnverified signature66c7f79 -
adds the initial iterative and deep research workflows
Joseph PollackUnverified signature687a1f1 -
Merge branch 'dev' into feature/iterative-deep-research-workflows
TonicUnverified signaturee6c2142 -
style: auto-format 4 files (ruff)
a805769 -
adds the initial iterative and deep research workflows
Joseph PollackUnverified signature731a241
-
feat: add hierarchical orchestration with web search (integrates PR #44) (#46)
Unverified signature* feat: add hierarchical orchestration with web search (from PR #44) Based on contribution by @EmployeeNo427 with fixes: New features: - WebSearchTool using DuckDuckGo for web searches - SubIterationMiddleware for research loop pattern - HierarchicalOrchestrator with judge-based refinement - RetrievalAgent for web-based evidence gathering - CodeExecutorAgent for Modal sandbox execution - LLMSubIterationJudge for LLM-based assessment - src/state/ package for state management Fixes applied: - Added chroma_db/ to .gitignore (was committed as binaries) - Added structlog logging per coding guidelines - Added pytest markers to new tests - Fixed silent exception swallowing in orchestrator - Preserved dual-mode architecture from PR #45 - Added "web" to SourceName type - Fixed mypy type errors Co-authored-by: EmployeeNo427 <45109567+EmployeeNo427@users.noreply.github.com> * fix: resolve mypy type errors in middleware and agents * fix: remove type argument from SubIterationTeam --------- …20f762e -
feat: implement dual-mode architecture (Simple + Advanced) (#45)
Unverified signature* docs: add dual-mode architecture specification Senior agent reviewed and approved. Key documents: - 00_SITUATION_AND_PLAN.md: Problem analysis, branch states, recommended path - 01_ARCHITECTURE_SPEC.md: Dual-mode architecture (Simple + Advanced) - 02_IMPLEMENTATION_PHASES.md: 6-phase implementation plan - 03_IMMEDIATE_ACTIONS.md: Quick reference checklist Architecture: pydantic-ai (structured outputs) + Microsoft Agent Framework (orchestration) are COMPLEMENTARY, not competing. Dual-mode allows graceful degradation to free tier when no API keys available. * docs: add follow-up review request for senior agent verification * feat: implement dual-mode architecture (Simple + Advanced) Phase 1 - Pydantic-AI Improvements (Simple Mode): - Add HuggingFace provider support in judges.py with get_model() - Add huggingface_model and hf_token config fields - Tests in test_judges_factory.py Phase 2 - Orchestrator Factory: - Implement create_orchestrator() with auto-detection logic - Simple m…b2929fc -
feat: implement async-safe rate limiting (Phase 17) (#40)
Unverified signature- Add 'limits' library dependency - Implement async RateLimiter with finer-grained polling (0.01s) - Refactor PubMedTool to use shared singleton limiter - Add comprehensive unit tests and demo script316dc7d -
feat: add roadmap summary and detailed improvement plans for data sources
- Introduced new documentation files outlining the current state and future improvements for DeepCritical's data sources: PubMed, ClinicalTrials.gov, Europe PMC, and OpenAlex. - Each document includes sections on current implementation, strengths, limitations, recommended improvements, and integration opportunities. - Added a comprehensive roadmap summary to guide future maintainers and enhance project maintainability.9286db5 -
fix: address CodeRabbit feedback
- Sort .env.example model keys alphabetically. - Narrow return type of create_demo() to gr.ChatInterface. - Confirmed embedding model vars are already wired in src/utils/config.py.be7e1a2 -
fix: repair Gradio accordion bug and cleanup env vars
- Unwrapped ChatInterface from gr.Blocks to fix settings accordion state (fixes P1_GRADIO_SETTINGS_CLEANUP). - Updated .env.example with missing variables and removed dead ones. - Updated documentation for the fix.fcc601a -
fix: address CodeRabbit feedback and CI failure
- Mock check_magentic_requirements in tests to run without OPENAI_API_KEY - Update stale "biorxiv" comment in models.py per CodeRabbit suggestion CI was failing because MagenticOrchestrator requires OPENAI_API_KEY, which exists locally in .env but not in CI environment.2ff16a3 -
fix(magentic): defensive text extraction & cleanup biorxiv refs
Add _extract_text to fix ChatMessage object output bug. Update bioRxiv strings to Europe PMC. Add regression test.3bfd42c -
fix: update references to Europe PMC in examples and documentation
Replaced mentions of bioRxiv with Europe PMC in the full stack and hypothesis demo scripts to reflect the current data sources. Updated the pyproject.toml to exclude specific directories from mypy checks using regex patterns for better clarity.9d21bf8 -
fix(config): increase max iterations to 10
Addressed P0-004 by increasing default max_iterations from 5 to 10 to allow deep search loops to complete successfully.72b2667 -
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