Metadata-Version: 2.5
Name: dtelecom-agents
Version: 0.1.1
Summary: Build streaming voice agents for dTelecom rooms
Project-URL: Documentation, https://github.com/dTelecom/agents-python/tree/main/agents#readme
Project-URL: Source, https://github.com/dTelecom/agents-python
Project-URL: Issues, https://github.com/dTelecom/agents-python/issues
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Requires-Python: >=3.11
Requires-Dist: dtelecom-rtc==0.1.1
Requires-Dist: dtelecom-server-sdk==0.1.0
Provides-Extra: llm
Requires-Dist: httpx<1,>=0.27; extra == 'llm'
Provides-Extra: memory
Requires-Dist: huggingface-hub<2,>=0.26; extra == 'memory'
Requires-Dist: numpy>=1.24; extra == 'memory'
Requires-Dist: onnxruntime<2,>=1.17; extra == 'memory'
Requires-Dist: tokenizers<1,>=0.20; extra == 'memory'
Description-Content-Type: text/markdown

# dTelecom voice agents for Python

Build a Python voice agent that listens and speaks in a dTelecom room. The agent uses the dTelecom server SDK for Cloud grants and speech sessions, and the Python RTC SDK for room audio and data.

Install the package with its LLM integration and set `DTELECOM_CLOUD_URL`, `DTELECOM_API_KEY`, `DTELECOM_API_SECRET`, and `OPENROUTER_API_KEY`. Run the [voice agent example](https://github.com/dTelecom/agents-python/blob/main/agents/examples/voice_agent.py) from the `agents/` directory of this checkout. It takes one room name. Have a second participant join the same project and room with its own grant.

```sh
python -m pip install 'dtelecom-agents[llm]'
python examples/voice_agent.py my-room
```

Use `DTelecomSTT` and `DTelecomTTS` for dTelecom speech. Choose `OpenRouterLLM` or `OpenAILLM`, or implement the asynchronous `LLMPlugin` interface. The optional `memory` extra adds a local embedding model for persistent, scoped room memory. The model downloads on first use.

A participant can interrupt the agent while it is speaking. Subscribe to the `transcription`, `response`, `interrupted`, and `metrics` events to update your application. An interim result carries the speaker, utterance ID and revision. Final text drives the LLM. Tool handler timeouts use seconds and latency metrics use milliseconds.

For an already issued room grant, supply `token`, `ws_url` and `fallback_urls` to `agent.start()`. A speech connection still needs separate speech credentials. For gateway speech grants, supply the issued server URL, single-use key and renewal callback to `SpeechCredentials`. The Cloud and gateway use their respective credential types.

## Tools and conversation controls

Define tools with JSON Schema. An asynchronous handler returns a string or JSON-serializable value to the model. The runtime cancels the handler when the user interrupts the turn. A tool supplied as a plain definition emits `tool_call` for application-managed handling.

```python
from dtelecom_agents import AgentTool

async def next_opening(arguments, context):
    return {"next_opening": "Tuesday at 09:00"}

schedule = AgentTool(
    definition={
        "type": "function",
        "function": {
            "name": "next_opening",
            "description": "Get the next appointment time.",
            "parameters": {"type": "object", "properties": {}},
        },
    },
    handler=next_opening,
    timeout=10,
)
```

Pass `tools=[schedule]` to `VoiceAgent`. For an addressed assistant in a group room, use `respond_mode="addressed"`, `agent_name="assistant"` and `name_variants=["helper"]`. A `before_respond(speaker, text)` hook can refine that decision. Each participant has its own recognition stream. A callback registered as `agent.on("transcription", callback)` receives `(speaker, result)`.

Use `await agent.say(text)` for a greeting and `await agent.say_ssml(document, display_text)` for a complete SSML document. Language-specific voices can be configured with `VoiceConfig(voice, lang_code)`. Set `watermark=True` on `DTelecomTTS` to request watermarking and `partials=True, smart_turn=True` on `DTelecomSTT` to request provisional text and server turn detection. The `stt_ready` event carries the server's effective Smart Turn state.

## Optional memory

Install `dtelecom-agents[memory]` and pass `memory=MemoryConfig(db_path="data/assistant.db")` using `from dtelecom_agents.memory import MemoryConfig`. Turns and summaries are scoped to the room by default. Set a separate `scope` when your application intentionally shares history across rooms. Session text and embeddings are stored locally. To supply an already downloaded model, construct `Embedder(model_dir=...)` in a `RoomMemory` instance.

Python's standard logging controls diagnostics. To capture synthesized speech explicitly, call `agent.enable_audio_dump(directory)`; recordings are written as local 48 kHz mono WAV files.
