OneLLM 0.1.2__tar.gz → 0.1.3__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.
- {onellm-0.1.2 → onellm-0.1.3/OneLLM.egg-info}/PKG-INFO +7 -11
- {onellm-0.1.2 → onellm-0.1.3}/OneLLM.egg-info/SOURCES.txt +1 -0
- {onellm-0.1.2/OneLLM.egg-info → onellm-0.1.3}/PKG-INFO +7 -11
- {onellm-0.1.2 → onellm-0.1.3}/README.md +6 -10
- onellm-0.1.3/onellm/.version +1 -0
- {onellm-0.1.2 → onellm-0.1.3}/onellm/__init__.py +0 -2
- {onellm-0.1.2 → onellm-0.1.3}/onellm/audio.py +0 -2
- {onellm-0.1.2 → onellm-0.1.3}/onellm/chat_completion.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/cli/__init__.py +2 -5
- {onellm-0.1.2 → onellm-0.1.3}/onellm/cli/download_model.py +12 -16
- {onellm-0.1.2 → onellm-0.1.3}/onellm/client.py +0 -12
- {onellm-0.1.2 → onellm-0.1.3}/onellm/completion.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/config.py +15 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/embedding.py +0 -2
- {onellm-0.1.2 → onellm-0.1.3}/onellm/errors.py +0 -13
- {onellm-0.1.2 → onellm-0.1.3}/onellm/files.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/image.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/models.py +0 -11
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/__init__.py +2 -0
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/anthropic.py +57 -12
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/anyscale.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/azure.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/base.py +0 -7
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/bedrock.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/cohere.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/deepseek.py +7 -10
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/fallback.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/fireworks.py +7 -10
- onellm-0.1.3/onellm/providers/glm.py +48 -0
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/google.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/groq.py +12 -15
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/llama_cpp.py +0 -4
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/mistral.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/moonshot.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/ollama.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/openai.py +44 -6
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/openai_compatible.py +0 -2
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/openrouter.py +10 -13
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/perplexity.py +8 -11
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/together.py +7 -10
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/vertexai.py +0 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/providers/xai.py +7 -10
- {onellm-0.1.2 → onellm-0.1.3}/onellm/speech.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/types/common.py +10 -3
- {onellm-0.1.2 → onellm-0.1.3}/onellm/utils/fallback.py +0 -2
- {onellm-0.1.2 → onellm-0.1.3}/onellm/utils/retry.py +0 -4
- {onellm-0.1.2 → onellm-0.1.3}/onellm/utils/streaming.py +0 -5
- {onellm-0.1.2 → onellm-0.1.3}/onellm/utils/text_cleaner.py +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/onellm/utils/token_counter.py +0 -5
- {onellm-0.1.2 → onellm-0.1.3}/onellm/validators.py +0 -28
- {onellm-0.1.2 → onellm-0.1.3}/tests/test_utils.py +5 -0
- onellm-0.1.2/onellm/.version +0 -1
- {onellm-0.1.2 → onellm-0.1.3}/LICENSE +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/MANIFEST.in +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/OneLLM.egg-info/dependency_links.txt +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/OneLLM.egg-info/top_level.txt +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/onellm/types/__init__.py +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/onellm/utils/__init__.py +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/pyproject.toml +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/setup.cfg +0 -0
- {onellm-0.1.2 → onellm-0.1.3}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onellm
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: A unified interface for interacting with large language models from various providers - a complete drop-in replacement for OpenAI's client
|
|
5
5
|
Home-page: https://github.com/muxi-ai/onellm
|
|
6
6
|
Author: Ran Aroussi
|
|
@@ -97,17 +97,16 @@ Dynamic: requires-python
|
|
|
97
97
|
- [License](https://github.com/muxi-ai/onellm/blob/main/README.md#-license)
|
|
98
98
|
- [Acknowledgements](https://github.com/muxi-ai/onellm/blob/main/README.md#-acknowledgements)
|
|
99
99
|
|
|
100
|
-
|
|
101
100
|
## 👉 Overview
|
|
102
101
|
|
|
103
102
|
**OneLLM** is a lightweight, provider-agnostic Python library that offers a unified interface for interacting with large language models (LLMs) from various providers. It simplifies the integration of LLMs into applications by providing a consistent API while abstracting away provider-specific implementation details.
|
|
104
103
|
|
|
105
104
|
The library follows the OpenAI client API design pattern, making it familiar to developers already using OpenAI and enabling easy migration for existing applications. **Simply change your import statements and instantly gain access to hundreds of models** across dozens of providers while maintaining your existing code structure.
|
|
106
105
|
|
|
107
|
-
With support for
|
|
106
|
+
With support for 20 implemented providers (and more planned), OneLLM gives you access to approximately 300+ unique language models through a single, consistent interface - from the latest proprietary models to open-source alternatives, all accessible through familiar OpenAI-compatible patterns.
|
|
108
107
|
|
|
109
108
|
> [!NOTE]
|
|
110
|
-
> **Ready for Use**: OneLLM now supports
|
|
109
|
+
> **Ready for Use**: OneLLM now supports 20 providers with 300+ models! From cloud APIs to local models, you can access them all through a single, unified interface. [Contributions are welcome](./CONTRIBUTING.md) to help add even more providers!
|
|
111
110
|
|
|
112
111
|
---
|
|
113
112
|
|
|
@@ -159,11 +158,10 @@ For more detailed examples, check out the [examples directory](./examples).
|
|
|
159
158
|
|
|
160
159
|
## ✨ Key Features
|
|
161
160
|
|
|
162
|
-
|
|
163
161
|
| Feature | Description |
|
|
164
162
|
|---------|-------------|
|
|
165
163
|
| **📦 Drop-in replacement** | Use your existing OpenAI code with minimal changes |
|
|
166
|
-
| **🔄 Provider-agnostic** | Support for 300+ models across
|
|
164
|
+
| **🔄 Provider-agnostic** | Support for 300+ models across 20 implemented providers |
|
|
167
165
|
| **🔁 Automatic fallback** | Seamlessly switch to alternative models when needed |
|
|
168
166
|
| **🔄 Auto-retry mechanism** | Retry the same model multiple times before failing |
|
|
169
167
|
| **🧩 OpenAI-compatible** | Familiar interface for developers used to OpenAI |
|
|
@@ -180,9 +178,9 @@ For more detailed examples, check out the [examples directory](./examples).
|
|
|
180
178
|
|
|
181
179
|
## 🌐 Supported Providers
|
|
182
180
|
|
|
183
|
-
OneLLM currently supports **
|
|
181
|
+
OneLLM currently supports **20 providers** with more on the way:
|
|
184
182
|
|
|
185
|
-
### Cloud API Providers (
|
|
183
|
+
### Cloud API Providers (18)
|
|
186
184
|
- **Anthropic** - Claude family of models
|
|
187
185
|
- **Anyscale** - Configurable AI platform
|
|
188
186
|
- **AWS Bedrock** - Access to multiple model families
|
|
@@ -193,6 +191,7 @@ OneLLM currently supports **19 providers** with more on the way:
|
|
|
193
191
|
- **Moonshot** - Kimi models with long-context capabilities
|
|
194
192
|
- **Google AI Studio** - Gemini models via API key
|
|
195
193
|
- **Groq** - Ultra-fast inference for Llama, Mixtral
|
|
194
|
+
- **GLM (Z.AI)** - OpenAI-compatible GLM-4 family
|
|
196
195
|
- **Mistral** - Mistral Large, Medium, Small
|
|
197
196
|
- **OpenAI** - GPT-4o, 3o-mini, DALL-E, Whisper, etc.
|
|
198
197
|
- **OpenRouter** - Gateway to 100+ models
|
|
@@ -561,8 +560,6 @@ flowchart TD
|
|
|
561
560
|
ERROR --> RESPONSE
|
|
562
561
|
```
|
|
563
562
|
|
|
564
|
-
|
|
565
|
-
|
|
566
563
|
### JSON Mode for Structured Outputs
|
|
567
564
|
|
|
568
565
|
For applications that require structured data, OneLLM supports JSON mode with compatible providers:
|
|
@@ -821,7 +818,6 @@ OneLLM maintains comprehensive test coverage to ensure reliability and compatibi
|
|
|
821
818
|
</tr>
|
|
822
819
|
</table>
|
|
823
820
|
|
|
824
|
-
|
|
825
821
|
This extensive test coverage ensures reliable operation across all supported providers and models.
|
|
826
822
|
|
|
827
823
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onellm
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: A unified interface for interacting with large language models from various providers - a complete drop-in replacement for OpenAI's client
|
|
5
5
|
Home-page: https://github.com/muxi-ai/onellm
|
|
6
6
|
Author: Ran Aroussi
|
|
@@ -97,17 +97,16 @@ Dynamic: requires-python
|
|
|
97
97
|
- [License](https://github.com/muxi-ai/onellm/blob/main/README.md#-license)
|
|
98
98
|
- [Acknowledgements](https://github.com/muxi-ai/onellm/blob/main/README.md#-acknowledgements)
|
|
99
99
|
|
|
100
|
-
|
|
101
100
|
## 👉 Overview
|
|
102
101
|
|
|
103
102
|
**OneLLM** is a lightweight, provider-agnostic Python library that offers a unified interface for interacting with large language models (LLMs) from various providers. It simplifies the integration of LLMs into applications by providing a consistent API while abstracting away provider-specific implementation details.
|
|
104
103
|
|
|
105
104
|
The library follows the OpenAI client API design pattern, making it familiar to developers already using OpenAI and enabling easy migration for existing applications. **Simply change your import statements and instantly gain access to hundreds of models** across dozens of providers while maintaining your existing code structure.
|
|
106
105
|
|
|
107
|
-
With support for
|
|
106
|
+
With support for 20 implemented providers (and more planned), OneLLM gives you access to approximately 300+ unique language models through a single, consistent interface - from the latest proprietary models to open-source alternatives, all accessible through familiar OpenAI-compatible patterns.
|
|
108
107
|
|
|
109
108
|
> [!NOTE]
|
|
110
|
-
> **Ready for Use**: OneLLM now supports
|
|
109
|
+
> **Ready for Use**: OneLLM now supports 20 providers with 300+ models! From cloud APIs to local models, you can access them all through a single, unified interface. [Contributions are welcome](./CONTRIBUTING.md) to help add even more providers!
|
|
111
110
|
|
|
112
111
|
---
|
|
113
112
|
|
|
@@ -159,11 +158,10 @@ For more detailed examples, check out the [examples directory](./examples).
|
|
|
159
158
|
|
|
160
159
|
## ✨ Key Features
|
|
161
160
|
|
|
162
|
-
|
|
163
161
|
| Feature | Description |
|
|
164
162
|
|---------|-------------|
|
|
165
163
|
| **📦 Drop-in replacement** | Use your existing OpenAI code with minimal changes |
|
|
166
|
-
| **🔄 Provider-agnostic** | Support for 300+ models across
|
|
164
|
+
| **🔄 Provider-agnostic** | Support for 300+ models across 20 implemented providers |
|
|
167
165
|
| **🔁 Automatic fallback** | Seamlessly switch to alternative models when needed |
|
|
168
166
|
| **🔄 Auto-retry mechanism** | Retry the same model multiple times before failing |
|
|
169
167
|
| **🧩 OpenAI-compatible** | Familiar interface for developers used to OpenAI |
|
|
@@ -180,9 +178,9 @@ For more detailed examples, check out the [examples directory](./examples).
|
|
|
180
178
|
|
|
181
179
|
## 🌐 Supported Providers
|
|
182
180
|
|
|
183
|
-
OneLLM currently supports **
|
|
181
|
+
OneLLM currently supports **20 providers** with more on the way:
|
|
184
182
|
|
|
185
|
-
### Cloud API Providers (
|
|
183
|
+
### Cloud API Providers (18)
|
|
186
184
|
- **Anthropic** - Claude family of models
|
|
187
185
|
- **Anyscale** - Configurable AI platform
|
|
188
186
|
- **AWS Bedrock** - Access to multiple model families
|
|
@@ -193,6 +191,7 @@ OneLLM currently supports **19 providers** with more on the way:
|
|
|
193
191
|
- **Moonshot** - Kimi models with long-context capabilities
|
|
194
192
|
- **Google AI Studio** - Gemini models via API key
|
|
195
193
|
- **Groq** - Ultra-fast inference for Llama, Mixtral
|
|
194
|
+
- **GLM (Z.AI)** - OpenAI-compatible GLM-4 family
|
|
196
195
|
- **Mistral** - Mistral Large, Medium, Small
|
|
197
196
|
- **OpenAI** - GPT-4o, 3o-mini, DALL-E, Whisper, etc.
|
|
198
197
|
- **OpenRouter** - Gateway to 100+ models
|
|
@@ -561,8 +560,6 @@ flowchart TD
|
|
|
561
560
|
ERROR --> RESPONSE
|
|
562
561
|
```
|
|
563
562
|
|
|
564
|
-
|
|
565
|
-
|
|
566
563
|
### JSON Mode for Structured Outputs
|
|
567
564
|
|
|
568
565
|
For applications that require structured data, OneLLM supports JSON mode with compatible providers:
|
|
@@ -821,7 +818,6 @@ OneLLM maintains comprehensive test coverage to ensure reliability and compatibi
|
|
|
821
818
|
</tr>
|
|
822
819
|
</table>
|
|
823
820
|
|
|
824
|
-
|
|
825
821
|
This extensive test coverage ensures reliable operation across all supported providers and models.
|
|
826
822
|
|
|
827
823
|
---
|
|
@@ -41,17 +41,16 @@
|
|
|
41
41
|
- [License](https://github.com/muxi-ai/onellm/blob/main/README.md#-license)
|
|
42
42
|
- [Acknowledgements](https://github.com/muxi-ai/onellm/blob/main/README.md#-acknowledgements)
|
|
43
43
|
|
|
44
|
-
|
|
45
44
|
## 👉 Overview
|
|
46
45
|
|
|
47
46
|
**OneLLM** is a lightweight, provider-agnostic Python library that offers a unified interface for interacting with large language models (LLMs) from various providers. It simplifies the integration of LLMs into applications by providing a consistent API while abstracting away provider-specific implementation details.
|
|
48
47
|
|
|
49
48
|
The library follows the OpenAI client API design pattern, making it familiar to developers already using OpenAI and enabling easy migration for existing applications. **Simply change your import statements and instantly gain access to hundreds of models** across dozens of providers while maintaining your existing code structure.
|
|
50
49
|
|
|
51
|
-
With support for
|
|
50
|
+
With support for 20 implemented providers (and more planned), OneLLM gives you access to approximately 300+ unique language models through a single, consistent interface - from the latest proprietary models to open-source alternatives, all accessible through familiar OpenAI-compatible patterns.
|
|
52
51
|
|
|
53
52
|
> [!NOTE]
|
|
54
|
-
> **Ready for Use**: OneLLM now supports
|
|
53
|
+
> **Ready for Use**: OneLLM now supports 20 providers with 300+ models! From cloud APIs to local models, you can access them all through a single, unified interface. [Contributions are welcome](./CONTRIBUTING.md) to help add even more providers!
|
|
55
54
|
|
|
56
55
|
---
|
|
57
56
|
|
|
@@ -103,11 +102,10 @@ For more detailed examples, check out the [examples directory](./examples).
|
|
|
103
102
|
|
|
104
103
|
## ✨ Key Features
|
|
105
104
|
|
|
106
|
-
|
|
107
105
|
| Feature | Description |
|
|
108
106
|
|---------|-------------|
|
|
109
107
|
| **📦 Drop-in replacement** | Use your existing OpenAI code with minimal changes |
|
|
110
|
-
| **🔄 Provider-agnostic** | Support for 300+ models across
|
|
108
|
+
| **🔄 Provider-agnostic** | Support for 300+ models across 20 implemented providers |
|
|
111
109
|
| **🔁 Automatic fallback** | Seamlessly switch to alternative models when needed |
|
|
112
110
|
| **🔄 Auto-retry mechanism** | Retry the same model multiple times before failing |
|
|
113
111
|
| **🧩 OpenAI-compatible** | Familiar interface for developers used to OpenAI |
|
|
@@ -124,9 +122,9 @@ For more detailed examples, check out the [examples directory](./examples).
|
|
|
124
122
|
|
|
125
123
|
## 🌐 Supported Providers
|
|
126
124
|
|
|
127
|
-
OneLLM currently supports **
|
|
125
|
+
OneLLM currently supports **20 providers** with more on the way:
|
|
128
126
|
|
|
129
|
-
### Cloud API Providers (
|
|
127
|
+
### Cloud API Providers (18)
|
|
130
128
|
- **Anthropic** - Claude family of models
|
|
131
129
|
- **Anyscale** - Configurable AI platform
|
|
132
130
|
- **AWS Bedrock** - Access to multiple model families
|
|
@@ -137,6 +135,7 @@ OneLLM currently supports **19 providers** with more on the way:
|
|
|
137
135
|
- **Moonshot** - Kimi models with long-context capabilities
|
|
138
136
|
- **Google AI Studio** - Gemini models via API key
|
|
139
137
|
- **Groq** - Ultra-fast inference for Llama, Mixtral
|
|
138
|
+
- **GLM (Z.AI)** - OpenAI-compatible GLM-4 family
|
|
140
139
|
- **Mistral** - Mistral Large, Medium, Small
|
|
141
140
|
- **OpenAI** - GPT-4o, 3o-mini, DALL-E, Whisper, etc.
|
|
142
141
|
- **OpenRouter** - Gateway to 100+ models
|
|
@@ -505,8 +504,6 @@ flowchart TD
|
|
|
505
504
|
ERROR --> RESPONSE
|
|
506
505
|
```
|
|
507
506
|
|
|
508
|
-
|
|
509
|
-
|
|
510
507
|
### JSON Mode for Structured Outputs
|
|
511
508
|
|
|
512
509
|
For applications that require structured data, OneLLM supports JSON mode with compatible providers:
|
|
@@ -765,7 +762,6 @@ OneLLM maintains comprehensive test coverage to ensure reliability and compatibi
|
|
|
765
762
|
</tr>
|
|
766
763
|
</table>
|
|
767
764
|
|
|
768
|
-
|
|
769
765
|
This extensive test coverage ensures reliable operation across all supported providers and models.
|
|
770
766
|
|
|
771
767
|
---
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.3
|
|
@@ -57,7 +57,6 @@ from .errors import (
|
|
|
57
57
|
InvalidRequestError,
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
-
|
|
61
60
|
def get_version() -> str:
|
|
62
61
|
"""
|
|
63
62
|
Read and return the package version from the .version file.
|
|
@@ -73,7 +72,6 @@ def get_version() -> str:
|
|
|
73
72
|
with open(version_file, "r", encoding="utf-8") as f:
|
|
74
73
|
return f.read().strip()
|
|
75
74
|
|
|
76
|
-
|
|
77
75
|
# Initialize package version from .version file
|
|
78
76
|
__version__ = get_version()
|
|
79
77
|
|
|
@@ -32,7 +32,6 @@ from typing import Any, Dict, IO, List, Optional, Union
|
|
|
32
32
|
from .providers.base import get_provider_with_fallbacks
|
|
33
33
|
from .utils.fallback import FallbackConfig
|
|
34
34
|
|
|
35
|
-
|
|
36
35
|
class AudioTranscription:
|
|
37
36
|
"""
|
|
38
37
|
API class for audio transcription.
|
|
@@ -125,7 +124,6 @@ class AudioTranscription:
|
|
|
125
124
|
)
|
|
126
125
|
)
|
|
127
126
|
|
|
128
|
-
|
|
129
127
|
class AudioTranslation:
|
|
130
128
|
"""
|
|
131
129
|
API class for audio translation to English.
|
|
@@ -35,7 +35,6 @@ from .models import ChatCompletionResponse, ChatCompletionChunk
|
|
|
35
35
|
from .utils.fallback import FallbackConfig
|
|
36
36
|
from .validators import validate_model_name, validate_messages, validate_stream
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
class ChatCompletion:
|
|
40
39
|
"""Class for creating chat completions with various providers."""
|
|
41
40
|
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
# See the License for the specific language governing permissions and
|
|
18
18
|
# limitations under the License.
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
"""OneLLM CLI utilities."""
|
|
22
21
|
|
|
23
|
-
|
|
24
22
|
def main():
|
|
25
23
|
"""Main CLI entry point."""
|
|
26
24
|
import sys
|
|
27
|
-
|
|
25
|
+
|
|
28
26
|
if len(sys.argv) > 1 and sys.argv[1] == "download":
|
|
29
27
|
# Remove 'download' from args and call download script
|
|
30
28
|
sys.argv.pop(1)
|
|
@@ -36,6 +34,5 @@ def main():
|
|
|
36
34
|
print(" onellm download - Download GGUF models from HuggingFace")
|
|
37
35
|
print("\nUse 'onellm <command> --help' for more information")
|
|
38
36
|
|
|
39
|
-
|
|
40
37
|
if __name__ == "__main__":
|
|
41
|
-
main()
|
|
38
|
+
main()
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
# See the License for the specific language governing permissions and
|
|
18
18
|
# limitations under the License.
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
"""
|
|
22
21
|
CLI utility for downloading GGUF models from HuggingFace.
|
|
23
22
|
"""
|
|
@@ -27,16 +26,15 @@ import sys
|
|
|
27
26
|
from pathlib import Path
|
|
28
27
|
import os
|
|
29
28
|
|
|
30
|
-
|
|
31
29
|
def download_gguf(repo_id: str, filename: str, output_dir: str = None):
|
|
32
30
|
"""
|
|
33
31
|
Download a GGUF model from HuggingFace.
|
|
34
|
-
|
|
32
|
+
|
|
35
33
|
Args:
|
|
36
34
|
repo_id: HuggingFace repository ID
|
|
37
35
|
filename: Model filename to download
|
|
38
36
|
output_dir: Directory to save the model (default: ~/llama_models)
|
|
39
|
-
|
|
37
|
+
|
|
40
38
|
Returns:
|
|
41
39
|
Path to the downloaded file
|
|
42
40
|
"""
|
|
@@ -47,17 +45,17 @@ def download_gguf(repo_id: str, filename: str, output_dir: str = None):
|
|
|
47
45
|
print("This should have been installed with onellm. Try:")
|
|
48
46
|
print(" pip install --upgrade onellm")
|
|
49
47
|
sys.exit(1)
|
|
50
|
-
|
|
48
|
+
|
|
51
49
|
# Default to ~/llama_models if no output dir specified
|
|
52
50
|
if output_dir is None:
|
|
53
51
|
output_dir = os.path.expanduser("~/llama_models")
|
|
54
|
-
|
|
52
|
+
|
|
55
53
|
# Create output directory
|
|
56
54
|
Path(output_dir).mkdir(parents=True, exist_ok=True)
|
|
57
|
-
|
|
55
|
+
|
|
58
56
|
print(f"Downloading {filename} from {repo_id}...")
|
|
59
57
|
print(f"Destination: {output_dir}")
|
|
60
|
-
|
|
58
|
+
|
|
61
59
|
try:
|
|
62
60
|
# Download with progress bar
|
|
63
61
|
file_path = hf_hub_download(
|
|
@@ -68,12 +66,12 @@ def download_gguf(repo_id: str, filename: str, output_dir: str = None):
|
|
|
68
66
|
)
|
|
69
67
|
print(f"\n✓ Downloaded successfully!")
|
|
70
68
|
print(f" File: {file_path}")
|
|
71
|
-
|
|
69
|
+
|
|
72
70
|
# Show how to use it
|
|
73
71
|
model_name = Path(file_path).name
|
|
74
72
|
print(f"\nTo use this model with OneLLM:")
|
|
75
73
|
print(f' model="llama_cpp/{model_name}"')
|
|
76
|
-
|
|
74
|
+
|
|
77
75
|
return file_path
|
|
78
76
|
except Exception as e:
|
|
79
77
|
print(f"\n✗ Error downloading model: {e}")
|
|
@@ -84,7 +82,6 @@ def download_gguf(repo_id: str, filename: str, output_dir: str = None):
|
|
|
84
82
|
print(f" - Visit https://huggingface.co/{repo_id} to see available files")
|
|
85
83
|
sys.exit(1)
|
|
86
84
|
|
|
87
|
-
|
|
88
85
|
def main():
|
|
89
86
|
"""Main entry point for the download command."""
|
|
90
87
|
parser = argparse.ArgumentParser(
|
|
@@ -107,7 +104,7 @@ Popular repositories:
|
|
|
107
104
|
- mistralai/Mistral-7B-Instruct-v0.2-GGUF
|
|
108
105
|
"""
|
|
109
106
|
)
|
|
110
|
-
|
|
107
|
+
|
|
111
108
|
parser.add_argument(
|
|
112
109
|
"--repo-id", "-r",
|
|
113
110
|
required=True,
|
|
@@ -122,12 +119,11 @@ Popular repositories:
|
|
|
122
119
|
"--output", "-o",
|
|
123
120
|
help="Output directory (default: ~/llama_models)"
|
|
124
121
|
)
|
|
125
|
-
|
|
122
|
+
|
|
126
123
|
args = parser.parse_args()
|
|
127
|
-
|
|
124
|
+
|
|
128
125
|
# Download the model
|
|
129
126
|
download_gguf(args.repo_id, args.filename, args.output)
|
|
130
127
|
|
|
131
|
-
|
|
132
128
|
if __name__ == "__main__":
|
|
133
|
-
main()
|
|
129
|
+
main()
|
|
@@ -35,7 +35,6 @@ from .image import Image
|
|
|
35
35
|
from .audio import AudioTranscription, AudioTranslation
|
|
36
36
|
from .speech import Speech
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
class ChatCompletionsResource:
|
|
40
39
|
"""Chat completions API resource"""
|
|
41
40
|
|
|
@@ -119,7 +118,6 @@ class ChatCompletionsResource:
|
|
|
119
118
|
**kwargs
|
|
120
119
|
)
|
|
121
120
|
|
|
122
|
-
|
|
123
121
|
class ChatResource:
|
|
124
122
|
"""Chat API resource"""
|
|
125
123
|
|
|
@@ -129,7 +127,6 @@ class ChatResource:
|
|
|
129
127
|
"""
|
|
130
128
|
self.completions = ChatCompletionsResource()
|
|
131
129
|
|
|
132
|
-
|
|
133
130
|
class CompletionsResource:
|
|
134
131
|
"""Completions API resource"""
|
|
135
132
|
|
|
@@ -211,7 +208,6 @@ class CompletionsResource:
|
|
|
211
208
|
**kwargs
|
|
212
209
|
)
|
|
213
210
|
|
|
214
|
-
|
|
215
211
|
class EmbeddingsResource:
|
|
216
212
|
"""Embeddings API resource"""
|
|
217
213
|
|
|
@@ -287,7 +283,6 @@ class EmbeddingsResource:
|
|
|
287
283
|
**kwargs
|
|
288
284
|
)
|
|
289
285
|
|
|
290
|
-
|
|
291
286
|
class ImagesResource:
|
|
292
287
|
"""Images API resource"""
|
|
293
288
|
|
|
@@ -336,7 +331,6 @@ class ImagesResource:
|
|
|
336
331
|
# Use the same create method - it will return a coroutine when called from here
|
|
337
332
|
return await Image.create(model=model, prompt=prompt, **kwargs)
|
|
338
333
|
|
|
339
|
-
|
|
340
334
|
class AudioResource:
|
|
341
335
|
"""Audio API resource"""
|
|
342
336
|
|
|
@@ -347,7 +341,6 @@ class AudioResource:
|
|
|
347
341
|
self.transcriptions = AudioTranscriptionsResource()
|
|
348
342
|
self.translations = AudioTranslationsResource()
|
|
349
343
|
|
|
350
|
-
|
|
351
344
|
class AudioTranscriptionsResource:
|
|
352
345
|
"""Audio transcriptions API resource"""
|
|
353
346
|
|
|
@@ -396,7 +389,6 @@ class AudioTranscriptionsResource:
|
|
|
396
389
|
# Use the same create method - it will return a coroutine when called from here
|
|
397
390
|
return await AudioTranscription.create(model=model, file=file, **kwargs)
|
|
398
391
|
|
|
399
|
-
|
|
400
392
|
class AudioTranslationsResource:
|
|
401
393
|
"""Audio translations API resource"""
|
|
402
394
|
|
|
@@ -445,7 +437,6 @@ class AudioTranslationsResource:
|
|
|
445
437
|
# Use the same create method - it will return a coroutine when called from here
|
|
446
438
|
return await AudioTranslation.create(model=model, file=file, **kwargs)
|
|
447
439
|
|
|
448
|
-
|
|
449
440
|
class SpeechResource:
|
|
450
441
|
"""Speech API resource"""
|
|
451
442
|
|
|
@@ -498,7 +489,6 @@ class SpeechResource:
|
|
|
498
489
|
# Use the same create method - it will return a coroutine when called from here
|
|
499
490
|
return await Speech.create(model=model, input=input, voice=voice, **kwargs)
|
|
500
491
|
|
|
501
|
-
|
|
502
492
|
class FilesResource:
|
|
503
493
|
"""Files API resource"""
|
|
504
494
|
|
|
@@ -642,7 +632,6 @@ class FilesResource:
|
|
|
642
632
|
"""
|
|
643
633
|
return await File.adownload(file_id=file_id, provider="openai", **kwargs)
|
|
644
634
|
|
|
645
|
-
|
|
646
635
|
class Client:
|
|
647
636
|
"""
|
|
648
637
|
Base client class for OneLLM that mimics OpenAI's client interface.
|
|
@@ -670,7 +659,6 @@ class Client:
|
|
|
670
659
|
self.api_key = api_key
|
|
671
660
|
self.config = kwargs
|
|
672
661
|
|
|
673
|
-
|
|
674
662
|
# Alias for OpenAI = Client for backward compatibility
|
|
675
663
|
# This allows users to use either onellm.OpenAI or onellm.Client
|
|
676
664
|
OpenAI = Client
|
|
@@ -57,6 +57,12 @@ DEFAULT_CONFIG = {
|
|
|
57
57
|
"timeout": 30,
|
|
58
58
|
"max_retries": 3,
|
|
59
59
|
},
|
|
60
|
+
"glm": {
|
|
61
|
+
"api_key": None,
|
|
62
|
+
"api_base": "https://api.z.ai/api/paas/v4",
|
|
63
|
+
"timeout": 60,
|
|
64
|
+
"max_retries": 3,
|
|
65
|
+
},
|
|
60
66
|
"xai": {
|
|
61
67
|
"api_key": None,
|
|
62
68
|
"api_base": "https://api.x.ai/v1",
|
|
@@ -169,6 +175,7 @@ PROVIDER_API_KEY_ENV_MAP = {
|
|
|
169
175
|
"anthropic": "ANTHROPIC_API_KEY",
|
|
170
176
|
"mistral": "MISTRAL_API_KEY",
|
|
171
177
|
"groq": "GROQ_API_KEY",
|
|
178
|
+
"glm": ("GLM_API_KEY", "ZAI_API_KEY"),
|
|
172
179
|
"xai": "XAI_API_KEY",
|
|
173
180
|
"openrouter": "OPENROUTER_API_KEY",
|
|
174
181
|
"together": "TOGETHER_API_KEY",
|
|
@@ -210,9 +217,14 @@ def _load_env_vars() -> None:
|
|
|
210
217
|
|
|
211
218
|
# Provider API keys (support both prefixed and provider-standard environment variables)
|
|
212
219
|
# This allows users to use either OPENAI_API_KEY or ONELLM_PROVIDERS__OPENAI__API_KEY
|
|
213
|
-
for provider,
|
|
214
|
-
if
|
|
215
|
-
|
|
220
|
+
for provider, env_vars in PROVIDER_API_KEY_ENV_MAP.items():
|
|
221
|
+
if isinstance(env_vars, str):
|
|
222
|
+
env_vars = (env_vars,)
|
|
223
|
+
|
|
224
|
+
for env_var in env_vars:
|
|
225
|
+
if env_var in os.environ and provider in config["providers"]:
|
|
226
|
+
config["providers"][provider]["api_key"] = os.environ[env_var]
|
|
227
|
+
break
|
|
216
228
|
|
|
217
229
|
# Special handling for Vertex AI service account JSON file
|
|
218
230
|
if "GOOGLE_APPLICATION_CREDENTIALS" in os.environ and "vertexai" in config["providers"]:
|
|
@@ -33,7 +33,6 @@ from .models import EmbeddingResponse
|
|
|
33
33
|
from .utils.fallback import FallbackConfig
|
|
34
34
|
from .errors import InvalidRequestError
|
|
35
35
|
|
|
36
|
-
|
|
37
36
|
def validate_embedding_input(input_data: Union[str, List[str]]) -> None:
|
|
38
37
|
"""
|
|
39
38
|
Validate the input for embedding.
|
|
@@ -57,7 +56,6 @@ def validate_embedding_input(input_data: Union[str, List[str]]) -> None:
|
|
|
57
56
|
if not input_data or all(not text for text in input_data):
|
|
58
57
|
raise InvalidRequestError("Input cannot be empty")
|
|
59
58
|
|
|
60
|
-
|
|
61
59
|
class Embedding:
|
|
62
60
|
"""Class for creating embeddings with various providers."""
|
|
63
61
|
|
|
@@ -27,7 +27,6 @@ to help with error handling in client code.
|
|
|
27
27
|
|
|
28
28
|
from typing import Any, Dict, List, Optional
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
class MuxiLLMError(Exception):
|
|
32
31
|
"""
|
|
33
32
|
Base exception class for OneLLM errors.
|
|
@@ -77,7 +76,6 @@ class MuxiLLMError(Exception):
|
|
|
77
76
|
# Combine all components into a single error message
|
|
78
77
|
return f"{self.message}{provider_msg}{status_msg}{request_msg}"
|
|
79
78
|
|
|
80
|
-
|
|
81
79
|
class APIError(MuxiLLMError):
|
|
82
80
|
"""
|
|
83
81
|
Raised when the provider's API returns an unexpected error.
|
|
@@ -88,7 +86,6 @@ class APIError(MuxiLLMError):
|
|
|
88
86
|
|
|
89
87
|
pass
|
|
90
88
|
|
|
91
|
-
|
|
92
89
|
class AuthenticationError(MuxiLLMError):
|
|
93
90
|
"""
|
|
94
91
|
Raised when there are authentication issues (invalid API key, etc.).
|
|
@@ -98,7 +95,6 @@ class AuthenticationError(MuxiLLMError):
|
|
|
98
95
|
|
|
99
96
|
pass
|
|
100
97
|
|
|
101
|
-
|
|
102
98
|
class RateLimitError(MuxiLLMError):
|
|
103
99
|
"""
|
|
104
100
|
Raised when the provider's rate limit is exceeded.
|
|
@@ -109,7 +105,6 @@ class RateLimitError(MuxiLLMError):
|
|
|
109
105
|
|
|
110
106
|
pass
|
|
111
107
|
|
|
112
|
-
|
|
113
108
|
class InvalidRequestError(MuxiLLMError):
|
|
114
109
|
"""
|
|
115
110
|
Raised when the request parameters are invalid.
|
|
@@ -120,7 +115,6 @@ class InvalidRequestError(MuxiLLMError):
|
|
|
120
115
|
|
|
121
116
|
pass
|
|
122
117
|
|
|
123
|
-
|
|
124
118
|
class ServiceUnavailableError(MuxiLLMError):
|
|
125
119
|
"""
|
|
126
120
|
Raised when the provider's service is unavailable.
|
|
@@ -130,7 +124,6 @@ class ServiceUnavailableError(MuxiLLMError):
|
|
|
130
124
|
|
|
131
125
|
pass
|
|
132
126
|
|
|
133
|
-
|
|
134
127
|
class TimeoutError(MuxiLLMError):
|
|
135
128
|
"""
|
|
136
129
|
Raised when a request times out.
|
|
@@ -141,7 +134,6 @@ class TimeoutError(MuxiLLMError):
|
|
|
141
134
|
|
|
142
135
|
pass
|
|
143
136
|
|
|
144
|
-
|
|
145
137
|
class BadGatewayError(MuxiLLMError):
|
|
146
138
|
"""
|
|
147
139
|
Raised when a bad gateway error occurs.
|
|
@@ -152,7 +144,6 @@ class BadGatewayError(MuxiLLMError):
|
|
|
152
144
|
|
|
153
145
|
pass
|
|
154
146
|
|
|
155
|
-
|
|
156
147
|
class PermissionError(MuxiLLMError):
|
|
157
148
|
"""
|
|
158
149
|
Raised when permission is denied for the requested operation.
|
|
@@ -163,7 +154,6 @@ class PermissionError(MuxiLLMError):
|
|
|
163
154
|
|
|
164
155
|
pass
|
|
165
156
|
|
|
166
|
-
|
|
167
157
|
class ResourceNotFoundError(MuxiLLMError):
|
|
168
158
|
"""
|
|
169
159
|
Raised when a requested resource is not found.
|
|
@@ -174,7 +164,6 @@ class ResourceNotFoundError(MuxiLLMError):
|
|
|
174
164
|
|
|
175
165
|
pass
|
|
176
166
|
|
|
177
|
-
|
|
178
167
|
class InvalidModelError(InvalidRequestError):
|
|
179
168
|
"""
|
|
180
169
|
Raised when an invalid or unsupported model is requested.
|
|
@@ -185,7 +174,6 @@ class InvalidModelError(InvalidRequestError):
|
|
|
185
174
|
|
|
186
175
|
pass
|
|
187
176
|
|
|
188
|
-
|
|
189
177
|
class InvalidConfigurationError(MuxiLLMError):
|
|
190
178
|
"""
|
|
191
179
|
Raised when the library is configured incorrectly.
|
|
@@ -196,7 +184,6 @@ class InvalidConfigurationError(MuxiLLMError):
|
|
|
196
184
|
|
|
197
185
|
pass
|
|
198
186
|
|
|
199
|
-
|
|
200
187
|
class FallbackExhaustionError(MuxiLLMError):
|
|
201
188
|
"""
|
|
202
189
|
Error raised when all fallback models have been tried and failed.
|