Metadata-Version: 2.5
Name: evoduce
Version: 0.1.0
Summary: Python client for the Evoduce API: decisions answered by your rules first and a model when needed, and proof-checked changes to your vocabulary
Project-URL: Homepage, https://www.evoduce.com
Project-URL: Documentation, https://www.evoduce.com/docs.html
License-Expression: MIT
Keywords: decision-rules,decisions,llm,neurosymbolic,verification,vocabulary
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# evoduce (Python)

Client for the [Evoduce API](https://www.evoduce.com/docs.html). Check a proposed term against your vocabulary and get a
proven verdict, or ask a decision and have your own rules answer before a model does.

```bash
pip install evoduce
export EVODUCE_API_KEY=evd_...
```

```python
from evoduce import Client

vocab = {
    "name": "spatial_relations",
    "axes": {"duration": {"values": ["absolute", "temporary"]},
             "type": {"values": ["contact", "proximity", "containment"]}},
    "rules": [{"type": "AXIS_COVERAGE"}, {"type": "REQUIRES_INVERSE"}, {"type": "NO_DUPLICATE"}],
    "predicates": {},
}

with Client() as nse:
    r = nse.verify(vocab, "resting_on", duration="temporary", type="contact")
    if not r.sat:
        print(r.violated_rules, r.counterexample)   # ['REQUIRES_INVERSE'] {...}

    grown = nse.accept(vocab, "resting_on", inverse="supports", duration="temporary", type="contact")
    vocab = grown.vocabulary or vocab                # persist this yourself
```

Methods: `verify`, `verify_graded`, `accept`, `optimize`, `prove`, `audit`. A `neurosymbolic_evaluator.Vocabulary`
is accepted anywhere a vocabulary dict is. Non-2xx responses raise `EvoduceError` (`.status`, `.detail`, `.retry_after`);
an UNSAT verdict is a normal result with `sat=False`.

## Typed decisions from an NS vocabulary

Pass a vocabulary on a Choice question to use its predicate names as options.
The gateway checks account decision rules first, then a model answers when needed. Your Evoduce key is all it needs:
model answers are included with it and show in your usage. Confident model answers become observations for that
question id's learning policy.

```python
question = {"route": {
    "type": "choice", "instructions": "Which team should handle this ticket?",
    "vocabulary": route_vocabulary,  # dict or neurosymbolic_evaluator.Vocabulary
}}
result = nse.systemone({"category": "refund"}, question)
print(result["answers"]["route"]["choice"], result["evoduce"]["sources"]["route"])
pending = nse.get_policy("route")["learned"]
# Review pending rules, then call nse.approve_policy("route", indexes=[0]).
```

The same gateway takes OpenAI's Decisions request shape. Questions are a list; a question's `name` is its
question id, and it may carry inline `rules`:

```python
result = nse.decisions(
    "The package arrived with a broken screen.",
    [{"type": "predicate", "name": "damaged", "instructions": "Does the customer report a damaged item?"}],
)
print(result["answers"][0]["probability"], result["evoduce"]["sources"][0])
```

To have a provider answer on your own account instead, pass your key for it: `upstream_key=jev_api_key` to
`systemone`, `upstream_key=openai_api_key` to `decisions`. Those answers are not counted against your monthly
model answers. After a quiet spell the model can take about a minute to start; a call that arrives while it does
raises `EvoduceError` with status 503 and `retry_after` set to the seconds to wait.

`put_policy` sets rules and learning mode. The vocabulary governs allowed terms;
a model choice is a judgment, while vocabulary additions use `verify` or `accept`.
