chatlas 0.3.0__tar.gz → 0.5.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.3.0 → chatlas-0.5.0}/.github/workflows/check-update-types.yml +5 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/.github/workflows/test.yml +1 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/.gitignore +3 -0
- chatlas-0.5.0/CHANGELOG.md +62 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/Makefile +1 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/PKG-INFO +35 -7
- {chatlas-0.3.0 → chatlas-0.5.0}/README.md +9 -5
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/__init__.py +11 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_anthropic.py +8 -10
- chatlas-0.5.0/chatlas/_auto.py +183 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_chat.py +50 -19
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_content.py +23 -7
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_display.py +12 -2
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_github.py +1 -1
- chatlas-0.5.0/chatlas/_google.py +605 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_groq.py +1 -1
- chatlas-0.5.0/chatlas/_live_render.py +116 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_merge.py +1 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_ollama.py +1 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_openai.py +4 -6
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_perplexity.py +1 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_provider.py +0 -9
- chatlas-0.5.0/chatlas/_snowflake.py +321 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_utils.py +7 -0
- chatlas-0.5.0/chatlas/_version.py +21 -0
- chatlas-0.5.0/chatlas/py.typed +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/__init__.py +5 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/anthropic/_submit.py +24 -2
- chatlas-0.5.0/chatlas/types/google/_client.py +22 -0
- chatlas-0.5.0/chatlas/types/google/_submit.py +66 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/openai/_submit.py +9 -2
- chatlas-0.5.0/chatlas/types/snowflake/__init__.py +8 -0
- chatlas-0.5.0/chatlas/types/snowflake/_submit.py +24 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/_quarto.yml +22 -3
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/_sidebar.yml +5 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/get-started.qmd +2 -2
- chatlas-0.5.0/docs/images/logo.png +0 -0
- chatlas-0.5.0/docs/images/posit-logo.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/index.py +5 -0
- chatlas-0.5.0/docs/reference/Chat.qmd +500 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatAnthropic.qmd +6 -6
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatAzureOpenAI.qmd +8 -8
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatBedrockAnthropic.qmd +58 -10
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatGithub.qmd +7 -7
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatGoogle.qmd +8 -12
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatGroq.qmd +7 -7
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatOllama.qmd +21 -15
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatOpenAI.qmd +7 -7
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/ChatPerplexity.qmd +7 -7
- chatlas-0.5.0/docs/reference/ChatVertex.qmd +62 -0
- chatlas-0.5.0/docs/reference/Turn.qmd +48 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/content_image_file.qmd +6 -6
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/index.qmd +17 -7
- chatlas-0.5.0/docs/reference/interpolate.qmd +37 -0
- chatlas-0.5.0/docs/reference/interpolate_file.qmd +39 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.ChatResponse.qmd +2 -13
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.ChatResponseAsync.qmd +2 -11
- chatlas-0.5.0/docs/reference/types.ContentImage.qmd +11 -0
- chatlas-0.5.0/docs/reference/types.ContentImageInline.qmd +18 -0
- chatlas-0.5.0/docs/reference/types.ContentImageRemote.qmd +17 -0
- chatlas-0.5.0/docs/reference/types.ContentJson.qmd +16 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.ContentText.qmd +1 -0
- chatlas-0.5.0/docs/reference/types.ContentToolRequest.qmd +19 -0
- chatlas-0.5.0/docs/reference/types.ContentToolResult.qmd +20 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/web-apps.qmd +1 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/pyproject.toml +20 -1
- {chatlas-0.3.0 → chatlas-0.5.0}/scripts/_generate_google_types.py +6 -14
- {chatlas-0.3.0 → chatlas-0.5.0}/scripts/_generate_openai_types.py +3 -3
- chatlas-0.5.0/scripts/_generate_snowflake_types.py +33 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/scripts/main.py +1 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/__snapshots__/test_chat.ambr +0 -2
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/conftest.py +23 -3
- chatlas-0.5.0/tests/test_auto.py +109 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_chat.py +1 -2
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_content_tools.py +1 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_provider_anthropic.py +12 -2
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_provider_azure.py +3 -2
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_provider_google.py +4 -4
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_provider_openai.py +5 -1
- chatlas-0.3.0/CHANGELOG.md +0 -26
- chatlas-0.3.0/chatlas/_google.py +0 -508
- chatlas-0.3.0/chatlas/types/google/_client.py +0 -101
- chatlas-0.3.0/chatlas/types/google/_submit.py +0 -113
- chatlas-0.3.0/docs/reference/Chat.qmd +0 -296
- chatlas-0.3.0/docs/reference/Turn.qmd +0 -47
- chatlas-0.3.0/docs/reference/types.ContentImage.qmd +0 -6
- chatlas-0.3.0/docs/reference/types.ContentImageInline.qmd +0 -6
- chatlas-0.3.0/docs/reference/types.ContentImageRemote.qmd +0 -6
- chatlas-0.3.0/docs/reference/types.ContentJson.qmd +0 -6
- chatlas-0.3.0/docs/reference/types.ContentToolRequest.qmd +0 -6
- chatlas-0.3.0/docs/reference/types.ContentToolResult.qmd +0 -6
- {chatlas-0.3.0 → chatlas-0.5.0}/.github/workflows/docs-publish.yml +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/.github/workflows/release.yml +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/.vscode/extensions.json +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/.vscode/settings.json +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_content_image.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_interpolate.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_logging.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_tokens.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_tokens_old.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_tools.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_turn.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/_typing_extensions.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/anthropic/__init__.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/anthropic/_client.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/anthropic/_client_bedrock.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/google/__init__.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/openai/__init__.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/openai/_client.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/chatlas/types/openai/_client_azure.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/.gitignore +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/_extensions/machow/interlinks/.gitignore +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/_extensions/machow/interlinks/_extension.yml +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/_extensions/machow/interlinks/interlinks.lua +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/congressional-assets.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/examples/third-party-testing.txt +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/images/congressional-assets.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/images/tool-calling-right.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/images/tool-calling-wrong.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/favicon/android-chrome-192x192.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/favicon/android-chrome-512x512.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/favicon/apple-touch-icon.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/favicon/favicon-16x16.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/favicon/favicon-32x32.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/favicon/favicon.ico +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/icon/brand-yml-icon-black.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/icon/brand-yml-icon-black.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/icon/brand-yml-icon-color.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/icon/brand-yml-icon-color.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/icon/brand-yml-icon-white.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/icon/brand-yml-icon-white.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/tall/brand-yml-tall-black.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/tall/brand-yml-tall-black.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/tall/brand-yml-tall-color.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/tall/brand-yml-tall-color.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/tall/brand-yml-tall-white.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/tall/brand-yml-tall-white.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-black.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-black.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-color.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-color.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-large-black.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-large-color.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-large-white.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-white.png +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/logos/wide/brand-yml-wide-white.svg +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/prompt-design.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/rag.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/Provider.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/Tool.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/content_image_plot.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/content_image_url.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/image_file.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/image_plot.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/image_url.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/token_usage.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.Content.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.ImageContentTypes.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.MISSING.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.MISSING_TYPE.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.SubmitInputArgsT.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/reference/types.TokenUsage.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/structured-data.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/styles.scss +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/docs/tool-calling.qmd +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/pytest.ini +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/scripts/_generate_anthropic_types.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/scripts/_utils.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/__init__.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_content.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_content_image.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_interpolate.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_provider_bedrock.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_tokens.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_turns.py +0 -0
- {chatlas-0.3.0 → chatlas-0.5.0}/tests/test_utils_merge.py +0 -0
|
@@ -36,7 +36,12 @@ jobs:
|
|
|
36
36
|
# Fail if there are changes under chatlas/types and throw a useful error message
|
|
37
37
|
- name: Check for changes
|
|
38
38
|
run: |
|
|
39
|
+
echo "Checking for changes in types..."
|
|
40
|
+
git status chatlas/types
|
|
41
|
+
git diff --stat chatlas/types
|
|
39
42
|
if [[ -n $(git diff chatlas/types) ]]; then
|
|
43
|
+
echo "Changes detected:"
|
|
44
|
+
git diff chatlas/types
|
|
40
45
|
echo "::error::Types are out of date. Please run 'make update-types' and commit the changes."
|
|
41
46
|
exit 1
|
|
42
47
|
fi
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
All notable changes to this project will be documented in this file.
|
|
5
|
+
|
|
6
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
## [0.5.0] - 2025-03-18
|
|
11
|
+
|
|
12
|
+
### New features
|
|
13
|
+
|
|
14
|
+
* Added a `ChatSnowflake()` class to interact with [Snowflake Cortex LLM](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions). (#54)
|
|
15
|
+
* Added a `ChatAuto()` class, allowing for configuration of chat providers and models via environment variables. (#38, thanks @mconflitti-pbc)
|
|
16
|
+
|
|
17
|
+
### Improvements
|
|
18
|
+
|
|
19
|
+
* Updated `ChatAnthropic()`'s `model` default to `"claude-3-7-sonnet-latest"`. (#62)
|
|
20
|
+
* The version is now accessible as `chatlas.__version__`. (#64)
|
|
21
|
+
* All provider-specific `Chat` subclasses now have an associated extras in chatlas. For example, `ChatOpenAI` has `chatlas[openai]`, `ChatPerplexity` has `chatlas[perplexity]`, `ChatBedrockAnthropic` has `chatlas[bedrock-anthropic]`, and so forth for the other `Chat` classes. (#66)
|
|
22
|
+
|
|
23
|
+
### Bug fixes
|
|
24
|
+
|
|
25
|
+
* Fixed an issue with content getting duplicated when it overflows in a `Live()` console. (#71)
|
|
26
|
+
* Fix an issue with tool calls not working with `ChatVertex()`. (#61)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [0.4.0] - 2025-02-19
|
|
30
|
+
|
|
31
|
+
### New features
|
|
32
|
+
|
|
33
|
+
* Added a `ChatVertex()` class to interact with Google Cloud's Vertex AI. (#50)
|
|
34
|
+
* Added `.app(*, echo=)` support. This allows for chatlas to change the echo behavior when running the Shiny app. (#31)
|
|
35
|
+
|
|
36
|
+
### Improvements
|
|
37
|
+
|
|
38
|
+
* Migrated `ChatGoogle()`'s underlying python SDK from `google-generative` to `google-genai`. As a result, streaming tools are now working properly. (#50)
|
|
39
|
+
|
|
40
|
+
### Bug fixes
|
|
41
|
+
|
|
42
|
+
* Fixed a bug where synchronous chat tools would not work properly when used in a `_async()` context. (#56)
|
|
43
|
+
* Fix broken `Chat`'s Shiny app when `.app(*, stream=True)` by using async chat tools. (#31)
|
|
44
|
+
* Update formatting of exported markdown to use `repr()` instead of `str()` when exporting tool call results. (#30)
|
|
45
|
+
|
|
46
|
+
## [0.3.0] - 2024-12-20
|
|
47
|
+
|
|
48
|
+
### New features
|
|
49
|
+
|
|
50
|
+
* `Chat`'s `.tokens()` method gains a `values` argument. Set it to `"discrete"` to get a result that can be summed to determine the token cost of submitting the current turns. The default (`"cumulative"`), remains the same (the result can be summed to determine the overall token cost of the conversation).
|
|
51
|
+
* `Chat` gains a `.token_count()` method to help estimate token cost of new input. (#23)
|
|
52
|
+
|
|
53
|
+
### Bug fixes
|
|
54
|
+
|
|
55
|
+
* `ChatOllama` no longer fails when a `OPENAI_API_KEY` environment variable is not set.
|
|
56
|
+
* `ChatOpenAI` now correctly includes the relevant `detail` on `ContentImageRemote()` input.
|
|
57
|
+
* `ChatGoogle` now correctly logs its `token_usage()`. (#23)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## [0.2.0] - 2024-12-11
|
|
61
|
+
|
|
62
|
+
First stable release of `chatlas`, see the website to learn more <https://posit-dev.github.io/chatlas/>
|
|
@@ -9,7 +9,7 @@ build: ## [py] Build python package
|
|
|
9
9
|
uv build
|
|
10
10
|
|
|
11
11
|
.PHONY: check
|
|
12
|
-
check:
|
|
12
|
+
check: check-format check-types check-tests ## [py] Run python checks
|
|
13
13
|
|
|
14
14
|
.PHONY: check-tests
|
|
15
15
|
check-tests: ## [py] Run python tests
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chatlas
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -20,9 +20,15 @@ Requires-Python: >=3.9
|
|
|
20
20
|
Requires-Dist: jinja2
|
|
21
21
|
Requires-Dist: pydantic>=2.0
|
|
22
22
|
Requires-Dist: rich
|
|
23
|
+
Provides-Extra: anthropic
|
|
24
|
+
Requires-Dist: anthropic; extra == 'anthropic'
|
|
25
|
+
Provides-Extra: azure-openai
|
|
26
|
+
Requires-Dist: openai; extra == 'azure-openai'
|
|
27
|
+
Provides-Extra: bedrock-anthropic
|
|
28
|
+
Requires-Dist: anthropic[bedrock]; extra == 'bedrock-anthropic'
|
|
23
29
|
Provides-Extra: dev
|
|
24
30
|
Requires-Dist: anthropic[bedrock]; extra == 'dev'
|
|
25
|
-
Requires-Dist: google-
|
|
31
|
+
Requires-Dist: google-genai>=1.2.0; extra == 'dev'
|
|
26
32
|
Requires-Dist: matplotlib; extra == 'dev'
|
|
27
33
|
Requires-Dist: numpy>1.24.4; extra == 'dev'
|
|
28
34
|
Requires-Dist: openai; extra == 'dev'
|
|
@@ -30,7 +36,9 @@ Requires-Dist: pillow; extra == 'dev'
|
|
|
30
36
|
Requires-Dist: python-dotenv; extra == 'dev'
|
|
31
37
|
Requires-Dist: ruff>=0.6.5; extra == 'dev'
|
|
32
38
|
Requires-Dist: shiny; extra == 'dev'
|
|
39
|
+
Requires-Dist: snowflake-ml-python; extra == 'dev'
|
|
33
40
|
Requires-Dist: tiktoken; extra == 'dev'
|
|
41
|
+
Requires-Dist: torch; (python_version <= '3.11') and extra == 'dev'
|
|
34
42
|
Provides-Extra: docs
|
|
35
43
|
Requires-Dist: griffe>=1; extra == 'docs'
|
|
36
44
|
Requires-Dist: ipykernel; extra == 'docs'
|
|
@@ -42,14 +50,32 @@ Requires-Dist: pandas; extra == 'docs'
|
|
|
42
50
|
Requires-Dist: pyyaml; extra == 'docs'
|
|
43
51
|
Requires-Dist: quartodoc>=0.7; extra == 'docs'
|
|
44
52
|
Requires-Dist: sentence-transformers; extra == 'docs'
|
|
53
|
+
Provides-Extra: github
|
|
54
|
+
Requires-Dist: openai; extra == 'github'
|
|
55
|
+
Provides-Extra: google
|
|
56
|
+
Requires-Dist: google-genai; extra == 'google'
|
|
57
|
+
Provides-Extra: groq
|
|
58
|
+
Requires-Dist: openai; extra == 'groq'
|
|
59
|
+
Provides-Extra: ollama
|
|
60
|
+
Requires-Dist: openai; extra == 'ollama'
|
|
61
|
+
Provides-Extra: openai
|
|
62
|
+
Requires-Dist: openai; extra == 'openai'
|
|
63
|
+
Provides-Extra: perplexity
|
|
64
|
+
Requires-Dist: openai; extra == 'perplexity'
|
|
65
|
+
Provides-Extra: snowflake
|
|
66
|
+
Requires-Dist: snowflake-ml-python; extra == 'snowflake'
|
|
45
67
|
Provides-Extra: test
|
|
46
68
|
Requires-Dist: pyright>=1.1.379; extra == 'test'
|
|
47
69
|
Requires-Dist: pytest-asyncio; extra == 'test'
|
|
48
70
|
Requires-Dist: pytest>=8.3.2; extra == 'test'
|
|
49
71
|
Requires-Dist: syrupy>=4; extra == 'test'
|
|
72
|
+
Provides-Extra: vertex
|
|
73
|
+
Requires-Dist: google-genai; extra == 'vertex'
|
|
50
74
|
Description-Content-Type: text/markdown
|
|
51
75
|
|
|
52
|
-
|
|
76
|
+
<h1 class="unnumbered unlisted"> chatlas <a href="https://posit-dev.github.io/chatlas"><img src="docs/images/logo.png" align="right" height="138" alt="chatlas website" /></a> </h1>
|
|
77
|
+
|
|
78
|
+
|
|
53
79
|
|
|
54
80
|
<p>
|
|
55
81
|
<!-- badges start -->
|
|
@@ -60,11 +86,11 @@ Description-Content-Type: text/markdown
|
|
|
60
86
|
</p>
|
|
61
87
|
|
|
62
88
|
chatlas provides a simple and unified interface across large language model (llm) providers in Python.
|
|
63
|
-
It
|
|
64
|
-
|
|
65
|
-
Developer experience is also a key focus of chatlas: typing support, rich console output, and
|
|
89
|
+
It helps you prototype faster by abstracting away complexity from common tasks like streaming chat interfaces, tool calling, structured output, and much more.
|
|
90
|
+
Switching providers is also as easy as changing one line of code, but you can also reach for provider-specific features when you need them.
|
|
91
|
+
Developer experience is also a key focus of chatlas: typing support, rich console output, and extension points are all included.
|
|
66
92
|
|
|
67
|
-
(Looking for something similar to chatlas, but in R? Check out [
|
|
93
|
+
(Looking for something similar to chatlas, but in R? Check out [ellmer](https://ellmer.tidyverse.org/)!)
|
|
68
94
|
|
|
69
95
|
## Install
|
|
70
96
|
|
|
@@ -96,6 +122,8 @@ It also supports the following enterprise cloud providers:
|
|
|
96
122
|
|
|
97
123
|
* AWS Bedrock: [`ChatBedrockAnthropic()`](https://posit-dev.github.io/chatlas/reference/ChatBedrockAnthropic.html).
|
|
98
124
|
* Azure OpenAI: [`ChatAzureOpenAI()`](https://posit-dev.github.io/chatlas/reference/ChatAzureOpenAI.html).
|
|
125
|
+
* Snowflake Cortex: [`ChatSnowflake()`](https://posit-dev.github.io/chatlas/reference/ChatSnowflake.html).
|
|
126
|
+
* Vertex AI: [`ChatVertex()`](https://posit-dev.github.io/chatlas/reference/ChatVertex.html).
|
|
99
127
|
|
|
100
128
|
To use a model provider that isn't listed here, you have two options:
|
|
101
129
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 class="unnumbered unlisted"> chatlas <a href="https://posit-dev.github.io/chatlas"><img src="docs/images/logo.png" align="right" height="138" alt="chatlas website" /></a> </h1>
|
|
2
|
+
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
<p>
|
|
4
6
|
<!-- badges start -->
|
|
@@ -9,11 +11,11 @@
|
|
|
9
11
|
</p>
|
|
10
12
|
|
|
11
13
|
chatlas provides a simple and unified interface across large language model (llm) providers in Python.
|
|
12
|
-
It
|
|
13
|
-
|
|
14
|
-
Developer experience is also a key focus of chatlas: typing support, rich console output, and
|
|
14
|
+
It helps you prototype faster by abstracting away complexity from common tasks like streaming chat interfaces, tool calling, structured output, and much more.
|
|
15
|
+
Switching providers is also as easy as changing one line of code, but you can also reach for provider-specific features when you need them.
|
|
16
|
+
Developer experience is also a key focus of chatlas: typing support, rich console output, and extension points are all included.
|
|
15
17
|
|
|
16
|
-
(Looking for something similar to chatlas, but in R? Check out [
|
|
18
|
+
(Looking for something similar to chatlas, but in R? Check out [ellmer](https://ellmer.tidyverse.org/)!)
|
|
17
19
|
|
|
18
20
|
## Install
|
|
19
21
|
|
|
@@ -45,6 +47,8 @@ It also supports the following enterprise cloud providers:
|
|
|
45
47
|
|
|
46
48
|
* AWS Bedrock: [`ChatBedrockAnthropic()`](https://posit-dev.github.io/chatlas/reference/ChatBedrockAnthropic.html).
|
|
47
49
|
* Azure OpenAI: [`ChatAzureOpenAI()`](https://posit-dev.github.io/chatlas/reference/ChatAzureOpenAI.html).
|
|
50
|
+
* Snowflake Cortex: [`ChatSnowflake()`](https://posit-dev.github.io/chatlas/reference/ChatSnowflake.html).
|
|
51
|
+
* Vertex AI: [`ChatVertex()`](https://posit-dev.github.io/chatlas/reference/ChatVertex.html).
|
|
48
52
|
|
|
49
53
|
To use a model provider that isn't listed here, you have two options:
|
|
50
54
|
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
from . import types
|
|
2
2
|
from ._anthropic import ChatAnthropic, ChatBedrockAnthropic
|
|
3
|
+
from ._auto import ChatAuto
|
|
3
4
|
from ._chat import Chat
|
|
4
5
|
from ._content_image import content_image_file, content_image_plot, content_image_url
|
|
5
6
|
from ._github import ChatGithub
|
|
6
|
-
from ._google import ChatGoogle
|
|
7
|
+
from ._google import ChatGoogle, ChatVertex
|
|
7
8
|
from ._groq import ChatGroq
|
|
8
9
|
from ._interpolate import interpolate, interpolate_file
|
|
9
10
|
from ._ollama import ChatOllama
|
|
10
11
|
from ._openai import ChatAzureOpenAI, ChatOpenAI
|
|
11
12
|
from ._perplexity import ChatPerplexity
|
|
12
13
|
from ._provider import Provider
|
|
14
|
+
from ._snowflake import ChatSnowflake
|
|
13
15
|
from ._tokens import token_usage
|
|
14
16
|
from ._tools import Tool
|
|
15
17
|
from ._turn import Turn
|
|
16
18
|
|
|
19
|
+
try:
|
|
20
|
+
from ._version import version as __version__
|
|
21
|
+
except ImportError: # pragma: no cover
|
|
22
|
+
__version__ = "0.0.0" # stub value for docs
|
|
23
|
+
|
|
17
24
|
__all__ = (
|
|
18
25
|
"ChatAnthropic",
|
|
26
|
+
"ChatAuto",
|
|
19
27
|
"ChatBedrockAnthropic",
|
|
20
28
|
"ChatGithub",
|
|
21
29
|
"ChatGoogle",
|
|
@@ -24,6 +32,8 @@ __all__ = (
|
|
|
24
32
|
"ChatOpenAI",
|
|
25
33
|
"ChatAzureOpenAI",
|
|
26
34
|
"ChatPerplexity",
|
|
35
|
+
"ChatSnowflake",
|
|
36
|
+
"ChatVertex",
|
|
27
37
|
"Chat",
|
|
28
38
|
"content_image_file",
|
|
29
39
|
"content_image_plot",
|
|
@@ -72,7 +72,7 @@ def ChatAnthropic(
|
|
|
72
72
|
::: {.callout-note}
|
|
73
73
|
## API key
|
|
74
74
|
|
|
75
|
-
Note that a Claude
|
|
75
|
+
Note that a Claude Pro membership does not give you the ability to call
|
|
76
76
|
models via the API. You will need to go to the [developer
|
|
77
77
|
console](https://console.anthropic.com/account/keys) to sign up (and pay
|
|
78
78
|
for) a developer account that will give you an API key that you can use with
|
|
@@ -82,7 +82,7 @@ def ChatAnthropic(
|
|
|
82
82
|
::: {.callout-note}
|
|
83
83
|
## Python requirements
|
|
84
84
|
|
|
85
|
-
`ChatAnthropic` requires the `anthropic` package
|
|
85
|
+
`ChatAnthropic` requires the `anthropic` package: `pip install "chatlas[anthropic]"`.
|
|
86
86
|
:::
|
|
87
87
|
|
|
88
88
|
Examples
|
|
@@ -164,7 +164,7 @@ def ChatAnthropic(
|
|
|
164
164
|
"""
|
|
165
165
|
|
|
166
166
|
if model is None:
|
|
167
|
-
model = log_model_default("claude-3-
|
|
167
|
+
model = log_model_default("claude-3-7-sonnet-latest")
|
|
168
168
|
|
|
169
169
|
return Chat(
|
|
170
170
|
provider=AnthropicProvider(
|
|
@@ -311,7 +311,8 @@ class AnthropicProvider(Provider[Message, RawMessageStreamEvent, Message]):
|
|
|
311
311
|
if stream:
|
|
312
312
|
stream = False
|
|
313
313
|
warnings.warn(
|
|
314
|
-
"Anthropic does not support structured data extraction in streaming mode."
|
|
314
|
+
"Anthropic does not support structured data extraction in streaming mode.",
|
|
315
|
+
stacklevel=2,
|
|
315
316
|
)
|
|
316
317
|
|
|
317
318
|
kwargs_full: "SubmitInputArgs" = {
|
|
@@ -371,10 +372,7 @@ class AnthropicProvider(Provider[Message, RawMessageStreamEvent, Message]):
|
|
|
371
372
|
|
|
372
373
|
return completion
|
|
373
374
|
|
|
374
|
-
def stream_turn(self, completion, has_data_model
|
|
375
|
-
return self._as_turn(completion, has_data_model)
|
|
376
|
-
|
|
377
|
-
async def stream_turn_async(self, completion, has_data_model, stream) -> Turn:
|
|
375
|
+
def stream_turn(self, completion, has_data_model) -> Turn:
|
|
378
376
|
return self._as_turn(completion, has_data_model)
|
|
379
377
|
|
|
380
378
|
def value_turn(self, completion, has_data_model) -> Turn:
|
|
@@ -574,8 +572,8 @@ def ChatBedrockAnthropic(
|
|
|
574
572
|
::: {.callout-note}
|
|
575
573
|
## Python requirements
|
|
576
574
|
|
|
577
|
-
`ChatBedrockAnthropic`, requires the `anthropic` package with the `bedrock` extras
|
|
578
|
-
|
|
575
|
+
`ChatBedrockAnthropic`, requires the `anthropic` package with the `bedrock` extras:
|
|
576
|
+
`pip install "chatlas[bedrock-anthropic]"`
|
|
579
577
|
:::
|
|
580
578
|
|
|
581
579
|
Examples
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from typing import Callable, Literal, Optional
|
|
6
|
+
|
|
7
|
+
from ._anthropic import ChatAnthropic, ChatBedrockAnthropic
|
|
8
|
+
from ._chat import Chat
|
|
9
|
+
from ._github import ChatGithub
|
|
10
|
+
from ._google import ChatGoogle, ChatVertex
|
|
11
|
+
from ._groq import ChatGroq
|
|
12
|
+
from ._ollama import ChatOllama
|
|
13
|
+
from ._openai import ChatAzureOpenAI, ChatOpenAI
|
|
14
|
+
from ._perplexity import ChatPerplexity
|
|
15
|
+
from ._snowflake import ChatSnowflake
|
|
16
|
+
from ._turn import Turn
|
|
17
|
+
|
|
18
|
+
AutoProviders = Literal[
|
|
19
|
+
"anthropic",
|
|
20
|
+
"bedrock-anthropic",
|
|
21
|
+
"github",
|
|
22
|
+
"google",
|
|
23
|
+
"groq",
|
|
24
|
+
"ollama",
|
|
25
|
+
"openai",
|
|
26
|
+
"azure-openai",
|
|
27
|
+
"perplexity",
|
|
28
|
+
"snowflake",
|
|
29
|
+
"vertex",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
_provider_chat_model_map: dict[AutoProviders, Callable[..., Chat]] = {
|
|
33
|
+
"anthropic": ChatAnthropic,
|
|
34
|
+
"bedrock-anthropic": ChatBedrockAnthropic,
|
|
35
|
+
"github": ChatGithub,
|
|
36
|
+
"google": ChatGoogle,
|
|
37
|
+
"groq": ChatGroq,
|
|
38
|
+
"ollama": ChatOllama,
|
|
39
|
+
"openai": ChatOpenAI,
|
|
40
|
+
"azure-openai": ChatAzureOpenAI,
|
|
41
|
+
"perplexity": ChatPerplexity,
|
|
42
|
+
"snowflake": ChatSnowflake,
|
|
43
|
+
"vertex": ChatVertex,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def ChatAuto(
|
|
48
|
+
system_prompt: Optional[str] = None,
|
|
49
|
+
turns: Optional[list[Turn]] = None,
|
|
50
|
+
*,
|
|
51
|
+
provider: Optional[AutoProviders] = None,
|
|
52
|
+
model: Optional[str] = None,
|
|
53
|
+
**kwargs,
|
|
54
|
+
) -> Chat:
|
|
55
|
+
"""
|
|
56
|
+
Use environment variables (env vars) to configure the Chat provider and model.
|
|
57
|
+
|
|
58
|
+
Creates a `:class:~chatlas.Chat` instance based on the specified provider.
|
|
59
|
+
The provider may be specified through the `provider` parameter and/or the
|
|
60
|
+
`CHATLAS_CHAT_PROVIDER` env var. If both are set, the env var takes
|
|
61
|
+
precedence. Similarly, the provider's model may be specified through the
|
|
62
|
+
`model` parameter and/or the `CHATLAS_CHAT_MODEL` env var. Also, additional
|
|
63
|
+
configuration may be provided through the `kwargs` parameter and/or the
|
|
64
|
+
`CHATLAS_CHAT_ARGS` env var (as a JSON string). In this case, when both are
|
|
65
|
+
set, they are merged, with the env var arguments taking precedence.
|
|
66
|
+
|
|
67
|
+
As a result, `ChatAuto()` provides a convenient way to set a default
|
|
68
|
+
provider and model in your Python code, while allowing you to override
|
|
69
|
+
these settings through env vars (i.e., without modifying your code).
|
|
70
|
+
|
|
71
|
+
Prerequisites
|
|
72
|
+
-------------
|
|
73
|
+
|
|
74
|
+
::: {.callout-note}
|
|
75
|
+
## API key
|
|
76
|
+
|
|
77
|
+
Follow the instructions for the specific provider to obtain an API key.
|
|
78
|
+
:::
|
|
79
|
+
|
|
80
|
+
::: {.callout-note}
|
|
81
|
+
## Python requirements
|
|
82
|
+
|
|
83
|
+
Follow the instructions for the specific provider to install the required
|
|
84
|
+
Python packages.
|
|
85
|
+
:::
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Examples
|
|
89
|
+
--------
|
|
90
|
+
First, set the environment variables for the provider, arguments, and API key:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
export CHATLAS_CHAT_PROVIDER=anthropic
|
|
94
|
+
export CHATLAS_CHAT_MODEL=claude-3-haiku-20240229
|
|
95
|
+
export CHATLAS_CHAT_ARGS='{"kwargs": {"max_retries": 3}}'
|
|
96
|
+
export ANTHROPIC_API_KEY=your_api_key
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Then, you can use the `ChatAuto` function to create a Chat instance:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from chatlas import ChatAuto
|
|
103
|
+
|
|
104
|
+
chat = ChatAuto()
|
|
105
|
+
chat.chat("What is the capital of France?")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
provider
|
|
111
|
+
The name of the default chat provider to use. Providers are strings
|
|
112
|
+
formatted in kebab-case, e.g. to use `ChatBedrockAnthropic` set
|
|
113
|
+
`provider="bedrock-anthropic"`.
|
|
114
|
+
|
|
115
|
+
This value can also be provided via the `CHATLAS_CHAT_PROVIDER`
|
|
116
|
+
environment variable, which takes precedence over `provider`
|
|
117
|
+
when set.
|
|
118
|
+
model
|
|
119
|
+
The name of the default model to use. This value can also be provided
|
|
120
|
+
via the `CHATLAS_CHAT_MODEL` environment variable, which takes
|
|
121
|
+
precedence over `model` when set.
|
|
122
|
+
system_prompt
|
|
123
|
+
A system prompt to set the behavior of the assistant.
|
|
124
|
+
turns
|
|
125
|
+
A list of turns to start the chat with (i.e., continuing a previous
|
|
126
|
+
conversation). If not provided, the conversation begins from scratch. Do
|
|
127
|
+
not provide non-`None` values for both `turns` and `system_prompt`. Each
|
|
128
|
+
message in the list should be a dictionary with at least `role` (usually
|
|
129
|
+
`system`, `user`, or `assistant`, but `tool` is also possible). Normally
|
|
130
|
+
there is also a `content` field, which is a string.
|
|
131
|
+
**kwargs
|
|
132
|
+
Additional keyword arguments to pass to the Chat constructor. See the
|
|
133
|
+
documentation for each provider for more details on the available
|
|
134
|
+
options.
|
|
135
|
+
|
|
136
|
+
These arguments can also be provided via the `CHATLAS_CHAT_ARGS`
|
|
137
|
+
environment variable as a JSON string. When provided, the options
|
|
138
|
+
in the `CHATLAS_CHAT_ARGS` envvar take precedence over the options
|
|
139
|
+
passed to `kwargs`.
|
|
140
|
+
|
|
141
|
+
Note that `system_prompt` and `turns` in `kwargs` or in
|
|
142
|
+
`CHATLAS_CHAT_ARGS` are ignored.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
Chat
|
|
147
|
+
A chat instance using the specified provider.
|
|
148
|
+
|
|
149
|
+
Raises
|
|
150
|
+
------
|
|
151
|
+
ValueError
|
|
152
|
+
If no valid provider is specified either through parameters or
|
|
153
|
+
environment variables.
|
|
154
|
+
"""
|
|
155
|
+
the_provider = os.environ.get("CHATLAS_CHAT_PROVIDER", provider)
|
|
156
|
+
|
|
157
|
+
if the_provider is None:
|
|
158
|
+
raise ValueError(
|
|
159
|
+
"Provider name is required as parameter or `CHATLAS_CHAT_PROVIDER` must be set."
|
|
160
|
+
)
|
|
161
|
+
if the_provider not in _provider_chat_model_map:
|
|
162
|
+
raise ValueError(
|
|
163
|
+
f"Provider name '{the_provider}' is not a known chatlas provider: "
|
|
164
|
+
f"{', '.join(_provider_chat_model_map.keys())}"
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# `system_prompt` and `turns` always come from `ChatAuto()`
|
|
168
|
+
base_args = {"system_prompt": system_prompt, "turns": turns}
|
|
169
|
+
|
|
170
|
+
if env_model := os.environ.get("CHATLAS_CHAT_MODEL"):
|
|
171
|
+
model = env_model
|
|
172
|
+
|
|
173
|
+
if model:
|
|
174
|
+
base_args["model"] = model
|
|
175
|
+
|
|
176
|
+
env_kwargs = {}
|
|
177
|
+
if env_kwargs_str := os.environ.get("CHATLAS_CHAT_ARGS"):
|
|
178
|
+
env_kwargs = json.loads(env_kwargs_str)
|
|
179
|
+
|
|
180
|
+
kwargs = {**kwargs, **env_kwargs, **base_args}
|
|
181
|
+
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
|
182
|
+
|
|
183
|
+
return _provider_chat_model_map[the_provider](**kwargs)
|