Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### New features

* Providers now expose a `base_url` attribute (`chat.provider.base_url`) reporting the endpoint requests are sent to, when the provider can determine it. This is groundwork for richer telemetry (e.g. OpenTelemetry `server.address`/`server.port` attributes) and is handy for confirming which endpoint a provider resolved.
* The OpenTelemetry integration now emits **metrics** alongside spans, following the [GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/): per-request inference duration and token-usage histograms (`gen_ai.client.inference.*`), cumulative token-usage counters (including cache-read and reasoning tokens, broken down by `gen_ai.token.modality`), streaming latency (`gen_ai.client.inference.time_to_first_chunk`, `gen_ai.client.inference.time_per_output_chunk`), tool execution duration (`gen_ai.execute_tool.duration`), and per-invocation agent metrics (`gen_ai.invoke_agent.duration`, `gen_ai.invoke_agent.inference_calls`, `gen_ai.invoke_agent.tool_calls`). Metrics flow through the same SDK configuration as traces, so no extra setup is needed.
* OpenTelemetry spans are richer and more accurate. Chat spans now record `server.address`/`server.port`, the request parameters actually sent (`gen_ai.request.*`, including `gen_ai.request.stream` and reasoning effort), the finish reason (`gen_ai.response.finish_reasons`), cache-read and reasoning token counts, time to first chunk, and (with content capture enabled) the tool definitions sent with the request. The `invoke_agent` span is now an `internal`-kind span and records duration, inference/tool call counts, and total token usage. Successful requests are now marked with an `OK` span status (previously unset), and failed, cancelled (`StreamController.cancel()`), and interrupted (e.g. abandoned streams) requests now report an error status and `error.type` on both the spans and the duration metrics, matching ellmer.
* The result of `chat.files.get()` (and elements of `chat.files.list()`) can now be passed straight to `.chat()` (and anywhere else content is accepted), so a file uploaded in an earlier session can be reused from its id alone: `chat.chat("Summarize this.", chat.files.get("file_011CRabc..."))`. When the provider doesn't report a MIME type (OpenAI's Files API never does), it's guessed from the filename. For when you want the underlying `ContentUploaded` reference itself (e.g. to build a `UserTurn` by hand), `FileMetadata` gains a `.to_content()` method. This works via a new general convention: any object implementing `to_content() -> Content` (see `chatlas.types.SupportsContent`) is accepted anywhere content is passed, so third-party packages can make their own objects usable as chat inputs. (#417)

### Changes
Expand Down
284 changes: 244 additions & 40 deletions chatlas/_chat.py

Large diffs are not rendered by default.

Loading
Loading