chatlas 0.6.0__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.

Files changed (173) hide show
  1. {chatlas-0.6.0 → chatlas-0.7.0}/.github/workflows/test.yml +2 -0
  2. {chatlas-0.6.0 → chatlas-0.7.0}/CHANGELOG.md +38 -0
  3. {chatlas-0.6.0 → chatlas-0.7.0}/PKG-INFO +29 -1
  4. {chatlas-0.6.0 → chatlas-0.7.0}/README.md +21 -0
  5. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/__init__.py +5 -0
  6. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_anthropic.py +12 -6
  7. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_auto.py +7 -3
  8. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_chat.py +339 -120
  9. chatlas-0.7.0/chatlas/_content.py +545 -0
  10. chatlas-0.7.0/chatlas/_databricks.py +145 -0
  11. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_display.py +13 -7
  12. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_google.py +9 -5
  13. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_ollama.py +3 -2
  14. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_openai.py +9 -8
  15. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_snowflake.py +46 -23
  16. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_utils.py +36 -1
  17. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_version.py +2 -2
  18. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/openai/_submit.py +11 -1
  19. {chatlas-0.6.0 → chatlas-0.7.0}/docs/_quarto.yml +1 -0
  20. {chatlas-0.6.0 → chatlas-0.7.0}/pyproject.toml +6 -0
  21. {chatlas-0.6.0 → chatlas-0.7.0}/tests/conftest.py +47 -26
  22. chatlas-0.7.0/tests/images/dice.png +0 -0
  23. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_chat.py +1 -2
  24. chatlas-0.7.0/tests/test_content_tools.py +322 -0
  25. chatlas-0.7.0/tests/test_provider_anthropic.py +130 -0
  26. chatlas-0.7.0/tests/test_provider_databricks.py +75 -0
  27. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_provider_google.py +53 -23
  28. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_provider_openai.py +2 -1
  29. chatlas-0.6.0/chatlas/_content.py +0 -347
  30. chatlas-0.6.0/tests/test_content_tools.py +0 -153
  31. chatlas-0.6.0/tests/test_provider_anthropic.py +0 -103
  32. {chatlas-0.6.0 → chatlas-0.7.0}/.github/workflows/check-update-types.yml +0 -0
  33. {chatlas-0.6.0 → chatlas-0.7.0}/.github/workflows/docs-publish.yml +0 -0
  34. {chatlas-0.6.0 → chatlas-0.7.0}/.github/workflows/release.yml +0 -0
  35. {chatlas-0.6.0 → chatlas-0.7.0}/.gitignore +0 -0
  36. {chatlas-0.6.0 → chatlas-0.7.0}/.vscode/extensions.json +0 -0
  37. {chatlas-0.6.0 → chatlas-0.7.0}/.vscode/settings.json +0 -0
  38. {chatlas-0.6.0 → chatlas-0.7.0}/Makefile +0 -0
  39. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_content_image.py +0 -0
  40. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_content_pdf.py +0 -0
  41. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_github.py +0 -0
  42. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_groq.py +0 -0
  43. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_interpolate.py +0 -0
  44. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_live_render.py +0 -0
  45. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_logging.py +0 -0
  46. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_merge.py +0 -0
  47. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_perplexity.py +0 -0
  48. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_provider.py +0 -0
  49. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_tokens.py +0 -0
  50. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_tokens_old.py +0 -0
  51. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_tools.py +0 -0
  52. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_turn.py +0 -0
  53. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/_typing_extensions.py +0 -0
  54. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/py.typed +0 -0
  55. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/__init__.py +0 -0
  56. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/anthropic/__init__.py +0 -0
  57. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/anthropic/_client.py +0 -0
  58. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/anthropic/_client_bedrock.py +0 -0
  59. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/anthropic/_submit.py +0 -0
  60. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/google/__init__.py +0 -0
  61. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/google/_client.py +0 -0
  62. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/google/_submit.py +0 -0
  63. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/openai/__init__.py +0 -0
  64. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/openai/_client.py +0 -0
  65. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/openai/_client_azure.py +0 -0
  66. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/snowflake/__init__.py +0 -0
  67. {chatlas-0.6.0 → chatlas-0.7.0}/chatlas/types/snowflake/_submit.py +0 -0
  68. {chatlas-0.6.0 → chatlas-0.7.0}/docs/.gitignore +0 -0
  69. {chatlas-0.6.0 → chatlas-0.7.0}/docs/_extensions/machow/interlinks/.gitignore +0 -0
  70. {chatlas-0.6.0 → chatlas-0.7.0}/docs/_extensions/machow/interlinks/_extension.yml +0 -0
  71. {chatlas-0.6.0 → chatlas-0.7.0}/docs/_extensions/machow/interlinks/interlinks.lua +0 -0
  72. {chatlas-0.6.0 → chatlas-0.7.0}/docs/_sidebar.yml +0 -0
  73. {chatlas-0.6.0 → chatlas-0.7.0}/docs/congressional-assets.png +0 -0
  74. {chatlas-0.6.0 → chatlas-0.7.0}/docs/examples/third-party-testing.txt +0 -0
  75. {chatlas-0.6.0 → chatlas-0.7.0}/docs/get-started.qmd +0 -0
  76. {chatlas-0.6.0 → chatlas-0.7.0}/docs/images/congressional-assets.png +0 -0
  77. {chatlas-0.6.0 → chatlas-0.7.0}/docs/images/logo.png +0 -0
  78. {chatlas-0.6.0 → chatlas-0.7.0}/docs/images/posit-logo.png +0 -0
  79. {chatlas-0.6.0 → chatlas-0.7.0}/docs/images/tool-calling-right.svg +0 -0
  80. {chatlas-0.6.0 → chatlas-0.7.0}/docs/images/tool-calling-wrong.svg +0 -0
  81. {chatlas-0.6.0 → chatlas-0.7.0}/docs/index.py +0 -0
  82. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/favicon/android-chrome-192x192.png +0 -0
  83. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/favicon/android-chrome-512x512.png +0 -0
  84. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/favicon/apple-touch-icon.png +0 -0
  85. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/favicon/favicon-16x16.png +0 -0
  86. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/favicon/favicon-32x32.png +0 -0
  87. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/favicon/favicon.ico +0 -0
  88. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-black.png +0 -0
  89. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-black.svg +0 -0
  90. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-color.png +0 -0
  91. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-color.svg +0 -0
  92. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-white.png +0 -0
  93. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/icon/brand-yml-icon-white.svg +0 -0
  94. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-black.png +0 -0
  95. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-black.svg +0 -0
  96. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-color.png +0 -0
  97. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-color.svg +0 -0
  98. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-white.png +0 -0
  99. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/tall/brand-yml-tall-white.svg +0 -0
  100. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-black.png +0 -0
  101. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-black.svg +0 -0
  102. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-color.png +0 -0
  103. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-color.svg +0 -0
  104. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-large-black.png +0 -0
  105. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-large-color.png +0 -0
  106. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-large-white.png +0 -0
  107. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-white.png +0 -0
  108. {chatlas-0.6.0 → chatlas-0.7.0}/docs/logos/wide/brand-yml-wide-white.svg +0 -0
  109. {chatlas-0.6.0 → chatlas-0.7.0}/docs/prompt-design.qmd +0 -0
  110. {chatlas-0.6.0 → chatlas-0.7.0}/docs/rag.qmd +0 -0
  111. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/Chat.qmd +0 -0
  112. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatAnthropic.qmd +0 -0
  113. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatAzureOpenAI.qmd +0 -0
  114. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatBedrockAnthropic.qmd +0 -0
  115. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatGithub.qmd +0 -0
  116. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatGoogle.qmd +0 -0
  117. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatGroq.qmd +0 -0
  118. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatOllama.qmd +0 -0
  119. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatOpenAI.qmd +0 -0
  120. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatPerplexity.qmd +0 -0
  121. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/ChatVertex.qmd +0 -0
  122. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/Provider.qmd +0 -0
  123. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/Tool.qmd +0 -0
  124. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/Turn.qmd +0 -0
  125. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/content_image_file.qmd +0 -0
  126. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/content_image_plot.qmd +0 -0
  127. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/content_image_url.qmd +0 -0
  128. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/image_file.qmd +0 -0
  129. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/image_plot.qmd +0 -0
  130. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/image_url.qmd +0 -0
  131. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/index.qmd +0 -0
  132. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/interpolate.qmd +0 -0
  133. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/interpolate_file.qmd +0 -0
  134. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/token_usage.qmd +0 -0
  135. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ChatResponse.qmd +0 -0
  136. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ChatResponseAsync.qmd +0 -0
  137. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.Content.qmd +0 -0
  138. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentImage.qmd +0 -0
  139. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentImageInline.qmd +0 -0
  140. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentImageRemote.qmd +0 -0
  141. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentJson.qmd +0 -0
  142. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentText.qmd +0 -0
  143. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentToolRequest.qmd +0 -0
  144. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ContentToolResult.qmd +0 -0
  145. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.ImageContentTypes.qmd +0 -0
  146. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.MISSING.qmd +0 -0
  147. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.MISSING_TYPE.qmd +0 -0
  148. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.SubmitInputArgsT.qmd +0 -0
  149. {chatlas-0.6.0 → chatlas-0.7.0}/docs/reference/types.TokenUsage.qmd +0 -0
  150. {chatlas-0.6.0 → chatlas-0.7.0}/docs/structured-data.qmd +0 -0
  151. {chatlas-0.6.0 → chatlas-0.7.0}/docs/styles.scss +0 -0
  152. {chatlas-0.6.0 → chatlas-0.7.0}/docs/tool-calling.qmd +0 -0
  153. {chatlas-0.6.0 → chatlas-0.7.0}/docs/web-apps.qmd +0 -0
  154. {chatlas-0.6.0 → chatlas-0.7.0}/pytest.ini +0 -0
  155. {chatlas-0.6.0 → chatlas-0.7.0}/scripts/_generate_anthropic_types.py +0 -0
  156. {chatlas-0.6.0 → chatlas-0.7.0}/scripts/_generate_google_types.py +0 -0
  157. {chatlas-0.6.0 → chatlas-0.7.0}/scripts/_generate_openai_types.py +0 -0
  158. {chatlas-0.6.0 → chatlas-0.7.0}/scripts/_generate_snowflake_types.py +0 -0
  159. {chatlas-0.6.0 → chatlas-0.7.0}/scripts/_utils.py +0 -0
  160. {chatlas-0.6.0 → chatlas-0.7.0}/scripts/main.py +0 -0
  161. {chatlas-0.6.0 → chatlas-0.7.0}/tests/__init__.py +0 -0
  162. {chatlas-0.6.0 → chatlas-0.7.0}/tests/__snapshots__/test_chat.ambr +0 -0
  163. {chatlas-0.6.0 → chatlas-0.7.0}/tests/apples.pdf +0 -0
  164. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_auto.py +0 -0
  165. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_content.py +0 -0
  166. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_content_image.py +0 -0
  167. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_content_pdf.py +0 -0
  168. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_interpolate.py +0 -0
  169. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_provider_azure.py +0 -0
  170. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_provider_bedrock.py +0 -0
  171. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_tokens.py +0 -0
  172. {chatlas-0.6.0 → chatlas-0.7.0}/tests/test_turns.py +0 -0
  173. {chatlas-0.6.0 → 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,44 @@ 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
+
42
+ ## [0.6.1] - 2025-04-03
43
+
44
+ ### Bug fixes
45
+
46
+ * Fixed a missing dependency on the `requests` package.
47
+
10
48
  ## [0.6.0] - 2025-04-01
11
49
 
12
50
  ### New features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chatlas
3
- Version: 0.6.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,7 +18,9 @@ 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
23
+ Requires-Dist: requests
22
24
  Requires-Dist: rich
23
25
  Provides-Extra: anthropic
24
26
  Requires-Dist: anthropic; extra == 'anthropic'
@@ -26,9 +28,13 @@ Provides-Extra: azure-openai
26
28
  Requires-Dist: openai; extra == 'azure-openai'
27
29
  Provides-Extra: bedrock-anthropic
28
30
  Requires-Dist: anthropic[bedrock]; extra == 'bedrock-anthropic'
31
+ Provides-Extra: databricks
32
+ Requires-Dist: databricks-sdk[openai]; extra == 'databricks'
29
33
  Provides-Extra: dev
30
34
  Requires-Dist: anthropic[bedrock]; extra == 'dev'
35
+ Requires-Dist: databricks-sdk; extra == 'dev'
31
36
  Requires-Dist: google-genai>=1.2.0; extra == 'dev'
37
+ Requires-Dist: htmltools; extra == 'dev'
32
38
  Requires-Dist: matplotlib; extra == 'dev'
33
39
  Requires-Dist: numpy>1.24.4; extra == 'dev'
34
40
  Requires-Dist: openai; extra == 'dev'
@@ -37,6 +43,7 @@ Requires-Dist: python-dotenv; extra == 'dev'
37
43
  Requires-Dist: ruff>=0.6.5; extra == 'dev'
38
44
  Requires-Dist: shiny; extra == 'dev'
39
45
  Requires-Dist: snowflake-ml-python; extra == 'dev'
46
+ Requires-Dist: tenacity; extra == 'dev'
40
47
  Requires-Dist: tiktoken; extra == 'dev'
41
48
  Requires-Dist: torch; (python_version <= '3.11') and extra == 'dev'
42
49
  Provides-Extra: docs
@@ -122,6 +129,7 @@ It also supports the following enterprise cloud providers:
122
129
 
123
130
  * AWS Bedrock: [`ChatBedrockAnthropic()`](https://posit-dev.github.io/chatlas/reference/ChatBedrockAnthropic.html).
124
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).
125
133
  * Snowflake Cortex: [`ChatSnowflake()`](https://posit-dev.github.io/chatlas/reference/ChatSnowflake.html).
126
134
  * Vertex AI: [`ChatVertex()`](https://posit-dev.github.io/chatlas/reference/ChatVertex.html).
127
135
 
@@ -281,6 +289,26 @@ chat.extract_data(
281
289
 
282
290
  Learn more in the [structured data article](https://posit-dev.github.io/chatlas/structured-data.html)
283
291
 
292
+ ### Multi-modal input
293
+
294
+ Attach images and pdfs when submitting input to using any one of the `content_*` functions.
295
+
296
+ ```python
297
+ from chatlas import content_image_url
298
+
299
+ chat.chat(
300
+ content_image_url("https://www.python.org/static/img/python-logo.png"),
301
+ "What do you see in this image?"
302
+ )
303
+ ```
304
+
305
+ ```
306
+ This image displays the logo of the Python programming language. It features the word "python" alongside the distinctive two snake heads logo, which is colored in blue and yellow.
307
+ ```
308
+
309
+ Learn more in the [content reference pages](https://posit-dev.github.io/chatlas/reference/content_image_url.html) for more details on the available content types.
310
+
311
+
284
312
  ### Export chat
285
313
 
286
314
  Easily get a full markdown or HTML export of a conversation:
@@ -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
 
@@ -206,6 +207,26 @@ chat.extract_data(
206
207
 
207
208
  Learn more in the [structured data article](https://posit-dev.github.io/chatlas/structured-data.html)
208
209
 
210
+ ### Multi-modal input
211
+
212
+ Attach images and pdfs when submitting input to using any one of the `content_*` functions.
213
+
214
+ ```python
215
+ from chatlas import content_image_url
216
+
217
+ chat.chat(
218
+ content_image_url("https://www.python.org/static/img/python-logo.png"),
219
+ "What do you see in this image?"
220
+ )
221
+ ```
222
+
223
+ ```
224
+ This image displays the logo of the Python programming language. It features the word "python" alongside the distinctive two snake heads logo, which is colored in blue and yellow.
225
+ ```
226
+
227
+ Learn more in the [content reference pages](https://posit-dev.github.io/chatlas/reference/content_image_url.html) for more details on the available content types.
228
+
229
+
209
230
  ### Export chat
210
231
 
211
232
  Easily get a full markdown or HTML export of a conversation:
@@ -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 = json.loads(this_content.input or "{}")
370
- except json.JSONDecodeError as e:
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
- return {"text": content.text, "type": "text"}
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
- return {
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 `:class:~chatlas.Chat` instance based on the specified provider.
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 = json.loads(env_kwargs_str)
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}