chatlas 0.6.1__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chatlas might be problematic. Click here for more details.
- {chatlas-0.6.1 → chatlas-0.7.0}/.github/workflows/test.yml +2 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/CHANGELOG.md +32 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/PKG-INFO +8 -1
- {chatlas-0.6.1 → chatlas-0.7.0}/README.md +1 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/__init__.py +5 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_anthropic.py +12 -6
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_auto.py +7 -3
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_chat.py +339 -120
- chatlas-0.7.0/chatlas/_content.py +545 -0
- chatlas-0.7.0/chatlas/_databricks.py +145 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_display.py +13 -7
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_google.py +9 -5
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_ollama.py +3 -2
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_openai.py +9 -8
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_snowflake.py +46 -23
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_utils.py +36 -1
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_version.py +2 -2
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/openai/_submit.py +11 -1
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/_quarto.yml +1 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/pyproject.toml +5 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/conftest.py +47 -26
- chatlas-0.7.0/tests/images/dice.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_chat.py +1 -2
- chatlas-0.7.0/tests/test_content_tools.py +322 -0
- chatlas-0.7.0/tests/test_provider_anthropic.py +130 -0
- chatlas-0.7.0/tests/test_provider_databricks.py +75 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_provider_google.py +53 -23
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_provider_openai.py +2 -1
- chatlas-0.6.1/chatlas/_content.py +0 -347
- chatlas-0.6.1/tests/test_content_tools.py +0 -153
- chatlas-0.6.1/tests/test_provider_anthropic.py +0 -103
- {chatlas-0.6.1 → chatlas-0.7.0}/.github/workflows/check-update-types.yml +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/.github/workflows/docs-publish.yml +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/.github/workflows/release.yml +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/.gitignore +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/.vscode/extensions.json +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/.vscode/settings.json +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/Makefile +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_content_image.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_content_pdf.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_github.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_groq.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_interpolate.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_live_render.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_logging.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_merge.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_perplexity.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_provider.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_tokens.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_tokens_old.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_tools.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_turn.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/_typing_extensions.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/py.typed +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/__init__.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/anthropic/__init__.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/anthropic/_client.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/anthropic/_client_bedrock.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/anthropic/_submit.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/google/__init__.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/google/_client.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/google/_submit.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/openai/__init__.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/openai/_client.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/openai/_client_azure.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/snowflake/__init__.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/chatlas/types/snowflake/_submit.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/.gitignore +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/_extensions/machow/interlinks/.gitignore +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/_extensions/machow/interlinks/_extension.yml +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/_extensions/machow/interlinks/interlinks.lua +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/_sidebar.yml +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/congressional-assets.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/examples/third-party-testing.txt +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/get-started.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/images/congressional-assets.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/images/logo.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/images/posit-logo.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/images/tool-calling-right.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/images/tool-calling-wrong.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/index.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/favicon/android-chrome-192x192.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/favicon/android-chrome-512x512.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/favicon/apple-touch-icon.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/favicon/favicon-16x16.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/favicon/favicon-32x32.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/favicon/favicon.ico +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-black.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-black.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-color.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-color.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-white.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-white.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-black.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-black.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-color.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-color.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-white.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-white.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-black.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-black.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-color.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-color.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-large-black.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-large-color.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-large-white.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-white.png +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-white.svg +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/prompt-design.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/rag.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/Chat.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatAnthropic.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatAzureOpenAI.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatBedrockAnthropic.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatGithub.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatGoogle.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatGroq.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatOllama.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatOpenAI.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatPerplexity.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/ChatVertex.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/Provider.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/Tool.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/Turn.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/content_image_file.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/content_image_plot.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/content_image_url.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/image_file.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/image_plot.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/image_url.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/index.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/interpolate.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/interpolate_file.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/token_usage.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ChatResponse.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ChatResponseAsync.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.Content.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentImage.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentImageInline.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentImageRemote.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentJson.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentText.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentToolRequest.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ContentToolResult.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.ImageContentTypes.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.MISSING.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.MISSING_TYPE.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.SubmitInputArgsT.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/reference/types.TokenUsage.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/structured-data.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/styles.scss +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/tool-calling.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/docs/web-apps.qmd +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/pytest.ini +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/scripts/_generate_anthropic_types.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/scripts/_generate_google_types.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/scripts/_generate_openai_types.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/scripts/_generate_snowflake_types.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/scripts/_utils.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/scripts/main.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/__init__.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/__snapshots__/test_chat.ambr +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/apples.pdf +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_auto.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_content.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_content_image.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_content_pdf.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_interpolate.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_provider_azure.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_provider_bedrock.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_tokens.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_turns.py +0 -0
- {chatlas-0.6.1 → chatlas-0.7.0}/tests/test_utils_merge.py +0 -0
|
@@ -29,6 +29,8 @@ jobs:
|
|
|
29
29
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
30
30
|
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
|
|
31
31
|
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
|
|
32
|
+
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
|
|
33
|
+
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
|
|
32
34
|
# Free tier of Google is rate limited, so we only test on 3.12
|
|
33
35
|
TEST_GOOGLE: ${{ matrix.config.test_google }}
|
|
34
36
|
# Free tier of Azure is rate limited, so we only test on 3.12
|
|
@@ -7,6 +7,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
7
7
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
|
+
## [0.7.0] - 2025-04-22
|
|
11
|
+
|
|
12
|
+
### New features
|
|
13
|
+
|
|
14
|
+
* Added `ChatDatabricks()`, for chatting with Databrick's [foundation models](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models). (#82)
|
|
15
|
+
* `.stream()` and `.stream_async()` gain a `content` argument. Set this to `"all"` to include `ContentToolResult`/`ContentToolRequest` objects in the stream. (#75)
|
|
16
|
+
* `ContentToolResult`/`ContentToolRequest` are now exported to `chatlas` namespace. (#75)
|
|
17
|
+
* `ContentToolResult`/`ContentToolRequest` gain a `.tagify()` method so they render sensibly in a Shiny app. (#75)
|
|
18
|
+
* A tool can now return a `ContentToolResult`. This is useful for:
|
|
19
|
+
* Specifying the format used for sending the tool result to the chat model (`model_format`). (#87)
|
|
20
|
+
* Custom rendering of the tool result (by overriding relevant methods in a subclass). (#75)
|
|
21
|
+
* `Chat` gains a new `.current_display` property. When a `.chat()` or `.stream()` is currently active, this property returns an object with a `.echo()` method (to echo new content to the display). This is primarily useful for displaying custom content during a tool call. (#79)
|
|
22
|
+
|
|
23
|
+
### Improvements
|
|
24
|
+
|
|
25
|
+
* When a tool call ends in failure, a warning is now raised and the stacktrace is printed. (#79)
|
|
26
|
+
* Several improvements to `ChatSnowflake()`:
|
|
27
|
+
* `.extract_data()` is now supported.
|
|
28
|
+
* `async` methods are now supported. (#81)
|
|
29
|
+
* Fixed an issue with more than one session being active at once. (#83)
|
|
30
|
+
* `ChatAnthropic()` no longer chokes after receiving an output that consists only of whitespace. (#86)
|
|
31
|
+
* `orjson` is now used for JSON loading and dumping. (#87)
|
|
32
|
+
|
|
33
|
+
### Changes
|
|
34
|
+
|
|
35
|
+
* The `echo` argument of the `.chat()` method defaults to a new value of `"output"`. As a result, tool requests and results are now echoed by default. To revert to the previous behavior, set `echo="text"`. (#78)
|
|
36
|
+
* Tool results are now dumped to JSON by default before being sent to the model. To revert to the previous behavior, have the tool return a `ContentToolResult` with `model_format="str"`. (#87)
|
|
37
|
+
|
|
38
|
+
### Breaking changes
|
|
39
|
+
|
|
40
|
+
* The `.export()` method's `include` argument has been renamed to `content` (to match `.stream()`). (#75)
|
|
41
|
+
|
|
10
42
|
## [0.6.1] - 2025-04-03
|
|
11
43
|
|
|
12
44
|
### Bug fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chatlas
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: A simple and consistent interface for chatting with LLMs
|
|
5
5
|
Project-URL: Homepage, https://posit-dev.github.io/chatlas
|
|
6
6
|
Project-URL: Documentation, https://posit-dev.github.io/chatlas
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Requires-Dist: jinja2
|
|
21
|
+
Requires-Dist: orjson
|
|
21
22
|
Requires-Dist: pydantic>=2.0
|
|
22
23
|
Requires-Dist: requests
|
|
23
24
|
Requires-Dist: rich
|
|
@@ -27,9 +28,13 @@ Provides-Extra: azure-openai
|
|
|
27
28
|
Requires-Dist: openai; extra == 'azure-openai'
|
|
28
29
|
Provides-Extra: bedrock-anthropic
|
|
29
30
|
Requires-Dist: anthropic[bedrock]; extra == 'bedrock-anthropic'
|
|
31
|
+
Provides-Extra: databricks
|
|
32
|
+
Requires-Dist: databricks-sdk[openai]; extra == 'databricks'
|
|
30
33
|
Provides-Extra: dev
|
|
31
34
|
Requires-Dist: anthropic[bedrock]; extra == 'dev'
|
|
35
|
+
Requires-Dist: databricks-sdk; extra == 'dev'
|
|
32
36
|
Requires-Dist: google-genai>=1.2.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: htmltools; extra == 'dev'
|
|
33
38
|
Requires-Dist: matplotlib; extra == 'dev'
|
|
34
39
|
Requires-Dist: numpy>1.24.4; extra == 'dev'
|
|
35
40
|
Requires-Dist: openai; extra == 'dev'
|
|
@@ -38,6 +43,7 @@ Requires-Dist: python-dotenv; extra == 'dev'
|
|
|
38
43
|
Requires-Dist: ruff>=0.6.5; extra == 'dev'
|
|
39
44
|
Requires-Dist: shiny; extra == 'dev'
|
|
40
45
|
Requires-Dist: snowflake-ml-python; extra == 'dev'
|
|
46
|
+
Requires-Dist: tenacity; extra == 'dev'
|
|
41
47
|
Requires-Dist: tiktoken; extra == 'dev'
|
|
42
48
|
Requires-Dist: torch; (python_version <= '3.11') and extra == 'dev'
|
|
43
49
|
Provides-Extra: docs
|
|
@@ -123,6 +129,7 @@ It also supports the following enterprise cloud providers:
|
|
|
123
129
|
|
|
124
130
|
* AWS Bedrock: [`ChatBedrockAnthropic()`](https://posit-dev.github.io/chatlas/reference/ChatBedrockAnthropic.html).
|
|
125
131
|
* Azure OpenAI: [`ChatAzureOpenAI()`](https://posit-dev.github.io/chatlas/reference/ChatAzureOpenAI.html).
|
|
132
|
+
* Databricks: [`ChatDatabricks()`](https://posit-dev.github.io/chatlas/reference/ChatDatabricks.html).
|
|
126
133
|
* Snowflake Cortex: [`ChatSnowflake()`](https://posit-dev.github.io/chatlas/reference/ChatSnowflake.html).
|
|
127
134
|
* Vertex AI: [`ChatVertex()`](https://posit-dev.github.io/chatlas/reference/ChatVertex.html).
|
|
128
135
|
|
|
@@ -47,6 +47,7 @@ It also supports the following enterprise cloud providers:
|
|
|
47
47
|
|
|
48
48
|
* AWS Bedrock: [`ChatBedrockAnthropic()`](https://posit-dev.github.io/chatlas/reference/ChatBedrockAnthropic.html).
|
|
49
49
|
* Azure OpenAI: [`ChatAzureOpenAI()`](https://posit-dev.github.io/chatlas/reference/ChatAzureOpenAI.html).
|
|
50
|
+
* Databricks: [`ChatDatabricks()`](https://posit-dev.github.io/chatlas/reference/ChatDatabricks.html).
|
|
50
51
|
* Snowflake Cortex: [`ChatSnowflake()`](https://posit-dev.github.io/chatlas/reference/ChatSnowflake.html).
|
|
51
52
|
* Vertex AI: [`ChatVertex()`](https://posit-dev.github.io/chatlas/reference/ChatVertex.html).
|
|
52
53
|
|
|
@@ -2,8 +2,10 @@ from . import types
|
|
|
2
2
|
from ._anthropic import ChatAnthropic, ChatBedrockAnthropic
|
|
3
3
|
from ._auto import ChatAuto
|
|
4
4
|
from ._chat import Chat
|
|
5
|
+
from ._content import ContentToolRequest, ContentToolResult
|
|
5
6
|
from ._content_image import content_image_file, content_image_plot, content_image_url
|
|
6
7
|
from ._content_pdf import content_pdf_file, content_pdf_url
|
|
8
|
+
from ._databricks import ChatDatabricks
|
|
7
9
|
from ._github import ChatGithub
|
|
8
10
|
from ._google import ChatGoogle, ChatVertex
|
|
9
11
|
from ._groq import ChatGroq
|
|
@@ -26,6 +28,7 @@ __all__ = (
|
|
|
26
28
|
"ChatAnthropic",
|
|
27
29
|
"ChatAuto",
|
|
28
30
|
"ChatBedrockAnthropic",
|
|
31
|
+
"ChatDatabricks",
|
|
29
32
|
"ChatGithub",
|
|
30
33
|
"ChatGoogle",
|
|
31
34
|
"ChatGroq",
|
|
@@ -41,6 +44,8 @@ __all__ = (
|
|
|
41
44
|
"content_image_url",
|
|
42
45
|
"content_pdf_file",
|
|
43
46
|
"content_pdf_url",
|
|
47
|
+
"ContentToolRequest",
|
|
48
|
+
"ContentToolResult",
|
|
44
49
|
"interpolate",
|
|
45
50
|
"interpolate_file",
|
|
46
51
|
"Provider",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import base64
|
|
4
|
-
import json
|
|
5
4
|
import warnings
|
|
6
5
|
from typing import TYPE_CHECKING, Any, Literal, Optional, Union, cast, overload
|
|
7
6
|
|
|
7
|
+
import orjson
|
|
8
8
|
from pydantic import BaseModel
|
|
9
9
|
|
|
10
10
|
from ._chat import Chat
|
|
@@ -366,8 +366,8 @@ class AnthropicProvider(Provider[Message, RawMessageStreamEvent, Message]):
|
|
|
366
366
|
this_content = completion.content[chunk.index]
|
|
367
367
|
if this_content.type == "tool_use" and isinstance(this_content.input, str):
|
|
368
368
|
try:
|
|
369
|
-
this_content.input =
|
|
370
|
-
except
|
|
369
|
+
this_content.input = orjson.loads(this_content.input or "{}")
|
|
370
|
+
except orjson.JSONDecodeError as e:
|
|
371
371
|
raise ValueError(f"Invalid JSON input: {e}")
|
|
372
372
|
elif chunk.type == "message_delta":
|
|
373
373
|
completion.stop_reason = chunk.delta.stop_reason
|
|
@@ -451,7 +451,10 @@ class AnthropicProvider(Provider[Message, RawMessageStreamEvent, Message]):
|
|
|
451
451
|
@staticmethod
|
|
452
452
|
def _as_content_block(content: Content) -> "ContentBlockParam":
|
|
453
453
|
if isinstance(content, ContentText):
|
|
454
|
-
|
|
454
|
+
text = content.text
|
|
455
|
+
if text == "" or text.isspace():
|
|
456
|
+
text = "[empty string]"
|
|
457
|
+
return {"type": "text", "text": text}
|
|
455
458
|
elif isinstance(content, ContentJson):
|
|
456
459
|
return {"text": "<structured data/>", "type": "text"}
|
|
457
460
|
elif isinstance(content, ContentPDF):
|
|
@@ -485,12 +488,15 @@ class AnthropicProvider(Provider[Message, RawMessageStreamEvent, Message]):
|
|
|
485
488
|
"input": content.arguments,
|
|
486
489
|
}
|
|
487
490
|
elif isinstance(content, ContentToolResult):
|
|
488
|
-
|
|
491
|
+
res: ToolResultBlockParam = {
|
|
489
492
|
"type": "tool_result",
|
|
490
493
|
"tool_use_id": content.id,
|
|
491
|
-
"content": content.get_final_value(),
|
|
492
494
|
"is_error": content.error is not None,
|
|
493
495
|
}
|
|
496
|
+
# Anthropic supports non-text contents like ImageBlockParam
|
|
497
|
+
res["content"] = content.get_model_value() # type: ignore
|
|
498
|
+
return res
|
|
499
|
+
|
|
494
500
|
raise ValueError(f"Unknown content type: {type(content)}")
|
|
495
501
|
|
|
496
502
|
@staticmethod
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import json
|
|
4
3
|
import os
|
|
5
4
|
from typing import Callable, Literal, Optional
|
|
6
5
|
|
|
6
|
+
import orjson
|
|
7
|
+
|
|
7
8
|
from ._anthropic import ChatAnthropic, ChatBedrockAnthropic
|
|
8
9
|
from ._chat import Chat
|
|
10
|
+
from ._databricks import ChatDatabricks
|
|
9
11
|
from ._github import ChatGithub
|
|
10
12
|
from ._google import ChatGoogle, ChatVertex
|
|
11
13
|
from ._groq import ChatGroq
|
|
@@ -18,6 +20,7 @@ from ._turn import Turn
|
|
|
18
20
|
AutoProviders = Literal[
|
|
19
21
|
"anthropic",
|
|
20
22
|
"bedrock-anthropic",
|
|
23
|
+
"databricks",
|
|
21
24
|
"github",
|
|
22
25
|
"google",
|
|
23
26
|
"groq",
|
|
@@ -32,6 +35,7 @@ AutoProviders = Literal[
|
|
|
32
35
|
_provider_chat_model_map: dict[AutoProviders, Callable[..., Chat]] = {
|
|
33
36
|
"anthropic": ChatAnthropic,
|
|
34
37
|
"bedrock-anthropic": ChatBedrockAnthropic,
|
|
38
|
+
"databricks": ChatDatabricks,
|
|
35
39
|
"github": ChatGithub,
|
|
36
40
|
"google": ChatGoogle,
|
|
37
41
|
"groq": ChatGroq,
|
|
@@ -55,7 +59,7 @@ def ChatAuto(
|
|
|
55
59
|
"""
|
|
56
60
|
Use environment variables (env vars) to configure the Chat provider and model.
|
|
57
61
|
|
|
58
|
-
Creates a
|
|
62
|
+
Creates a :class:`~chatlas.Chat` instance based on the specified provider.
|
|
59
63
|
The provider may be specified through the `provider` parameter and/or the
|
|
60
64
|
`CHATLAS_CHAT_PROVIDER` env var. If both are set, the env var takes
|
|
61
65
|
precedence. Similarly, the provider's model may be specified through the
|
|
@@ -175,7 +179,7 @@ def ChatAuto(
|
|
|
175
179
|
|
|
176
180
|
env_kwargs = {}
|
|
177
181
|
if env_kwargs_str := os.environ.get("CHATLAS_CHAT_ARGS"):
|
|
178
|
-
env_kwargs =
|
|
182
|
+
env_kwargs = orjson.loads(env_kwargs_str)
|
|
179
183
|
|
|
180
184
|
kwargs = {**kwargs, **env_kwargs, **base_args}
|
|
181
185
|
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|