Metadata-Version: 2.4
Name: darknight
Version: 0.1.2
Summary: Agentic CAPTCHA solver: dk.configure(...) to set credentials, dk.solve(image) -> answer
Author-email: Yeo Zi Yi <ziyi160073@gmail.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai>=1.0.0
Requires-Dist: anthropic>=0.40.0
Requires-Dist: opencv-python>=4.8.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: Pillow>=10.0.0
Requires-Dist: scipy>=1.11.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: sentence-transformers>=2.2.0
Dynamic: license-file

# darknight (`dk`)



## Install

```bash
pip install darknight
```

If your project tracks dependencies in `requirements.txt`:

```
darknight
```

or in `pyproject.toml`:

```toml
dependencies = [
    "darknight",
]
```

## Configure

Copy the example env file and fill in your own values:

```bash
cp .env.example .env
```

```
DK_ENDPOINT=openai          # or "anthropic"
DK_BASE_URL=https://api.openai.com/v1
DK_API_KEY=sk-...
DK_MODEL=gpt-4o
```

Or configure programmatically instead of / on top of `.env`:

```python
import dk

dk.configure(
    endpoint="openai",
    base_url="https://api.openai.com/v1",
    api_key="sk-...",
    model="qwen3-vl-",
)
```

## Solve a single CAPTCHA

```python
import dk

res = dk.solve("/path/to/your/captcha.png")   # pass a file path in .png / .jpg / .jpeg
res = dk.solve("captcha_b64string")           # or a base64 / data-URI image string
print(res)   # eg: "Cx5b"
```

## Solve a batch (.json dataset)

```python
results = dk.solve("dataset.json")  
```

Dataset format:
```json
[
  {"id": "001", "label": "4vNf", "b64_string": "<base64 PNG/JPEG>"}
]
```

## RAG memory + feedback

Every `dk.solve()` call automatically reads from a single, universal,
disk-persisted RAG store (`~/.darknight/rag/rag.json`) for hints from past
captchas. But correctness isn't knowable at solve() time, so **nothing is
written until you report the real outcome**:

```python
import dk

res = dk.solve("/path/to/your/captcha.png")   # pass a file path in .png / .jpg / .jpeg
correct = submit_to_website(res)   # verification step
dk.feedback(correct)               # writes this records into the RAG store
```

`dk.feedback()` always applies to the most recent `dk.solve()` call. If you
call `dk.solve()` again before giving feedback on the previous one, only captchas that received feedback will be stored.

```python
dk.clear_rag()   # clear the RAG store
```
