版本发布 8
### Bug fixes * Fixed compatibility with rich >= 14.3.0 and Anthropic SDK v0.82+. (#269) * Updated generated OpenAI types for SDK v2.22+. (#270)
### New features * `.stream()` and `.stream_async()` now support a `data_model` parameter for structured data extraction while streaming. (#262) * `.to_solver()` now supports a `data_model` parameter for structured data extraction in evals. When provided, the solver uses `.chat_structured()` instead of `.chat()` and outputs JSON-serialized data. (#264) ### Bug fixes * Fixed `ContentToolResult` with an `error` not being JSON serializable. When a tool call failed, calling `.get_turns()` followed by `.model_dump_json()` would raise a `PydanticSerializationError`. (#267)
* `ChatOpenAI()` (and `ChatAzureOpenAI()`) gain access to latest models, built-in tools, etc. as a result of moving to the new [Responses API](https://platform.openai.com/docs/api-reference/responses). (#192) * Added new family of functions (`parallel_chat()`, `parallel_chat_text()`, and `parallel_chat_structured()`) for submitting multiple prompts at once with some basic rate limiting toggles. (#188) * Tools can now return image or PDF content types, with `content_image_file()` or `content_pdf_file()` (#231). * As a result, the experimental `ContentToolResultImage` and `ContentToolResultResource` were removed since this new support for generally supporting `ContentImage` and `ContentPDF` renders those content types redundant. * Added support for systematic evaluation via [Inspect AI](https://inspect.aisi.org.uk/). This includes: * A new `.export_eval()` method for exporting conversation history as an Inspect eval dataset sample. This supports multi-turn conversations, tool calls, images, PDFs, and structured data. * A new `.to_solver()` method for translating chat instances into Inspect solvers that can be used with Inspect's evaluation framework. * A new `Turn.to_inspect_messages()` method for converting turns to Inspect's message format. * Comprehensive documentation in the [Evals guide](https://posit-dev.github.io/chatlas/misc/evals.html). * `ChatAnthropic()` and `ChatBedrockAnthropic()` gain new `cache` parameter to control caching. For `ChatAnthropic()`, it defaults to `"5m"`, which should (on average) reduce the cost of your chats. For `ChatBedrockAnthropic()`, it defaults to `"none"`, since caching isn't guaranteed to be widely supported (#215) * Added rudimentary support for a new `ContentThinking` type. (#192) ### Changes * `ChatOpenAI()` (and `ChatAzureOpenAI()`) move from OpenAI's Completions API to [Responses API](https://platform.openai.com/docs/api-reference/responses). If this happens to break behavior, change `ChatOpenAI()` -> `ChatOpenAICompletions()` (or `ChatAzureOpenAI()` -> `ChatAzureOpenAICompletions()`). (#192) * The `Turn` class is now a base class with three specialized subclasses: `UserTurn`, `AssistantTurn`, and `SystemTurn`. Use these new classes to construct turns by hand. (#224) * The `.set_model_params()` method no longer accepts `kwargs`. Instead, use the new `chat.kwargs_chat` attribute to set chat input parameters that persist across the chat session. (#212) * `Provider` implementations now require an additional `.value_tokens()` method. Previously, it was assumed that token info was logged and attached to the `Turn` as part of the `.value_turn()` method. The logging and attaching is now handled automatically. (#194) ### Improvements * `ChatAnthropic()` and `ChatBedrockAnthropic()` now default to Claude Sonnet 4.5. * `ChatGroq()` now defaults to llama-3.1-8b-instant. * `Chat.chat()`, `Chat.stream()`, and related methods now automatically complete dangling tool requests when a chat is interrupted during a tool call loop, allowing the conversation to be resumed without causing API errors (#230). * `content_pdf_file()` and `content_pdf_url()` now include relevant `filename` information. (#199) ### Bug fixes * `.set_model_params()` now works correctly for `.*_async()` methods. (#198) * `.chat_structured()` results are now included correctly into the multi-turn conversation history. (#203) * `ChatAnthropic()` now drops empty assistant turns to avoid API errors when tools return side-effect only results. (#226)
### Bug fixes * `ChatGithub()` once again uses the appropriate `base_url` when generating reponses (problem introduced in v0.11.0). (#182)
### New features * Added support for submitting multiple chats in one batch. With batch submission, results can take up to 24 hours to complete, but in return you pay ~50% less than usual. For more, see the [reference](https://posit-dev.github.io/chatlas/reference/) for `batch_chat()`, `batch_chat_text()`, `batch_chat_structured()` and `batch_chat_completed()`. (#177) * The `Chat` class gains new `.chat_structured()` (and `.chat_structured_async()`) methods. These methods supersede the now deprecated `.extract_data()` (and `.extract_data_async()`). The only difference is that the new methods return a `BaseModel` instance (instead of a `dict()`), leading to a better type hinting/checking experience. (#175) * The `.get_turns()` method gains a `tool_result_role` parameter. Set `tool_result_role="assistant"` to collect tool result content (plus the surrounding assistant turn contents) into a single assistant turn. This is convenient for display purposes and more generally if you want the tool calling loop to be contained in a single turn. (#179) ### Improvements * The `.app()` method now: * Enables bookmarking by default (i.e., chat session survives page reload). (#179) * Correctly renders pre-existing turns that contain tool calls. (#179)
### New features * The `Chat` class gains a new `.list_models()` method for obtaining a list of model ids/names, pricing info, and more. (#155) * `Chat`'s `.register_tool()` method gains an `annotations` parameter, which is useful for describing the tool and its behavior. This information is attached to `ContentToolRequest()` and `ContentToolResult()` (via the `.request` parameter) objects when tool calls occur. To include these objects in streaming content, make sure to set `.stream(content="all")`. (#156) ### Improvements * Tools registered via MCP (e.g., `.register_mcp_tools_http_stream_async()`) now automatically pick up on tool annotations. (#156) ### Changes * `ChatGithub()` changed its default for `base_url` from <https://models.inference.ai.azure.com> to <https://models.github.ai/inference/>. As a result, more models are available (by default). (#155)
### Bug fixes * Fixed an issue where `.chat()` wasn't streaming output properly in (the latest build of) Positron's Jupyter notebook. (#131) * Needless warnings and errors are no longer thrown when model pricing info is unavailable. (#132)
### New features * `Chat` gains a handful of new methods: * `.register_mcp_tools_http_stream_async()` and `.register_mcp_tools_stdio_async()`: for registering tools from a [MCP server](https://modelcontextprotocol.io/). (#39) * `.get_tools()` and `.set_tools()`: for fine-grained control over registered tools. (#39) * `.set_model_params()`: for setting common LLM parameters in a model-agnostic fashion. (#127) * `.get_cost()`: to get the estimated cost of the chat. Only popular models are supported, but you can also supply your own token prices. (#106) * `.add_turn()`: to add `Turn`(s) to the current chat history. (#126) * Tool functions passed to `.register_tool()` can now `yield` numerous results. (#39) * A `ContentToolResultImage` content class was added for returning images from tools. It is currently only works with `ChatAnthropic`. (#39) * A `Tool` can now be constructed from a pre-existing tool schema (via a new `__init__` method). (#39) * The `Chat.app()` method gains a `host` parameter. (#122) * `ChatGithub()` now supports the more standard `GITHUB_TOKEN` environment variable for storing the API key. (#123) ### Changes #### Breaking Changes * `Chat` constructors (`ChatOpenAI()`, `ChatAnthropic()`, etc) no longer have a `turns` keyword parameter. Use the `.set_turns()` method instead to set the (initial) chat history. (#126) * `Chat`'s `.tokens()` methods have been removed in favor of `.get_tokens()` which returns both cumulative tokens in the turn and discrete tokens. (#106) #### Other Changes * `Tool`'s constructor no longer takes a function as input. Use the new `.from_func()` method instead to create a `Tool` from a function. (#39) * `.register_tool()` now throws an exception when the tool has the same name as an already registered tool. Set the new `force` parameter to `True` to force the registration. (#39) ### Improvements * `ChatGoogle()` and `ChatVertex()` now default to Gemini 2.5 (instead of 2.0). (#125) * `ChatOpenAI()` and `ChatGithub()` now default to GPT 4.1 (instead of 4o). (#115) * `ChatAnthropic()` now supports `content_image_url()`. (#112) * HTML styling improvements for `ContentToolResult` and `ContentToolRequest`. (#39) * `Chat`'s representation now includes cost information if it can be calculated. (#106) * `token_usage()` includes cost if it can be calculated. (#106) ### Bug fixes * Fixed an issue where `httpx` client customization (e.g., `ChatOpenAI(kwargs = {"http_client": httpx.Client()})`) wasn't working as expected (#108) ### Developer APIs * The base `Provider` class now includes a `name` and `model` property. In order for them to work properly, provider implementations should pass a `name` and `model` along to the `__init__()` method. (#106) * `Provider` implementations must implement two new abstract methods: `translate_model_params()` and `supported_model_params()`.