fangbot 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fangbot-0.1.0/.github/workflows/ci.yml +52 -0
- fangbot-0.1.0/.github/workflows/publish.yml +27 -0
- fangbot-0.1.0/.gitignore +59 -0
- fangbot-0.1.0/.python-version +1 -0
- fangbot-0.1.0/CHANGELOG.md +27 -0
- fangbot-0.1.0/CLAUDE.md +108 -0
- fangbot-0.1.0/CONTRIBUTING.md +166 -0
- fangbot-0.1.0/LICENSE +21 -0
- fangbot-0.1.0/PKG-INFO +163 -0
- fangbot-0.1.0/README.md +119 -0
- fangbot-0.1.0/SECURITY.md +24 -0
- fangbot-0.1.0/prep.md +419 -0
- fangbot-0.1.0/pyproject.toml +70 -0
- fangbot-0.1.0/src/fangbot/__init__.py +3 -0
- fangbot-0.1.0/src/fangbot/brain/__init__.py +0 -0
- fangbot-0.1.0/src/fangbot/brain/guardrails.py +76 -0
- fangbot-0.1.0/src/fangbot/brain/providers/__init__.py +6 -0
- fangbot-0.1.0/src/fangbot/brain/providers/base.py +32 -0
- fangbot-0.1.0/src/fangbot/brain/providers/claude.py +151 -0
- fangbot-0.1.0/src/fangbot/brain/providers/openai.py +148 -0
- fangbot-0.1.0/src/fangbot/brain/react.py +207 -0
- fangbot-0.1.0/src/fangbot/brain/system_prompt.py +36 -0
- fangbot-0.1.0/src/fangbot/config.py +62 -0
- fangbot-0.1.0/src/fangbot/evaluation/__init__.py +0 -0
- fangbot-0.1.0/src/fangbot/gateway/__init__.py +0 -0
- fangbot-0.1.0/src/fangbot/gateway/cli.py +497 -0
- fangbot-0.1.0/src/fangbot/gateway/models_catalog.py +104 -0
- fangbot-0.1.0/src/fangbot/gateway/setup.py +195 -0
- fangbot-0.1.0/src/fangbot/memory/__init__.py +0 -0
- fangbot-0.1.0/src/fangbot/memory/audit.py +98 -0
- fangbot-0.1.0/src/fangbot/memory/session.py +42 -0
- fangbot-0.1.0/src/fangbot/models.py +48 -0
- fangbot-0.1.0/src/fangbot/safety/__init__.py +0 -0
- fangbot-0.1.0/src/fangbot/skills/__init__.py +0 -0
- fangbot-0.1.0/src/fangbot/skills/mcp_client.py +92 -0
- fangbot-0.1.0/src/fangbot/skills/tool_registry.py +30 -0
- fangbot-0.1.0/src/fangbot/workflows/__init__.py +0 -0
- fangbot-0.1.0/tests/__init__.py +0 -0
- fangbot-0.1.0/tests/conftest.py +112 -0
- fangbot-0.1.0/tests/test_audit.py +104 -0
- fangbot-0.1.0/tests/test_cli.py +211 -0
- fangbot-0.1.0/tests/test_mcp_client.py +97 -0
- fangbot-0.1.0/tests/test_providers.py +218 -0
- fangbot-0.1.0/tests/test_react_loop.py +211 -0
- fangbot-0.1.0/tests/test_setup.py +95 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v6
|
|
23
|
+
|
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
+
run: uv python install ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --extra dev --extra openai
|
|
29
|
+
|
|
30
|
+
- name: Run linter
|
|
31
|
+
run: uv run ruff check .
|
|
32
|
+
|
|
33
|
+
- name: Check formatting
|
|
34
|
+
run: uv run ruff format --check .
|
|
35
|
+
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: uv run python -m pytest -v --tb=short
|
|
38
|
+
|
|
39
|
+
build:
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
needs: test
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
|
|
45
|
+
- name: Install uv
|
|
46
|
+
uses: astral-sh/setup-uv@v6
|
|
47
|
+
|
|
48
|
+
- name: Build package
|
|
49
|
+
run: uv build
|
|
50
|
+
|
|
51
|
+
- name: Verify wheel
|
|
52
|
+
run: ls -la dist/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment: pypi
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # trusted publishing
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v6
|
|
22
|
+
|
|
23
|
+
- name: Build package
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Publish to PyPI
|
|
27
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
fangbot-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.whl
|
|
11
|
+
*.manifest
|
|
12
|
+
*.spec
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
ENV/
|
|
19
|
+
|
|
20
|
+
# uv
|
|
21
|
+
uv.lock
|
|
22
|
+
|
|
23
|
+
# IDE
|
|
24
|
+
.idea/
|
|
25
|
+
.vscode/
|
|
26
|
+
*.swp
|
|
27
|
+
*.swo
|
|
28
|
+
*~
|
|
29
|
+
.DS_Store
|
|
30
|
+
|
|
31
|
+
# Environment / secrets
|
|
32
|
+
.env
|
|
33
|
+
.env.*
|
|
34
|
+
!.env.example
|
|
35
|
+
*.pem
|
|
36
|
+
*.key
|
|
37
|
+
credentials.json
|
|
38
|
+
|
|
39
|
+
# Testing / coverage
|
|
40
|
+
.pytest_cache/
|
|
41
|
+
.coverage
|
|
42
|
+
htmlcov/
|
|
43
|
+
.hypothesis/
|
|
44
|
+
|
|
45
|
+
# Logs
|
|
46
|
+
logs/
|
|
47
|
+
*.log
|
|
48
|
+
|
|
49
|
+
# Claude Code
|
|
50
|
+
.claude/
|
|
51
|
+
|
|
52
|
+
# Ruff
|
|
53
|
+
.ruff_cache/
|
|
54
|
+
|
|
55
|
+
# mypy
|
|
56
|
+
.mypy_cache/
|
|
57
|
+
|
|
58
|
+
# Jupyter
|
|
59
|
+
.ipynb_checkpoints/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-03-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of Fangbot
|
|
13
|
+
- ReAct loop engine for clinical reasoning with mandatory MCP tool use
|
|
14
|
+
- Anthropic Claude provider (Opus 4.6, Sonnet 4.6, Haiku 4.5, Sonnet 4, Opus 4)
|
|
15
|
+
- OpenAI provider (GPT-5, GPT-4o, GPT-4.1, o3, o4-mini)
|
|
16
|
+
- MCP client connecting to OpenMedicine server via stdio
|
|
17
|
+
- Interactive CLI with `fangbot chat` command
|
|
18
|
+
- Slash commands: `/help`, `/status`, `/claude`, `/openai`, `/model`, `/models`, `/clear`, `/history`, `/compact`
|
|
19
|
+
- Interactive model picker with categorized display
|
|
20
|
+
- `fangbot init` setup wizard — provider config, API key, MCP connection test
|
|
21
|
+
- `~/.fangbot/` config home for settings and logs
|
|
22
|
+
- JSONL audit trail for all agent interactions
|
|
23
|
+
- Clinical guardrails enforcing mandatory tool use
|
|
24
|
+
- Session context with conversation history management
|
|
25
|
+
- 62 unit tests with full mock coverage
|
|
26
|
+
|
|
27
|
+
[0.1.0]: https://github.com/RamosFBC/fangbot/releases/tag/v0.1.0
|
fangbot-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Fangbot
|
|
2
|
+
|
|
3
|
+
A clinical reasoning agent powered by [OpenMedicine](https://github.com/open-medicine/openmedicine) — fangs of the healing serpent. Connects to the OpenMedicine MCP server to perform deterministic, auditable clinical calculations. **This is NOT a diagnostic tool** — it is a research platform for validating LLM-based clinical tool orchestration.
|
|
4
|
+
|
|
5
|
+
## Critical Constraint
|
|
6
|
+
|
|
7
|
+
> The agent MUST call OpenMedicine's deterministic MCP tools for any clinical calculation. It must NEVER compute scores, doses, or risk stratifications from its own parametric knowledge.
|
|
8
|
+
|
|
9
|
+
Enforced by: system prompt rules, evaluation harness (protocol adherence check), and audit trail verification. Results without tool-call traces are failures regardless of correctness.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv sync # Install dependencies
|
|
15
|
+
uv run fangbot chat # Interactive CLI mode
|
|
16
|
+
uv run fangbot run studies/chadsvasc/config.yaml # Batch evaluation
|
|
17
|
+
uv run fangbot report studies/chadsvasc/results/ # Generate comparison report
|
|
18
|
+
uv run python -m pytest -v # Run tests
|
|
19
|
+
uv run python -m pytest tests/test_file.py -v # Run single test file
|
|
20
|
+
uv run python -m pytest -k "test_name" -v # Run specific test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
Environment variables use the `FANGBOT_` prefix (e.g. `FANGBOT_PROVIDER`, `FANGBOT_MODEL`). The agent also reads native SDK env vars (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`) as fallback.
|
|
26
|
+
|
|
27
|
+
## Tech Stack
|
|
28
|
+
|
|
29
|
+
- **Language:** Python 3.10+
|
|
30
|
+
- **Package manager:** uv (matches OpenMedicine)
|
|
31
|
+
- **LLM SDKs:** anthropic, openai, google-genai (multi-model benchmarking)
|
|
32
|
+
- **MCP client:** mcp (Python SDK) — connects to OpenMedicine via stdio
|
|
33
|
+
- **Validation:** Pydantic
|
|
34
|
+
- **CLI:** typer + rich
|
|
35
|
+
- **Testing:** pytest + Hypothesis
|
|
36
|
+
- **Audit format:** JSON-lines (.jsonl)
|
|
37
|
+
|
|
38
|
+
## Architecture
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Gateway → Brain → Skills (MCP) → Memory
|
|
42
|
+
→ Evaluation
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Layer | Path | Purpose |
|
|
46
|
+
|-------|------|---------|
|
|
47
|
+
| Gateway | `src/fangbot/gateway/` | Case ingestion (CLI, API, file loader) |
|
|
48
|
+
| Brain | `src/fangbot/brain/` | ReAct loop + clinical guardrails + LLM providers |
|
|
49
|
+
| Skills | `src/fangbot/skills/` | MCP client connecting to OpenMedicine server |
|
|
50
|
+
| Memory | `src/fangbot/memory/` | Session context, audit log (JSONL), chain-of-thought |
|
|
51
|
+
| Workflows | `src/fangbot/workflows/` | Study-specific clinical workflows |
|
|
52
|
+
| Evaluation | `src/fangbot/evaluation/` | Batch runner, gold standard comparison, metrics |
|
|
53
|
+
| Safety | `src/fangbot/safety/` | Validators, contraindication flags |
|
|
54
|
+
|
|
55
|
+
## MCP Integration Rules
|
|
56
|
+
|
|
57
|
+
- The agent spawns `uv run open-medicine-mcp` as a subprocess and communicates via stdin/stdout
|
|
58
|
+
- The agent NEVER imports OpenMedicine directly — always goes through MCP protocol
|
|
59
|
+
- Available meta-tools: `search_clinical_calculators`, `execute_clinical_calculator`, `search_guidelines`, `retrieve_guideline`
|
|
60
|
+
- OpenMedicine >= 0.4.0 required
|
|
61
|
+
|
|
62
|
+
## LLM Providers
|
|
63
|
+
|
|
64
|
+
Abstract base in `brain/providers/base.py`. Implementations:
|
|
65
|
+
- `claude.py` — Anthropic Claude (primary)
|
|
66
|
+
- `openai.py` — OpenAI GPT-4/GPT-5
|
|
67
|
+
- `gemini.py` — Google Gemini (planned)
|
|
68
|
+
- `ollama.py` — Local models via Ollama (planned)
|
|
69
|
+
|
|
70
|
+
All providers must implement the same interface for benchmark comparability.
|
|
71
|
+
|
|
72
|
+
## Research Studies
|
|
73
|
+
|
|
74
|
+
| Study | Workflow | Calculator | Complexity |
|
|
75
|
+
|-------|----------|-----------|------------|
|
|
76
|
+
| 1: Renal Dosing | `renal_dosing.py` | CKD-EPI + dose adjustment | Multi-step chain |
|
|
77
|
+
| 2: Glasgow Coma Score | `gcs_assessment.py` | GCS calculator | Narrative extraction |
|
|
78
|
+
| 3: CHA2DS2-VASc | `chadsvasc.py` | CHA2DS2-VASc | Single calculator (simplest) |
|
|
79
|
+
|
|
80
|
+
Build order: Study 3 first (simplest), then Study 2, then Study 1.
|
|
81
|
+
|
|
82
|
+
## Evaluation Metrics
|
|
83
|
+
|
|
84
|
+
- **accuracy** — exact score match
|
|
85
|
+
- **mae** — mean absolute error
|
|
86
|
+
- **kappa** — Cohen's Kappa (inter-rater reliability)
|
|
87
|
+
- **sensitivity/specificity** — per risk tier
|
|
88
|
+
- **protocol_adherence** — did the agent call the right tools?
|
|
89
|
+
- **cot_quality** — was reasoning auditable and correct?
|
|
90
|
+
|
|
91
|
+
## Audit Log
|
|
92
|
+
|
|
93
|
+
Every agent run produces a JSONL audit file with events: `case_received`, `think`, `tool_call`, `tool_result`, `synthesis`, `evaluation`. Each tool result includes DOI references.
|
|
94
|
+
|
|
95
|
+
## Code Style
|
|
96
|
+
|
|
97
|
+
- Pydantic models for all data structures
|
|
98
|
+
- Type hints on all public functions
|
|
99
|
+
- Async where appropriate (MCP client, LLM calls)
|
|
100
|
+
- Follow OpenMedicine patterns for consistency
|
|
101
|
+
|
|
102
|
+
## Gotchas
|
|
103
|
+
|
|
104
|
+
- MCP communication is stdio-based — never try HTTP/WebSocket to OpenMedicine
|
|
105
|
+
- Synthetic patient data only — no real patient data (per Resolucao CNS 510/2016)
|
|
106
|
+
- metric_mismatch_warning from tools must be included verbatim in responses
|
|
107
|
+
- Contraindication results must be prominently flagged, never downplayed
|
|
108
|
+
- Gold standard cases require expert validation before use in evaluation
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Contributing to Fangbot
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Fangbot is an open-source clinical reasoning agent and we welcome contributions of all kinds.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
Be respectful, constructive, and inclusive. We follow the [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
### Prerequisites
|
|
12
|
+
|
|
13
|
+
- Python 3.10+
|
|
14
|
+
- [uv](https://docs.astral.sh/uv/) package manager
|
|
15
|
+
- An API key for at least one LLM provider (Anthropic or OpenAI)
|
|
16
|
+
|
|
17
|
+
### Development setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Clone the repo
|
|
21
|
+
git clone https://github.com/RamosFBC/fangbot.git
|
|
22
|
+
cd fangbot
|
|
23
|
+
|
|
24
|
+
# Install all dependencies (dev + optional providers)
|
|
25
|
+
uv sync --extra dev --extra openai
|
|
26
|
+
|
|
27
|
+
# Run tests
|
|
28
|
+
uv run python -m pytest -v
|
|
29
|
+
|
|
30
|
+
# Run linter
|
|
31
|
+
uv run ruff check .
|
|
32
|
+
|
|
33
|
+
# Run formatter
|
|
34
|
+
uv run ruff format .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Project structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
src/fangbot/
|
|
41
|
+
├── gateway/ # CLI interface (typer + rich)
|
|
42
|
+
├── brain/ # ReAct loop, providers, guardrails
|
|
43
|
+
│ └── providers/ # LLM provider implementations
|
|
44
|
+
├── skills/ # MCP client, tool registry
|
|
45
|
+
└── memory/ # Session context, audit logger
|
|
46
|
+
tests/ # pytest test suite
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Development workflow
|
|
50
|
+
|
|
51
|
+
1. **Fork** the repository
|
|
52
|
+
2. **Create a branch** from `main`: `git checkout -b feat/your-feature`
|
|
53
|
+
3. **Make your changes** — write tests for new functionality
|
|
54
|
+
4. **Run the full test suite**: `uv run python -m pytest -v`
|
|
55
|
+
5. **Run the linter**: `uv run ruff check .`
|
|
56
|
+
6. **Commit** with a clear message (see conventions below)
|
|
57
|
+
7. **Push** and open a Pull Request
|
|
58
|
+
|
|
59
|
+
### Branch naming
|
|
60
|
+
|
|
61
|
+
| Prefix | Use for |
|
|
62
|
+
|--------|---------|
|
|
63
|
+
| `feat/` | New features |
|
|
64
|
+
| `fix/` | Bug fixes |
|
|
65
|
+
| `docs/` | Documentation |
|
|
66
|
+
| `refactor/` | Code restructuring |
|
|
67
|
+
| `test/` | Test additions/fixes |
|
|
68
|
+
|
|
69
|
+
### Commit messages
|
|
70
|
+
|
|
71
|
+
Use clear, descriptive commit messages:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
Add renal dosing workflow with CKD-EPI integration
|
|
75
|
+
|
|
76
|
+
Implements the multi-step renal dosing calculation chain using
|
|
77
|
+
CKD-EPI GFR estimation followed by dose adjustment lookup.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- Start with a verb (Add, Fix, Update, Remove, Refactor)
|
|
81
|
+
- First line under 72 characters
|
|
82
|
+
- Body explains **why**, not just **what**
|
|
83
|
+
|
|
84
|
+
## Testing
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Full test suite
|
|
88
|
+
uv run python -m pytest -v
|
|
89
|
+
|
|
90
|
+
# Single test file
|
|
91
|
+
uv run python -m pytest tests/test_react_loop.py -v
|
|
92
|
+
|
|
93
|
+
# Specific test
|
|
94
|
+
uv run python -m pytest -k "test_guardrail" -v
|
|
95
|
+
|
|
96
|
+
# Integration tests (requires open-medicine-mcp)
|
|
97
|
+
uv run python -m pytest -m integration -v
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Writing tests
|
|
101
|
+
|
|
102
|
+
- Every new feature needs tests
|
|
103
|
+
- Use `pytest` fixtures and `tmp_path` for file operations
|
|
104
|
+
- Mock external services (LLM APIs, MCP server) — see `tests/conftest.py`
|
|
105
|
+
- Use `@pytest.mark.asyncio` for async tests
|
|
106
|
+
- Use `@pytest.mark.integration` for tests requiring a live MCP server
|
|
107
|
+
|
|
108
|
+
## Code style
|
|
109
|
+
|
|
110
|
+
- **Linter/formatter:** ruff (configured in `pyproject.toml`)
|
|
111
|
+
- **Type hints** on all public functions
|
|
112
|
+
- **Pydantic models** for all data structures
|
|
113
|
+
- **Line length:** 100 characters
|
|
114
|
+
- **Target:** Python 3.10+ (no walrus operator in hot paths, use `from __future__ import annotations`)
|
|
115
|
+
|
|
116
|
+
Run before committing:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
uv run ruff check . --fix
|
|
120
|
+
uv run ruff format .
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Adding a new LLM provider
|
|
124
|
+
|
|
125
|
+
1. Create `src/fangbot/brain/providers/your_provider.py`
|
|
126
|
+
2. Implement the `LLMProvider` ABC from `base.py`
|
|
127
|
+
3. Add the provider to `_create_provider()` in `gateway/cli.py`
|
|
128
|
+
4. Add models to `gateway/models_catalog.py`
|
|
129
|
+
5. Add the SDK as an optional dependency in `pyproject.toml`
|
|
130
|
+
6. Write tests in `tests/test_providers.py`
|
|
131
|
+
|
|
132
|
+
## Adding a new clinical workflow
|
|
133
|
+
|
|
134
|
+
1. Create `src/fangbot/workflows/your_workflow.py`
|
|
135
|
+
2. Define gold standard test cases
|
|
136
|
+
3. Add to the study configuration
|
|
137
|
+
4. Write evaluation tests
|
|
138
|
+
|
|
139
|
+
## Critical rules
|
|
140
|
+
|
|
141
|
+
- **Never compute clinical scores from LLM knowledge** — always use MCP tools
|
|
142
|
+
- **Never import OpenMedicine directly** — communicate via MCP protocol only
|
|
143
|
+
- **Synthetic patient data only** — no real patient data (per Resolucao CNS 510/2016)
|
|
144
|
+
- **Always include DOI references** from tool results in responses
|
|
145
|
+
- **Never downplay contraindication flags** from MCP tools
|
|
146
|
+
|
|
147
|
+
## Releasing
|
|
148
|
+
|
|
149
|
+
Releases follow [Semantic Versioning](https://semver.org/):
|
|
150
|
+
|
|
151
|
+
- **MAJOR** (1.0.0) — breaking API changes
|
|
152
|
+
- **MINOR** (0.2.0) — new features, backward compatible
|
|
153
|
+
- **PATCH** (0.1.1) — bug fixes
|
|
154
|
+
|
|
155
|
+
Releases are automated via GitHub Actions when a version tag is pushed:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Update version in pyproject.toml and src/fangbot/__init__.py
|
|
159
|
+
# Update CHANGELOG.md
|
|
160
|
+
git tag v0.2.0
|
|
161
|
+
git push origin v0.2.0
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Questions?
|
|
165
|
+
|
|
166
|
+
Open an [issue](https://github.com/RamosFBC/fangbot/issues) or start a [discussion](https://github.com/RamosFBC/fangbot/discussions).
|
fangbot-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RamosFBC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
fangbot-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fangbot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Clinical reasoning agent powered by OpenMedicine — fangs of the healing serpent
|
|
5
|
+
Project-URL: Homepage, https://github.com/RamosFBC/fangbot
|
|
6
|
+
Project-URL: Repository, https://github.com/RamosFBC/fangbot
|
|
7
|
+
Project-URL: Issues, https://github.com/RamosFBC/fangbot/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/RamosFBC/fangbot/blob/main/CHANGELOG.md
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,clinical,llm,mcp,openmedicine,reasoning
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: anthropic>=0.40.0
|
|
25
|
+
Requires-Dist: mcp>=1.0.0
|
|
26
|
+
Requires-Dist: open-medicine>=0.6.0
|
|
27
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
30
|
+
Requires-Dist: rich>=13.0.0
|
|
31
|
+
Requires-Dist: typer>=0.12.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
37
|
+
Provides-Extra: gemini
|
|
38
|
+
Requires-Dist: google-genai>=1.0.0; extra == 'gemini'
|
|
39
|
+
Provides-Extra: ollama
|
|
40
|
+
Requires-Dist: ollama>=0.4.0; extra == 'ollama'
|
|
41
|
+
Provides-Extra: openai
|
|
42
|
+
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# Fangbot
|
|
46
|
+
|
|
47
|
+
[](https://pypi.org/project/fangbot/)
|
|
48
|
+
[](https://www.python.org/downloads/)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
[](https://github.com/RamosFBC/fangbot/actions/workflows/ci.yml)
|
|
51
|
+
|
|
52
|
+
Clinical reasoning agent powered by [OpenMedicine](https://github.com/open-medicine/openmedicine) — fangs of the healing serpent.
|
|
53
|
+
|
|
54
|
+
**This is NOT a diagnostic tool** — it is a research platform for validating LLM-based clinical tool orchestration.
|
|
55
|
+
|
|
56
|
+
## What it does
|
|
57
|
+
|
|
58
|
+
Fangbot connects to the OpenMedicine MCP server to perform deterministic, auditable clinical calculations via a ReAct (Reasoning + Acting) loop. It supports multiple LLM providers for benchmarking.
|
|
59
|
+
|
|
60
|
+
**Critical constraint:** The agent always calls OpenMedicine's MCP tools for clinical calculations — it never computes scores from its own knowledge.
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Recommended: install as a global CLI tool
|
|
66
|
+
pipx install fangbot
|
|
67
|
+
|
|
68
|
+
# Or with uv
|
|
69
|
+
uv tool install fangbot
|
|
70
|
+
|
|
71
|
+
# With OpenAI support
|
|
72
|
+
pipx install "fangbot[openai]"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quick start
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Interactive setup — configure provider, API key, test MCP connection
|
|
79
|
+
fangbot init
|
|
80
|
+
|
|
81
|
+
# Start a clinical reasoning session
|
|
82
|
+
fangbot chat
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Usage
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
fangbot init # First-time setup wizard
|
|
89
|
+
fangbot chat # Interactive clinical reasoning session
|
|
90
|
+
fangbot run studies/config.yaml # Batch evaluation (Phase 2)
|
|
91
|
+
fangbot report studies/results/ # Generate comparison report (Phase 2)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Chat commands
|
|
95
|
+
|
|
96
|
+
Inside `fangbot chat`, use slash commands:
|
|
97
|
+
|
|
98
|
+
| Command | Description |
|
|
99
|
+
|---------|-------------|
|
|
100
|
+
| `/help` | Show all commands |
|
|
101
|
+
| `/status` | Current provider, model, session info |
|
|
102
|
+
| `/claude [model]` | Switch to Claude |
|
|
103
|
+
| `/openai [model]` | Switch to OpenAI |
|
|
104
|
+
| `/model [name]` | Interactive model picker |
|
|
105
|
+
| `/models` | List all available models |
|
|
106
|
+
| `/clear` | Clear conversation history |
|
|
107
|
+
| `/history` | Show message count and tool calls |
|
|
108
|
+
| `/compact` | Compress conversation history |
|
|
109
|
+
| `quit` | End the session |
|
|
110
|
+
|
|
111
|
+
## Configuration
|
|
112
|
+
|
|
113
|
+
Fangbot stores config in `~/.fangbot/`:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
~/.fangbot/
|
|
117
|
+
├── .env # API keys and settings
|
|
118
|
+
└── logs/ # JSONL audit trail
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Environment variables (prefix `FANGBOT_`):
|
|
122
|
+
|
|
123
|
+
| Variable | Default | Description |
|
|
124
|
+
|----------|---------|-------------|
|
|
125
|
+
| `FANGBOT_PROVIDER` | `claude` | LLM provider (`claude`, `openai`) |
|
|
126
|
+
| `FANGBOT_MODEL` | `claude-sonnet-4-20250514` | Model to use |
|
|
127
|
+
| `ANTHROPIC_API_KEY` | — | Anthropic API key |
|
|
128
|
+
| `OPENAI_API_KEY` | — | OpenAI API key |
|
|
129
|
+
|
|
130
|
+
## Supported providers
|
|
131
|
+
|
|
132
|
+
| Provider | Models | Status |
|
|
133
|
+
|----------|--------|--------|
|
|
134
|
+
| Anthropic Claude | Opus 4.6, Sonnet 4.6, Haiku 4.5, Sonnet 4, Opus 4 | Supported |
|
|
135
|
+
| OpenAI | GPT-5, GPT-4o, GPT-4.1, o3, o4-mini | Supported |
|
|
136
|
+
| Google Gemini | — | Planned |
|
|
137
|
+
| Ollama (local) | — | Planned |
|
|
138
|
+
|
|
139
|
+
## Architecture
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
Gateway (CLI) → Brain (ReAct loop) → Skills (MCP tools) → Memory (audit trail)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- **Gateway** — CLI interface with typer + rich
|
|
146
|
+
- **Brain** — ReAct loop engine, LLM providers, clinical guardrails
|
|
147
|
+
- **Skills** — MCP client connecting to OpenMedicine server via stdio
|
|
148
|
+
- **Memory** — Session context, JSONL audit logger
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
git clone https://github.com/RamosFBC/fangbot.git
|
|
156
|
+
cd fangbot
|
|
157
|
+
uv sync --extra dev --extra openai
|
|
158
|
+
uv run python -m pytest -v
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
[MIT](LICENSE) — Copyright (c) 2026 RamosFBC
|