# Python: document assistant example

Instrument an ASGI application and add retrieval, explanation and source observations.

## 1. Install the wheel

Use Python 3.10+ and the service-specific wheel downloaded from the portal.

~~~bash
python -m pip install ./packages/sigillum_finans_sdk-0.11.0-py3-none-any.whl
python -m pip install fastapi uvicorn
~~~

HTTPX, OpenTelemetry and cryptography dependencies can be resolved through your institution’s package mirror.

## 2. Wrap the ASGI application

Create a single SDK with start(Path(...).resolve()). After defining the routes, use app = sdk.wrap_asgi(api). The SDK observes standard ASGI HTTP messages and in-scope HTTPX calls. WebSockets, arbitrary sockets and every Python library are not automatically instrumented.

## 3. Record the document-assistant workflow

The **POST /assist** example accepts a question, selects from three synthetic local documents by word matching and produces a deterministic answer. It does not call a real LLM. Retrieval source content, explanation, business result and original source attachment are recorded explicitly. Other AI categories are demonstrated separately in the AI observation examples.

## 4. Supply JSON, attachments and references

JsonData.raw accepts a valid JSON object as str or immutable bytes. Attachment carries original content. References and ExternalReference add person, session and business references. Avoid parsing and serialising large JSON numbers solely for observation.

## 5. Integrate an actual model call

sdk.call_ai and call_ai_async execute the actual operation once. If the return value is not raw JSON, an output= selector supplies the original JSON representation. Do not pre-consume a stream for capture; observe it during normal consumption.

## 6. Run the project

Follow the ZIP README and set SIGILLUM_CONFIG to the absolute service-configuration path. Start with uvicorn app:app --host 127.0.0.1 --port 5110. Set **POST /assist** as the entry point. A /sdk-status response is not evidence of transaction observation: send an actual /assist request.