LLM Adapters Package Documentation
List of currently supported models
Overview
The Adapters package facilitates communication between different language model APIs by providing a unified interface for interaction. This ensures ease of use and flexibility in integrating multiple models from various providers.
The package can be installed an used via pip:
pip install martian-adapters
Getting Started
Prerequisites
- Python version: 3.11.10
- Poetry
Installation
poetry install
poetry run pre-commit install
Setting Up Pre-commit
To run pre-commit manually:
poetry run pre-commit run --all-files
Semantic Versioning
For versioning we follow Semantic Versioning
Environment Configuration
The package requires certain environment variables to be set by the users:
- Copy
.env-exampleto.envand populate it with appropriate values.
Running Tests
poetry run pytest
Quickstart
from adapters import AdapterFactory
# First component in model path is Provider, then Vendor, and last model name itself
adapter = AdapterFactory.get_adapter_by_path("openai/openai/gpt-4o-mini")
adapter.execute_sync(
[
{"role": "system", "content": "You are a helpful assistant."},
{
"role": "user",
"content": "Write a haiku about recursion in programming.",
},
]
)
Adapter paths follows the format provider/vendor/model_name. Use AdapterFactory.get_supported_models() to retrieve all supported models. For a given model, model.get_path() returns the adapter path.
Contributing
Adding New Models
-
Existing Providers: Add new models to the
MODELSarray if the provider is already supported. -
New Providers:
- If the provider follows the OpenAI format, model integration is straightforward. See the "Fireworks" provider class as an example.
- For providers with different schemas, see the "Anthropic" provider class for guidance.
Development Steps
-
Add the Provider and Model: Update
provider_adapters/__init__.pyand test files accordingly. -
Write Tests: Add tests in the relevant directories. Use
@pytest.mark.vcrfor tests making network requests. -
Run Tests:
poetry run pytest
-
Check-in Cassette Files: Include any new cassette YAML files in your commit.
-
Send a Pull Request: Ensure all tests pass before requesting a review.
Re-creating Cassette Files
Use the poetry run pytest --record-mode=rewrite option with pytest to update cassette files.
Additional Notes
Some models may only be accessible from specific locations (e.g., the U.S.). In such cases, running tests might require access to a U.S.-based server.
This documentation provides a streamlined approach to using and contributing to the Adapters package, emphasizing practical steps and clear examples.
Misclenous
HTTP Client configuration
To optimize throughput and performance, we provide options to configure HTTP networking parameters:
ADAPTERS_MAX_KEEPALIVE_CONNECTIONS_PER_PROCESS = 100
ADAPTERS_MAX_CONNECTIONS_PER_PROCESS = 1000
ADAPTERS_HTTP_CONNECT_TIMEOUT = 5
ADAPTERS_HTTP_TIMEOUT = 600
Base URL overriding
For stress testing or other purposes, you can override all base URLs by setting the following in your .env file:
_ADAPTERS_OVERRIDE_ALL_BASE_URLS_ = "https://new-base-url.com/api"
This setting ensures that all LLM API calls will route to the specified new base URL.
Metadata
Release files for martian-adapters 7.25.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| martian_adapters-7.25.0.tar.gz | 39.8 kB | Without provenance | Details for martian_adapters-7.25.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| martian_adapters-7.25.0-py3-none-any.whl | Python 3 | none | any | Details for martian_adapters-7.25.0-py3-none-any.whl |
Total release size: 98.6 kB
Release files / martian_adapters-7.25.0.tar.gz
| Download URL | martian_adapters-7.25.0.tar.gz |
|---|---|
| Size | 39.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d97697548c69563d11ec8490ea0199461b748c6f509b25d3c422948c4e2f2ab7
|
|
BLAKE2b-256 checksum How to use checksums |
b2e8db393eaac9daf35d15e4c8538539dcf1241d30ec0607d4c31236b150c31c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.5 Darwin/24.5.0
|
Release files / martian_adapters-7.25.0-py3-none-any.whl
| Download URL | martian_adapters-7.25.0-py3-none-any.whl |
|---|---|
| Size | 58.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9b324c29b4ee4fe04580411a7db9922dd139efaca31be6da9a89cf009fc2b4d
|
|
BLAKE2b-256 checksum How to use checksums |
3a4cef3b9231ce1a9dc34b8b97c533108bb6bdfc24b9d962d753ece1e3a9ba56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.5 Darwin/24.5.0
|
Security for martian-adapters 7.25.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.