Pydantic AI capability for Sigil Python SDK
Project description
Grafana AI Observability Python Framework Module: Pydantic AI
sigil-sdk-pydantic-ai provides an AbstractCapability implementation that maps Pydantic AI lifecycle hooks into Sigil generation recorder lifecycles.
Installation
pip install sigil-sdk sigil-sdk-pydantic-ai
pip install pydantic-ai
Quickstart
from pydantic_ai import Agent
from sigil_sdk import Client
from sigil_sdk_pydantic_ai import create_sigil_pydantic_ai_capability
client = Client()
capability = create_sigil_pydantic_ai_capability(client=client, provider_resolver="auto")
agent = Agent("openai:gpt-4o", capabilities=[capability])
result = agent.run_sync("What is the weather?")
print(result.output)
client.shutdown()
End-to-end example (run + run_stream)
from pydantic_ai import Agent
from sigil_sdk import Client
from sigil_sdk_pydantic_ai import with_sigil_pydantic_ai_capability
client = Client()
capabilities = with_sigil_pydantic_ai_capability(
None,
client=client,
provider_resolver="auto",
agent_name="pydantic-ai-example",
agent_version="1.0.0",
)
agent = Agent("openai:gpt-4o-mini", capabilities=capabilities)
# Non-stream call -> SYNC generation mode.
result = agent.run_sync("Summarize why retry budgets matter.")
print(result.output)
# Stream call -> STREAM generation mode + TTFT tracking.
async def stream_example() -> None:
async with agent.run_stream("Give me three short reliability tips.") as stream:
async for chunk in stream.stream_text():
print(chunk, end="", flush=True)
print()
import asyncio
asyncio.run(stream_example())
client.shutdown()
Conversation mapping
Primary mapping is Pydantic AI run identity:
conversation_id/session_idfromctx.depsorctx.metadatathread_idfromctx.depsorctx.metadata- fallback
sigil:framework:pydantic-ai:<run_id>
Metadata and lineage
- Required:
sigil.framework.run_type - Optional:
sigil.framework.run_id,sigil.framework.parent_run_id,sigil.framework.thread_id,sigil.framework.event_id,sigil.framework.component_name,sigil.framework.retry_attempt
Provider resolver
Resolver order: explicit provider option -> callback payload -> model prefix inference -> custom.
Troubleshooting
- Provide stable
conversation_idviactx.depsorctx.metadatato avoid fragmented conversations. - If model aliases are custom, set explicit
provideron the handler. - Always call
client.shutdown()during teardown to flush buffered telemetry.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sigil_sdk_pydantic_ai-0.1.4.tar.gz.
File metadata
- Download URL: sigil_sdk_pydantic_ai-0.1.4.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566b0c212e46c62d99b55fc71a683019afbe8d823dff5c9bf4f5109cc3c471dc
|
|
| MD5 |
6036fd313a0e193275213523f345ac4b
|
|
| BLAKE2b-256 |
8e932f7499c379619d7ea73970eeba013cf7c37661a30cc5e0c9e015d4656749
|
Provenance
The following attestation bundles were made for sigil_sdk_pydantic_ai-0.1.4.tar.gz:
Publisher:
python-sdks-publish.yml on grafana/sigil-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sigil_sdk_pydantic_ai-0.1.4.tar.gz -
Subject digest:
566b0c212e46c62d99b55fc71a683019afbe8d823dff5c9bf4f5109cc3c471dc - Sigstore transparency entry: 1400875683
- Sigstore integration time:
-
Permalink:
grafana/sigil-sdk@e70beecacc215c12b48fbc2a107b065ab48a5be7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/grafana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdks-publish.yml@e70beecacc215c12b48fbc2a107b065ab48a5be7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sigil_sdk_pydantic_ai-0.1.4-py3-none-any.whl.
File metadata
- Download URL: sigil_sdk_pydantic_ai-0.1.4-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33b7e31b8c8b837a1af50cb76e9289debf5268c2cb8103990280598bc621cbc8
|
|
| MD5 |
fe014390af5fbab4cbdbcc045e1296d3
|
|
| BLAKE2b-256 |
c056ac452669fd65b7b87d1580c4862e9f8be0e7702da92232f87df0e4a27c1b
|
Provenance
The following attestation bundles were made for sigil_sdk_pydantic_ai-0.1.4-py3-none-any.whl:
Publisher:
python-sdks-publish.yml on grafana/sigil-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sigil_sdk_pydantic_ai-0.1.4-py3-none-any.whl -
Subject digest:
33b7e31b8c8b837a1af50cb76e9289debf5268c2cb8103990280598bc621cbc8 - Sigstore transparency entry: 1400875833
- Sigstore integration time:
-
Permalink:
grafana/sigil-sdk@e70beecacc215c12b48fbc2a107b065ab48a5be7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/grafana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdks-publish.yml@e70beecacc215c12b48fbc2a107b065ab48a5be7 -
Trigger Event:
workflow_dispatch
-
Statement type: