Metadata-Version: 2.5
Name: crewai-getabrain
Version: 0.1.0
Summary: CrewAI tools for GetABrain: ask verified humans a question from a crew.
Project-URL: Homepage, https://www.getabrain.ai
Project-URL: Documentation, https://github.com/Guitarmaniac24/crewai-getabrain#readme
Project-URL: Source, https://github.com/Guitarmaniac24/crewai-getabrain
Project-URL: API docs, https://www.getabrain.ai/docs
Author-email: GetABrain <hello@getabrain.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,crewai,getabrain,human-in-the-loop,tools
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: <3.14,>=3.10
Requires-Dist: crewai>=1.0
Requires-Dist: getabrain>=0.2.1
Description-Content-Type: text/markdown

# crewai-getabrain

CrewAI tools for [GetABrain](https://www.getabrain.ai), an API that lets an agent ask
verified people in the US a question and get structured answers back.

Two tools:

| Tool | Name the model sees | What it does |
|---|---|---|
| `GetABrainAskTool` | `getabrain_ask_human` | Sends a question, waits up to `max_wait_seconds` for answers, returns them. If nobody has answered yet it returns `status: "pending"` and a `query_id`. |
| `GetABrainGetAnswersTool` | `getabrain_get_answers` | Reads the answers to an earlier question by `query_id`. Free and read-only. |

People take minutes to hours to answer, so a `pending` result is normal. The question stays
open and the second tool picks up the answers later.

## Install

```bash
pip install -U crewai-getabrain
```

## Credentials

Create an account and API key at https://www.getabrain.ai/requestor/signup (or see the
[quick start](https://www.getabrain.ai/docs/quickstart)), then:

```bash
export GETABRAIN_API_KEY="gab_k_..."
export GETABRAIN_API_SECRET="gab_s_..."
```

**Cost:** with a live key, every answer is paid from your GetABrain balance. With a
**test-mode key** (`POST /api/v1/requestor/keys {"mode": "test"}`), answers are simulated by
an AI stand-in, never reach people, and come back marked `"simulated": true` with a notice.
Build and test with a test-mode key first.

## Use it directly

```python
from crewai_getabrain import GetABrainAskTool, GetABrainGetAnswersTool

ask = GetABrainAskTool(max_wait_seconds=60)
print(ask.run(
    question="Which name is easier to remember?",
    query_type="multiple_choice",
    options=["Quillo", "Brightdesk"],
    num_responses=3,
))
```

The result is a JSON string:

```json
{"query_id": "...", "status": "answered", "answers_received": 3, "answers_requested": 3,
 "answers": [{"selected_ids": ["2"], "selected_options": ["Brightdesk"]}, "..."],
 "test_mode": false}
```

## Use it in a crew

```python
from crewai import Agent, Crew, Task
from crewai_getabrain import GetABrainAskTool, GetABrainGetAnswersTool

checker = Agent(
    role="Product checker",
    goal="Settle judgment calls by asking real people instead of guessing",
    backstory="You call getabrain_ask_human when a decision needs human judgment.",
    tools=[GetABrainAskTool(), GetABrainGetAnswersTool()],
)
task = Task(
    description="Find out whether the headline 'Ship faster' is clear to a normal person.",
    expected_output="Yes or no, with what the person said.",
    agent=checker,
)
print(Crew(agents=[checker], tasks=[task]).kickoff())
```

A runnable version is in [`example.py`](example.py).

Errors (missing keys, bad arguments, API errors) come back to the agent as a string starting
with `Error:`.

## Arguments the model fills

| Argument | Type | Notes |
|---|---|---|
| `question` | str | Required. |
| `query_type` | `yes_no` \| `multiple_choice` \| `rating_scale` \| `text` | Default `yes_no`. `rating_scale` is 1 to 5. |
| `options` | list[str] | Required for `multiple_choice` (2 or more). |
| `context` | str | Optional background shown to the person. |
| `num_responses` | int | How many different people answer. Default 1. |

## Settings you set in code

| Setting | Default | Notes |
|---|---|---|
| `max_wait_seconds` | 60 | How long one call waits before returning `pending`. |
| `poll_interval_seconds` | 5 | Time between status checks. |
| `max_responses` | 5 | Upper limit on `num_responses` per call, a spend guard. |
| `speed` | `None` | `relaxed` / `standard` / `fast` / `rush`: higher pays people more per answer. |
| `api_key`, `api_secret`, `base_url` | env vars | `GETABRAIN_API_KEY`, `GETABRAIN_API_SECRET`, `GETABRAIN_BASE_URL`. |
| `client` | `None` | Pass a ready `getabrain.GetABrain` client instead. |

Other query types (image comparison, ranking, A/B tests, video and audio review) are available
through the [`getabrain` Python SDK](https://pypi.org/project/getabrain/) and the
[API docs](https://www.getabrain.ai/docs/api).

## Development

```bash
uv sync --group test
uv run pytest
```

Unit tests mock HTTP and make no network calls.

## License

MIT
