model-library 0.1.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.
Files changed (114) hide show
  1. model_library-0.1.0/.gitattributes +4 -0
  2. model_library-0.1.0/.github/workflows/publish.yml +96 -0
  3. model_library-0.1.0/.github/workflows/style.yaml +27 -0
  4. model_library-0.1.0/.github/workflows/test.yaml +27 -0
  5. model_library-0.1.0/.github/workflows/typecheck.yml +27 -0
  6. model_library-0.1.0/.gitignore +4 -0
  7. model_library-0.1.0/LICENSE +21 -0
  8. model_library-0.1.0/Makefile +90 -0
  9. model_library-0.1.0/PKG-INFO +268 -0
  10. model_library-0.1.0/README.md +241 -0
  11. model_library-0.1.0/examples/README.md +32 -0
  12. model_library-0.1.0/examples/advanced/batch.py +111 -0
  13. model_library-0.1.0/examples/advanced/custom_retrier.py +148 -0
  14. model_library-0.1.0/examples/advanced/deep_research.py +60 -0
  15. model_library-0.1.0/examples/advanced/stress.py +67 -0
  16. model_library-0.1.0/examples/advanced/structured_output.py +49 -0
  17. model_library-0.1.0/examples/advanced/web_search.py +144 -0
  18. model_library-0.1.0/examples/basics.py +130 -0
  19. model_library-0.1.0/examples/data/files.py +34 -0
  20. model_library-0.1.0/examples/data/images.py +21 -0
  21. model_library-0.1.0/examples/embeddings.py +68 -0
  22. model_library-0.1.0/examples/files.py +95 -0
  23. model_library-0.1.0/examples/images.py +95 -0
  24. model_library-0.1.0/examples/prompt_caching.py +93 -0
  25. model_library-0.1.0/examples/setup.py +39 -0
  26. model_library-0.1.0/examples/tool_calls.py +116 -0
  27. model_library-0.1.0/model_library/__init__.py +23 -0
  28. model_library-0.1.0/model_library/base.py +814 -0
  29. model_library-0.1.0/model_library/config/ai21labs_models.yaml +99 -0
  30. model_library-0.1.0/model_library/config/alibaba_models.yaml +91 -0
  31. model_library-0.1.0/model_library/config/all_models.json +13479 -0
  32. model_library-0.1.0/model_library/config/amazon_models.yaml +276 -0
  33. model_library-0.1.0/model_library/config/anthropic_models.yaml +370 -0
  34. model_library-0.1.0/model_library/config/cohere_models.yaml +177 -0
  35. model_library-0.1.0/model_library/config/deepseek_models.yaml +47 -0
  36. model_library-0.1.0/model_library/config/dummy_model.yaml +38 -0
  37. model_library-0.1.0/model_library/config/fireworks_models.yaml +228 -0
  38. model_library-0.1.0/model_library/config/google_models.yaml +516 -0
  39. model_library-0.1.0/model_library/config/inception_models.yaml +24 -0
  40. model_library-0.1.0/model_library/config/kimi_models.yaml +34 -0
  41. model_library-0.1.0/model_library/config/mistral_models.yaml +143 -0
  42. model_library-0.1.0/model_library/config/openai_models.yaml +783 -0
  43. model_library-0.1.0/model_library/config/perplexity_models.yaml +91 -0
  44. model_library-0.1.0/model_library/config/together_models.yaml +866 -0
  45. model_library-0.1.0/model_library/config/xai_models.yaml +266 -0
  46. model_library-0.1.0/model_library/config/zai_models.yaml +65 -0
  47. model_library-0.1.0/model_library/exceptions.py +288 -0
  48. model_library-0.1.0/model_library/file_utils.py +114 -0
  49. model_library-0.1.0/model_library/model_utils.py +26 -0
  50. model_library-0.1.0/model_library/providers/ai21labs.py +193 -0
  51. model_library-0.1.0/model_library/providers/alibaba.py +147 -0
  52. model_library-0.1.0/model_library/providers/amazon.py +367 -0
  53. model_library-0.1.0/model_library/providers/anthropic.py +419 -0
  54. model_library-0.1.0/model_library/providers/azure.py +43 -0
  55. model_library-0.1.0/model_library/providers/cohere.py +100 -0
  56. model_library-0.1.0/model_library/providers/deepseek.py +115 -0
  57. model_library-0.1.0/model_library/providers/fireworks.py +133 -0
  58. model_library-0.1.0/model_library/providers/google/__init__.py +4 -0
  59. model_library-0.1.0/model_library/providers/google/batch.py +299 -0
  60. model_library-0.1.0/model_library/providers/google/google.py +467 -0
  61. model_library-0.1.0/model_library/providers/inception.py +102 -0
  62. model_library-0.1.0/model_library/providers/kimi.py +102 -0
  63. model_library-0.1.0/model_library/providers/mistral.py +299 -0
  64. model_library-0.1.0/model_library/providers/openai.py +924 -0
  65. model_library-0.1.0/model_library/providers/perplexity.py +101 -0
  66. model_library-0.1.0/model_library/providers/together.py +249 -0
  67. model_library-0.1.0/model_library/providers/vals.py +307 -0
  68. model_library-0.1.0/model_library/providers/xai.py +332 -0
  69. model_library-0.1.0/model_library/providers/zai.py +102 -0
  70. model_library-0.1.0/model_library/py.typed +0 -0
  71. model_library-0.1.0/model_library/register_models.py +385 -0
  72. model_library-0.1.0/model_library/registry_utils.py +202 -0
  73. model_library-0.1.0/model_library/settings.py +34 -0
  74. model_library-0.1.0/model_library/utils.py +151 -0
  75. model_library-0.1.0/model_library.egg-info/PKG-INFO +268 -0
  76. model_library-0.1.0/model_library.egg-info/SOURCES.txt +112 -0
  77. model_library-0.1.0/model_library.egg-info/dependency_links.txt +1 -0
  78. model_library-0.1.0/model_library.egg-info/requires.txt +16 -0
  79. model_library-0.1.0/model_library.egg-info/top_level.txt +1 -0
  80. model_library-0.1.0/pyproject.toml +91 -0
  81. model_library-0.1.0/scripts/config.py +43 -0
  82. model_library-0.1.0/scripts/explore_models.py +83 -0
  83. model_library-0.1.0/scripts/publish.py +66 -0
  84. model_library-0.1.0/scripts/run_models.py +246 -0
  85. model_library-0.1.0/setup.cfg +4 -0
  86. model_library-0.1.0/tests/README.md +87 -0
  87. model_library-0.1.0/tests/__init__.py +0 -0
  88. model_library-0.1.0/tests/conftest.py +271 -0
  89. model_library-0.1.0/tests/integration/__init__.py +0 -0
  90. model_library-0.1.0/tests/integration/conftest.py +8 -0
  91. model_library-0.1.0/tests/integration/test_batch.py +154 -0
  92. model_library-0.1.0/tests/integration/test_completion.py +41 -0
  93. model_library-0.1.0/tests/integration/test_files.py +279 -0
  94. model_library-0.1.0/tests/integration/test_reasoning.py +68 -0
  95. model_library-0.1.0/tests/integration/test_retry.py +95 -0
  96. model_library-0.1.0/tests/integration/test_streaming.py +162 -0
  97. model_library-0.1.0/tests/integration/test_structured_output.py +171 -0
  98. model_library-0.1.0/tests/integration/test_tools.py +135 -0
  99. model_library-0.1.0/tests/test_helpers.py +89 -0
  100. model_library-0.1.0/tests/unit/__init__.py +0 -0
  101. model_library-0.1.0/tests/unit/conftest.py +28 -0
  102. model_library-0.1.0/tests/unit/providers/__init__.py +0 -0
  103. model_library-0.1.0/tests/unit/providers/test_fireworks_provider.py +47 -0
  104. model_library-0.1.0/tests/unit/providers/test_google_provider.py +58 -0
  105. model_library-0.1.0/tests/unit/test_batch.py +236 -0
  106. model_library-0.1.0/tests/unit/test_context_window.py +45 -0
  107. model_library-0.1.0/tests/unit/test_deep_research.py +120 -0
  108. model_library-0.1.0/tests/unit/test_model_registry.py +66 -0
  109. model_library-0.1.0/tests/unit/test_perplexity_provider.py +71 -0
  110. model_library-0.1.0/tests/unit/test_prompt_caching.py +159 -0
  111. model_library-0.1.0/tests/unit/test_retry.py +289 -0
  112. model_library-0.1.0/tests/unit/test_streaming.py +83 -0
  113. model_library-0.1.0/tests/unit/test_tools.py +150 -0
  114. model_library-0.1.0/uv.lock +1895 -0
