Skip to content
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Added a `ChatSnowflake()` class to interact with [Snowflake Cortex LLM](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions). (#54)
* Added a `ChatAuto()` class, allowing for configuration of chat providers and models via environment variables. (#38, thanks @mconflitti-pbc)
* Added a `ToolResult()` class which allow for: (1) control how results get formatted when sent to the model and (2) yield additional content to the user (i.e., the downstream consumer of a `.stream()` or `.chat()`) for display when the tool is called. (#69)
* Added a `on_request` parameter to `.register_tool()`. When tool is requested, this callback executes, and the result is yielded to the user. (#69)
* Added a `Chat.on_tool_request()` method for registering a default tool request handler. (#69)


### Changes

* By default, tool results are formatted as a JSON string when sent to the model. (#69)

### Improvements

Expand Down
3 changes: 2 additions & 1 deletion chatlas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ._provider import Provider
from ._snowflake import ChatSnowflake
from ._tokens import token_usage
from ._tools import Tool
from ._tools import Tool, ToolResult
from ._turn import Turn

try:
Expand Down Expand Up @@ -43,6 +43,7 @@
"Provider",
"token_usage",
"Tool",
"ToolResult",
"Turn",
"types",
)
7 changes: 5 additions & 2 deletions chatlas/_anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,15 @@ def _as_content_block(content: Content) -> "ContentBlockParam":
"input": content.arguments,
}
elif isinstance(content, ContentToolResult):
return {
res: ToolResultBlockParam = {
"type": "tool_result",
"tool_use_id": content.id,
"content": content.get_final_value(),
"is_error": content.error is not None,
}
# Anthropic supports non-text contents like ImageBlockParam
res["content"] = content.get_final_value() # type: ignore
return res

raise ValueError(f"Unknown content type: {type(content)}")

@staticmethod
Expand Down
Loading
Loading