Metadata-Version: 2.4
Name: latence
Version: 0.2.0
Summary: Thin Python SDK for Latence TRACE.
Project-URL: Homepage, https://latence.ai
Project-URL: Documentation, https://docs.latence.ai
Project-URL: Repository, https://github.com/latenceainew/latence-trace-python
Project-URL: Issues, https://github.com/latenceainew/latence-trace-python/issues
Author-email: "latence.ai" <support@latence.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: groundedness,hallucination-detection,knowledge,rag,retrieval,trace
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.6
Provides-Extra: all
Requires-Dist: crewai>=0.30; extra == 'all'
Requires-Dist: haystack-ai>=2.0; extra == 'all'
Requires-Dist: langchain-core>=0.2; extra == 'all'
Requires-Dist: langgraph>=0.0.50; extra == 'all'
Requires-Dist: llama-index-core>=0.10; extra == 'all'
Requires-Dist: openai>=1.30; extra == 'all'
Requires-Dist: opentelemetry-api>=1.24; extra == 'all'
Requires-Dist: opentelemetry-instrumentation-httpx>=0.45b0; extra == 'all'
Requires-Dist: pyautogen>=0.2.30; extra == 'all'
Requires-Dist: pydantic-ai>=0.1; extra == 'all'
Provides-Extra: autogen
Requires-Dist: pyautogen>=0.2.30; extra == 'autogen'
Provides-Extra: crewai
Requires-Dist: crewai>=0.30; extra == 'crewai'
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.20; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: haystack
Requires-Dist: haystack-ai>=2.0; extra == 'haystack'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.0.50; extra == 'langgraph'
Provides-Extra: llama-index
Requires-Dist: llama-index-core>=0.10; extra == 'llama-index'
Provides-Extra: openai
Requires-Dist: openai>=1.30; extra == 'openai'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.24; extra == 'otel'
Requires-Dist: opentelemetry-instrumentation-httpx>=0.45b0; extra == 'otel'
Provides-Extra: pydantic-ai
Requires-Dist: pydantic-ai>=0.1; extra == 'pydantic-ai'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/latenceainew/latence-trace-python/main/docs/assets/latence-logo.svg" alt="Latence" width="180" />
</p>

<h1 align="center">Latence TRACE Python SDK</h1>

<p align="center">
  Real-time safety for knowledge agents. Groundedness verification,
  privacy redaction, and context compression — without replacing your stack.
</p>

<p align="center">
  <a href="https://pypi.org/project/latence/">PyPI</a>
  ·
  <a href="docs/quickstart.md">Quickstart</a>
  ·
  <a href="docs/integrations.md">Integrations</a>
  ·
  <a href="examples/">Examples</a>
  ·
  <a href="https://latence.ai">Website</a>
</p>

```bash
pip install latence
```

```python
from latence import Latence

trace = Latence(api_key="lat_...")

score = trace.grounding.rag(
    query="Can I promise this customer a refund?",
    response_text="Yes, the refund will arrive within 48 hours.",
    raw_context="Refunds require manual finance approval before timelines are promised.",
)

print(score.risk_band)
print(score.runtime_decision)
```

## What TRACE Does

- **Groundedness** — verify RAG answers against retrieved context.
- **Compression** — reduce long context to what matters.
- **Privacy** — redact private data before it spreads through tools, logs, or prompts.

## Getting Started

```bash
export LATENCE_TRACE_API_KEY="lat_..."
```

```python
from latence import Latence

trace = Latence()
```

The SDK connects to `https://api.latence.ai` by default. Override with `base_url` or `LATENCE_TRACE_URL`.

## API Surface

```python
# Groundedness scoring
score = trace.grounding.rag(query=..., response_text=..., raw_context=...)

# Privacy redaction
redacted = trace.privacy.redact(text=...)

# Context compression
compressed = trace.compression.text(text=..., compression_rate=0.4)
```

`Latence` is synchronous. `AsyncLatence` exposes the same surface for asyncio services.

Base dependencies are only `httpx` and `pydantic`.

## Integrations

Direct calls are the recommended path. Optional helpers live under
`latence.integrations`.

```bash
pip install "latence[langchain]"
pip install "latence[llama_index]"
pip install "latence[openai]"
pip install "latence[haystack]"
```

Docs: [Integrations](docs/integrations.md)

## More

- [Quickstart](docs/quickstart.md)
- [Integrations](docs/integrations.md)
- [Errors](docs/errors.md)
- [Publishing](docs/publishing.md)
- [Examples](examples/)
- [Website](https://latence.ai)