@@ -0,0 +1,4 @@
1
+ * text=auto
2
+ *.json text eol=lf
3
+ *.yaml text eol=lf
4
+ *.yml text eol=lf
@@ -0,0 +1,96 @@
1
+ name: Publish vals-model-library to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ build:
10
+ name: Build Wheel Distribution
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install build tools
24
+ run: python3 -m pip install build --user
25
+
26
+ - name: Build a binary wheel and a source tarball
27
+ run: python3 -m build
28
+
29
+ - name: Store the distribution packages
30
+ uses: actions/upload-artifact@v4
31
+ with:
32
+ name: python-package-distributions
33
+ path: dist/
34
+
35
+ publish-to-pypi:
36
+ name: Publish to Production PyPi Server
37
+ if: startsWith(github.ref, 'refs/tags/v')
38
+ needs:
39
+ - build
40
+ runs-on: ubuntu-latest
41
+ environment:
42
+ name: pypi-prod
43
+ url: https://pypi.org/p/vals-model-library
44
+ permissions:
45
+ id-token: write
46
+
47
+ steps:
48
+ - name: Download all the dists
49
+ uses: actions/download-artifact@v4
50
+ with:
51
+ name: python-package-distributions
52
+ path: dist/
53
+
54
+ - name: Publish distribution to PyPI
55
+ uses: pypa/gh-action-pypi-publish@release/v1
56
+
57
+ github-release:
58
+ name: Sign Distribution and Upload to GitHub Release
59
+ needs:
60
+ - publish-to-pypi
61
+ runs-on: ubuntu-latest
62
+
63
+ permissions:
64
+ contents: write
65
+ id-token: write
66
+
67
+ steps:
68
+ - name: Download all the dists
69
+ uses: actions/download-artifact@v4
70
+ with:
71
+ name: python-package-distributions
72
+ path: dist/
73
+
74
+ - name: Sign the dists with Sigstore
75
+ uses: sigstore/gh-action-sigstore-python@v2.1.1
76
+ with:
77
+ inputs: |
78
+ ./dist/*.tar.gz
79
+ ./dist/*.whl
80
+
81
+ - name: Create GitHub Release
82
+ env:
83
+ GITHUB_TOKEN: ${{ github.token }}
84
+ run: >-
85
+ gh release create
86
+ '${{ github.ref_name }}'
87
+ --repo '${{ github.repository }}'
88
+ --notes ""
89
+
90
+ - name: Upload artifact signatures to GitHub Release
91
+ env:
92
+ GITHUB_TOKEN: ${{ github.token }}
93
+ run: >-
94
+ gh release upload
95
+ '${{ github.ref_name }}' dist/**
96
+ --repo '${{ github.repository }}'
@@ -0,0 +1,27 @@
1
+ name: Style
2
+ on:
3
+ pull_request:
4
+ types: [opened, reopened, synchronize]
5
+ jobs:
6
+ style:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+
11
+ - name: Install uv
12
+ uses: astral-sh/setup-uv@v5
13
+ with:
14
+ enable-cache: true
15
+ cache-local-path: ".setup-uv-cache"
16
+ cache-dependency-glob: "uv.lock"
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install dependencies
24
+ run: make install
25
+
26
+ - name: Run style check
27
+ run: make style-check
@@ -0,0 +1,27 @@
1
+ name: Test
2
+ on:
3
+ pull_request:
4
+ types: [opened, reopened, synchronize]
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+
11
+ - name: Install uv
12
+ uses: astral-sh/setup-uv@v5
13
+ with:
14
+ enable-cache: true
15
+ cache-local-path: ".setup-uv-cache"
16
+ cache-dependency-glob: "uv.lock"
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install dependencies
24
+ run: make install
25
+
26
+ - name: Run tests
27
+ run: make test
@@ -0,0 +1,27 @@
1
+ name: Typecheck
2
+ on:
3
+ pull_request:
4
+ types: [opened, reopened, synchronize]
5
+ jobs:
6
+ typecheck:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+
11
+ - name: Install uv
12
+ uses: astral-sh/setup-uv@v5
13
+ with:
14
+ enable-cache: true
15
+ cache-local-path: ".setup-uv-cache"
16
+ cache-dependency-glob: "uv.lock"
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install dependencies
24
+ run: make install
25
+
26
+ - name: Run typecheck
27
+ run: make typecheck
@@ -0,0 +1,4 @@
1
+ model_library.egg-info
2
+ **/__pycache__
3
+ CLAUDE.md
4
+ .env
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Vals AI, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,90 @@
1
+ .PHONY: help install test test-integration test-all style style-check typecheck config run-models examples browse_models
2
+
3
+ help:
4
+ @echo "Makefile for model-library"
5
+ @echo "Usage:"
6
+ @echo " make install Install dependencies"
7
+ @echo " make test Run unit tests"
8
+ @echo " make test-integration Run integration tests (requires API keys)"
9
+ @echo " make test-all Run all tests (unit + integration)"
10
+ @echo " make style Lint & Format"
11
+ @echo " make style-check Check style"
12
+ @echo " make typecheck Typecheck"
13
+ @echo " make config Generate all_models.json"
14
+ @echo " make run-models Run all models"
15
+ @echo " make examples Run all examples"
16
+ @echo " make examples <model> Run all examples with specified model"
17
+ @echo " make browse_models Interactively browse models and their configurations"
18
+
19
+ install:
20
+ uv venv
21
+ uv sync --dev
22
+ @echo "🎉 Done! Run 'source .venv/bin/activate' to activate the environment locally."
23
+
24
+ venv_check:
25
+ @if [ ! -f .venv/bin/activate ]; then \
26
+ echo "❌ Virtualenv not found! Run \`make install\` first."; \
27
+ exit 1; \
28
+ fi
29
+
30
+ test: venv_check
31
+ @echo "Running unit tests..."
32
+ @uv run pytest tests/unit/ -m "not integration"
33
+ test-integration: venv_check
34
+ @echo "Running integration tests (requires API keys)..."
35
+ @uv run pytest tests/integration/ -m "not unit"
36
+ test-all: venv_check
37
+ @echo "Running all tests..."
38
+ @uv run pytest
39
+
40
+ format: venv_check
41
+ @uv run ruff format .
42
+ lint: venv_check
43
+ @uv run ruff check --fix .
44
+ style: format lint
45
+
46
+ style-check: venv_check
47
+ @uv run ruff format --check .
48
+ @uv run ruff check .
49
+
50
+ typecheck: venv_check
51
+ @uv run basedpyright
52
+
53
+ config: venv_check
54
+ @uv run python scripts/config.py
55
+
56
+ run-models: venv_check
57
+ @uv run python -m scripts.run_models
58
+
59
+ examples: venv_check
60
+ @echo "Running examples with model: $(filter-out $@,$(MAKECMDGOALS))"
61
+ @echo "\n=== Running basics.py ==="
62
+ @uv run python -m examples.basics $(filter-out $@,$(MAKECMDGOALS)) || true
63
+ @echo "\n=== Running images.py ==="
64
+ @uv run python -m examples.images $(filter-out $@,$(MAKECMDGOALS)) || true
65
+ @echo "\n=== Running files.py ==="
66
+ @uv run python -m examples.files $(filter-out $@,$(MAKECMDGOALS)) || true
67
+ @echo "\n=== Running tool_calls.py ==="
68
+ @uv run python -m examples.tool_calls $(filter-out $@,$(MAKECMDGOALS)) || true
69
+ @echo "\n=== Running advanced.structured_output ==="
70
+ @uv run python -m examples.advanced.structured_output $(filter-out $@,$(MAKECMDGOALS)) || true
71
+ @echo "\n=== Running advanced.batch ==="
72
+ @uv run python -m examples.advanced.batch $(filter-out $@,$(MAKECMDGOALS)) || true
73
+ @echo "\n=== Running advanced.custom_retrier ==="
74
+ @uv run python -m examples.advanced.custom_retrier $(filter-out $@,$(MAKECMDGOALS)) || true
75
+ @echo "\n=== Running advanced.stress ==="
76
+ @uv run python -m examples.advanced.stress $(filter-out $@,$(MAKECMDGOALS)) || true
77
+
78
+ @if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
79
+ echo "\n=== Running embeddings.py ==="; \
80
+ uv run python -m examples.embeddings; \
81
+
82
+ echo "\n=== Running advanced.deep_research ==="; \
83
+ uv run python -m examples.advanced.deep_research; \
84
+ fi
85
+
86
+ @echo "\n✅ All examples completed!"
87
+
88
+ browse_models: venv_check
89
+ @uv run python -m scripts.explore_models
90
+
@@ -0,0 +1,268 @@
1
+ Metadata-Version: 2.4
2
+ Name: model-library
3
+ Version: 0.1.0
4
+ Summary: Model Library for vals.ai
5
+ Author-email: "Vals AI, Inc." <contact@vals.ai>
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: typing-extensions<5.0,>=4.14.1
11
+ Requires-Dist: pydantic<3.0,>=2.11.7
12
+ Requires-Dist: pyyaml>=6.0.2
13
+ Requires-Dist: backoff<3.0,>=2.2.1
14
+ Requires-Dist: redis<7.0,>=6.2.0
15
+ Requires-Dist: tiktoken==0.11.0
16
+ Requires-Dist: pillow
17
+ Requires-Dist: openai<2.0,>=1.97.1
18
+ Requires-Dist: anthropic<1.0,>=0.57.1
19
+ Requires-Dist: together<2.0,>=1.5.25
20
+ Requires-Dist: mistralai<2.0,>=1.9.10
21
+ Requires-Dist: xai-sdk<2.0,>=1.0.0
22
+ Requires-Dist: ai21<5.0,>=4.0.3
23
+ Requires-Dist: boto3<2.0,>=1.38.27
24
+ Requires-Dist: google-genai[aiohttp]<2.0,>=1.48.0
25
+ Requires-Dist: google-cloud-storage>=1.26.0
26
+ Dynamic: license-file
27
+
28
+ # Model Library
29
+
30
+ Open-source model library for interacting with a variety of LLM providers. Originally developed for internal use at [vals.ai](https://vals.ai/) benchmarks. This tool is designed to be a general-purpose solution for any project requiring a unified interface for multiple model providers.
31
+
32
+ `pip install model-library`
33
+
34
+ **Note**: This library is undergoing rapid development. Expect breaking changes.
35
+
36
+ ## Features
37
+
38
+ ### Providers
39
+
40
+ - AI21 Labs
41
+ - Alibaba
42
+ - Amazon Bedrock
43
+ - Anthropic
44
+ - Azure OpenAI
45
+ - Cohere
46
+ - DeepSeek
47
+ - Fireworks
48
+ - Google Gemini
49
+ - Mistral
50
+ - Perplexity
51
+ - Together AI
52
+ - OpenAI
53
+ - X AI
54
+ - ZhipuAI (zai)
55
+
56
+ Run `python -m scripts.browse_models` to browse the model registry.
57
+
58
+ ### Supported Input
59
+
60
+ - Images
61
+ - Files
62
+ - Tools (with full history)
63
+ - Batch
64
+ - Reasoning
65
+ - Custom Parameters
66
+
67
+ ## Usage
68
+
69
+ Here is a basic example of how to query a model:
70
+
71
+ ```python
72
+ import asyncio
73
+ from model_library.registry_utils import get_registry_model
74
+
75
+ async def main():
76
+ # Load a model from the registry
77
+ model = get_registry_model("openai/gemini-2.5-flash")
78
+
79
+ # Query the model with a simple text input
80
+ response = await model.query("What is QSBS? Explain your thinking in detail and make it concise.")
81
+
82
+ # Logger automatically logs the response
83
+
84
+ if __name__ == "__main__":
85
+ asyncio.run(main())
86
+ ```
87
+
88
+ The model registry holds model attributes, ex. reasoning, file support, tool support, max tokens. You may also use models not included in the registry.
89
+
90
+ ```python
91
+ model = get_raw_model("openai/gpt-3.5-turbo", config=LLMConfig(max_tokens=1000))
92
+ ```
93
+
94
+ ### Environment Setup
95
+
96
+ The model library will use:
97
+ - Environment varibles for API keys
98
+ - OPENAI_API_KEY
99
+ - ANTHROPIC_API_KEY
100
+ - GOOGLE_API_KEY
101
+ - ...
102
+
103
+ - Variables set through model_library.settings
104
+ ```python
105
+ from model_library import model_library_settings
106
+
107
+ model_library_settings.set(MY_KEY="my-key")
108
+ ```
109
+
110
+
111
+ ### System Prompt
112
+
113
+ ```bash
114
+ python -m examples.basics
115
+ ```
116
+
117
+ ```python
118
+ await model.query(
119
+ [TextInput(text="Hello, how are you?")],
120
+ system_prompt="You are a pirate, answer in the speaking style of a pirate. Keeps responses under 10 words",
121
+ )
122
+ ```
123
+
124
+ ### Image/File Input
125
+
126
+ Supports base64, url, and file id (file upload)
127
+
128
+ ```bash
129
+ python -m examples.images
130
+ ```
131
+
132
+ ```python
133
+ red_image_content = b"..."
134
+
135
+ await model.query(
136
+ [
137
+ TextInput(text="What color is the image?"),
138
+ FileWithBase64(
139
+ type="image",
140
+ name="red_image.png",
141
+ mime="png",
142
+ base64=base64.b64encode(red_image_content).decode("utf-8"),
143
+ ),
144
+ ]
145
+ )
146
+ ```
147
+
148
+ ### Tool Calls
149
+
150
+ ```bash
151
+ python -m examples.tool_calls
152
+ ```
153
+
154
+ ```python
155
+ tools = [
156
+ ToolDefinition(
157
+ name="get_weather",
158
+ body=ToolBody(
159
+ name="get_weather",
160
+ description="Get current temperature in a given location",
161
+ properties={
162
+ "location": {
163
+ "type": "string",
164
+ "description": "City and country e.g. Bogotá, Colombia",
165
+ },
166
+ },
167
+ required=["location"],
168
+ ),
169
+ )
170
+ ]
171
+
172
+ output1 = await model.query(
173
+ [TextInput(text="What is the weather in SF right now?")],
174
+ tools=tools,
175
+ )
176
+
177
+ output2 = await model.query(
178
+ [
179
+ # assume one tool call was made
180
+ ToolResult(tool_call=output1.tool_calls[0], result="25C"),
181
+ TextInput(
182
+ text="Also, includes some weird emojies in your answer (at least 8 of them)"
183
+ ),
184
+ ],
185
+ history=output1.history,
186
+ tools=tools,
187
+ ```
188
+
189
+ ### Full examples
190
+
191
+ You can run `make examples` (default models) or `make example <model>` to run all examples.
192
+
193
+ `python -m examples.basics`
194
+
195
+ `python -m examples.images`
196
+
197
+ `python -m examples.files`
198
+
199
+ `python -m examples.tool_calls`
200
+
201
+ `python -m examples.embeddings`
202
+
203
+ `python -m examples.advanced.batch`
204
+
205
+ `python -m examples.advanced.custom_retrier`
206
+
207
+ `python -m examples.advanced.stress`
208
+
209
+ `python -m examples.advanced.deep_research`
210
+
211
+
212
+ ## Architecture
213
+
214
+ Designed to abstract different LLM providers:
215
+
216
+ - **LLM Base Class**: An abstract base class that defines a common interface for all models
217
+ - **Model Registry**: A central registry that loads model configurations from YAML files
218
+ - **Provider-Specific Implementations**: Concrete classes for each provider (e.g., OpenAI, Google, Anthropic) that inherit from the `LLM` base class
219
+ - **Data Models**: A set of `pydantic` models for representing various input and output types, such as `TextInput`, `FileWithBase64`, `ToolDefinition`, and `ToolResult`. This ensures code is model agnostic, and easy to maintain.
220
+ - **Retry Logic**: A set of retry strategies for handling errors and rate limiting
221
+
222
+ ## Contributing
223
+
224
+ ### Setup
225
+
226
+ We use [uv](https://docs.astral.sh/uv/getting-started/installation/) for dependency management.
227
+ A Makefile is provided to help with development.
228
+
229
+ To install dependencies, run:
230
+
231
+ ```bash
232
+ make install
233
+ ```
234
+
235
+ ### Makefile commands
236
+
237
+ ```bash
238
+ make install Install dependencies"
239
+ make test Run unit tests"
240
+ make test-integration Run integration tests (requires API keys)"
241
+ make test-all Run all tests (unit + integration)"
242
+ make style Lint & Format"
243
+ make style-check Check style"
244
+ make typecheck Typecheck"
245
+ make config Generate all_models.json"
246
+ make run-models Run all models"
247
+ make examples Run all examples"
248
+ make examples <model> Run all examples with specified model"
249
+ make browse-models Browse all models"
250
+ ```
251
+
252
+ ### Testing
253
+
254
+ #### Unit Tests
255
+
256
+ Unit tests do not require API keys
257
+
258
+ ```bash
259
+ make test-unit
260
+ ```
261
+
262
+ #### Integration Tests
263
+
264
+ Make sure you have API keys configured
265
+
266
+ ```bash
267
+ make test-integration
268
+ ```