indoxrouter 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- indoxrouter-0.1.4.dist-info/METADATA +195 -0
- indoxrouter-0.1.4.dist-info/RECORD +4 -0
- indoxrouter-0.1.4.dist-info/top_level.txt +1 -0
- indoxRouter/__init__.py +0 -83
- indoxRouter/client.py +0 -632
- indoxRouter/client_resourses/__init__.py +0 -20
- indoxRouter/client_resourses/base.py +0 -67
- indoxRouter/client_resourses/chat.py +0 -144
- indoxRouter/client_resourses/completion.py +0 -138
- indoxRouter/client_resourses/embedding.py +0 -83
- indoxRouter/client_resourses/image.py +0 -116
- indoxRouter/client_resourses/models.py +0 -114
- indoxRouter/config.py +0 -151
- indoxRouter/constants/__init__.py +0 -81
- indoxRouter/exceptions/__init__.py +0 -70
- indoxRouter/models/__init__.py +0 -111
- indoxRouter/providers/__init__.py +0 -108
- indoxRouter/providers/ai21labs.json +0 -128
- indoxRouter/providers/base_provider.py +0 -101
- indoxRouter/providers/claude.json +0 -164
- indoxRouter/providers/cohere.json +0 -116
- indoxRouter/providers/databricks.json +0 -110
- indoxRouter/providers/deepseek.json +0 -110
- indoxRouter/providers/google.json +0 -128
- indoxRouter/providers/meta.json +0 -128
- indoxRouter/providers/mistral.json +0 -146
- indoxRouter/providers/nvidia.json +0 -110
- indoxRouter/providers/openai.json +0 -308
- indoxRouter/providers/openai.py +0 -521
- indoxRouter/providers/qwen.json +0 -110
- indoxRouter/utils/__init__.py +0 -240
- indoxrouter-0.1.2.dist-info/LICENSE +0 -21
- indoxrouter-0.1.2.dist-info/METADATA +0 -259
- indoxrouter-0.1.2.dist-info/RECORD +0 -33
- indoxrouter-0.1.2.dist-info/top_level.txt +0 -1
- {indoxrouter-0.1.2.dist-info → indoxrouter-0.1.4.dist-info}/WHEEL +0 -0
@@ -0,0 +1,195 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: indoxrouter
|
3
|
+
Version: 0.1.4
|
4
|
+
Summary: A unified client for various AI providers
|
5
|
+
Home-page: https://github.com/indoxrouter/indoxrouter
|
6
|
+
Author: indoxRouter Team
|
7
|
+
Author-email: ashkan.eskandari.dev@gmail.com
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
9
|
+
Classifier: Intended Audience :: Developers
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Requires-Python: >=3.8
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
Requires-Dist: requests>=2.25.0
|
20
|
+
Requires-Dist: python-dotenv>=1.0.0
|
21
|
+
Provides-Extra: dev
|
22
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
23
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
24
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
25
|
+
Requires-Dist: isort>=5.0.0; extra == "dev"
|
26
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
27
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
28
|
+
Dynamic: author
|
29
|
+
Dynamic: author-email
|
30
|
+
Dynamic: classifier
|
31
|
+
Dynamic: description
|
32
|
+
Dynamic: description-content-type
|
33
|
+
Dynamic: home-page
|
34
|
+
Dynamic: provides-extra
|
35
|
+
Dynamic: requires-dist
|
36
|
+
Dynamic: requires-python
|
37
|
+
Dynamic: summary
|
38
|
+
|
39
|
+
# IndoxRouter Client
|
40
|
+
|
41
|
+
A unified client for various AI providers, including OpenAI, Anthropic, Google, and Mistral.
|
42
|
+
|
43
|
+
## Features
|
44
|
+
|
45
|
+
- **Unified API**: Access multiple AI providers through a single API
|
46
|
+
- **Simple Interface**: Easy-to-use methods for chat, completion, embeddings, and image generation
|
47
|
+
- **Error Handling**: Standardized error handling across providers
|
48
|
+
- **Authentication**: Automatic token management
|
49
|
+
|
50
|
+
## Installation
|
51
|
+
|
52
|
+
```bash
|
53
|
+
pip install indoxrouter
|
54
|
+
```
|
55
|
+
|
56
|
+
## Usage
|
57
|
+
|
58
|
+
### Initialization
|
59
|
+
|
60
|
+
```python
|
61
|
+
from indoxrouter import Client
|
62
|
+
|
63
|
+
# Initialize with API key (default connects to localhost:8000)
|
64
|
+
client = Client(api_key="your_api_key")
|
65
|
+
|
66
|
+
# Or specify a custom server URL
|
67
|
+
client = Client(
|
68
|
+
api_key="your_api_key",
|
69
|
+
base_url="http://your-server-url:8000"
|
70
|
+
)
|
71
|
+
|
72
|
+
# Connect to Docker container inside the Docker network
|
73
|
+
client = Client(
|
74
|
+
api_key="your_api_key",
|
75
|
+
base_url="http://indoxrouter-server:8000"
|
76
|
+
)
|
77
|
+
|
78
|
+
# Using environment variables
|
79
|
+
# Set INDOX_ROUTER_API_KEY environment variable
|
80
|
+
import os
|
81
|
+
os.environ["INDOX_ROUTER_API_KEY"] = "your_api_key"
|
82
|
+
client = Client()
|
83
|
+
```
|
84
|
+
|
85
|
+
### Chat Completions
|
86
|
+
|
87
|
+
```python
|
88
|
+
response = client.chat(
|
89
|
+
messages=[
|
90
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
91
|
+
{"role": "user", "content": "Tell me a joke."}
|
92
|
+
],
|
93
|
+
model="openai/gpt-4o-mini", # Provider/model format
|
94
|
+
temperature=0.7
|
95
|
+
)
|
96
|
+
|
97
|
+
print(response["choices"][0]["message"]["content"])
|
98
|
+
```
|
99
|
+
|
100
|
+
### Text Completions
|
101
|
+
|
102
|
+
```python
|
103
|
+
response = client.completion(
|
104
|
+
prompt="Once upon a time,",
|
105
|
+
model="openai/gpt-4o-mini",
|
106
|
+
max_tokens=100
|
107
|
+
)
|
108
|
+
|
109
|
+
print(response["choices"][0]["text"])
|
110
|
+
```
|
111
|
+
|
112
|
+
### Embeddings
|
113
|
+
|
114
|
+
```python
|
115
|
+
response = client.embeddings(
|
116
|
+
text=["Hello world", "AI is amazing"],
|
117
|
+
model="openai/text-embedding-3-small"
|
118
|
+
)
|
119
|
+
|
120
|
+
print(f"Dimensions: {len(response['data'][0]['embedding'])}")
|
121
|
+
print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
|
122
|
+
```
|
123
|
+
|
124
|
+
### Image Generation
|
125
|
+
|
126
|
+
```python
|
127
|
+
response = client.images(
|
128
|
+
prompt="A serene landscape with mountains and a lake",
|
129
|
+
model="openai/dall-e-3",
|
130
|
+
size="1024x1024"
|
131
|
+
)
|
132
|
+
|
133
|
+
print(f"Image URL: {response['data'][0]['url']}")
|
134
|
+
```
|
135
|
+
|
136
|
+
### Streaming Responses
|
137
|
+
|
138
|
+
```python
|
139
|
+
for chunk in client.chat(
|
140
|
+
messages=[{"role": "user", "content": "Write a short story."}],
|
141
|
+
model="openai/gpt-4o-mini",
|
142
|
+
stream=True
|
143
|
+
):
|
144
|
+
if chunk.get("choices") and len(chunk["choices"]) > 0:
|
145
|
+
content = chunk["choices"][0].get("delta", {}).get("content", "")
|
146
|
+
print(content, end="", flush=True)
|
147
|
+
```
|
148
|
+
|
149
|
+
### Getting Available Models
|
150
|
+
|
151
|
+
```python
|
152
|
+
# Get all providers and models
|
153
|
+
providers = client.models()
|
154
|
+
for provider in providers:
|
155
|
+
print(f"Provider: {provider['name']}")
|
156
|
+
for model in provider["models"]:
|
157
|
+
print(f" - {model['id']}: {model['description'] or ''}")
|
158
|
+
|
159
|
+
# Get models for a specific provider
|
160
|
+
openai_provider = client.models("openai")
|
161
|
+
print(f"OpenAI models: {[m['id'] for m in openai_provider['models']]}")
|
162
|
+
```
|
163
|
+
|
164
|
+
## Error Handling
|
165
|
+
|
166
|
+
```python
|
167
|
+
from indoxrouter import Client, ModelNotFoundError, ProviderError
|
168
|
+
|
169
|
+
try:
|
170
|
+
client = Client(api_key="your_api_key")
|
171
|
+
response = client.chat(
|
172
|
+
messages=[{"role": "user", "content": "Hello"}],
|
173
|
+
model="nonexistent-provider/nonexistent-model"
|
174
|
+
)
|
175
|
+
except ModelNotFoundError as e:
|
176
|
+
print(f"Model not found: {e}")
|
177
|
+
except ProviderError as e:
|
178
|
+
print(f"Provider error: {e}")
|
179
|
+
```
|
180
|
+
|
181
|
+
## Context Manager
|
182
|
+
|
183
|
+
```python
|
184
|
+
with Client(api_key="your_api_key") as client:
|
185
|
+
response = client.chat(
|
186
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
187
|
+
model="openai/gpt-4o-mini"
|
188
|
+
)
|
189
|
+
print(response["choices"][0]["message"]["content"])
|
190
|
+
# Client is automatically closed when exiting the block
|
191
|
+
```
|
192
|
+
|
193
|
+
## License
|
194
|
+
|
195
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
@@ -0,0 +1,4 @@
|
|
1
|
+
indoxrouter-0.1.4.dist-info/METADATA,sha256=LdzdY3TuKijYVTtjvyWGSG9rvN0oYjLll8oSJ3Zr01k,5257
|
2
|
+
indoxrouter-0.1.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
3
|
+
indoxrouter-0.1.4.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
4
|
+
indoxrouter-0.1.4.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
|
indoxRouter/__init__.py
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
indoxRouter - A unified interface for various LLM providers.
|
3
|
-
|
4
|
-
This package provides a simple and consistent way to interact with different
|
5
|
-
LLM providers like OpenAI, Claude, Mistral, and more.
|
6
|
-
"""
|
7
|
-
|
8
|
-
__version__ = "0.1.0"
|
9
|
-
|
10
|
-
from .client import Client, IndoxRouter
|
11
|
-
from .config import Config, get_config
|
12
|
-
from .models import (
|
13
|
-
ChatMessage,
|
14
|
-
ChatResponse,
|
15
|
-
CompletionResponse,
|
16
|
-
EmbeddingResponse,
|
17
|
-
ImageResponse,
|
18
|
-
ModelInfo,
|
19
|
-
Usage,
|
20
|
-
)
|
21
|
-
from .exceptions import (
|
22
|
-
IndoxRouterError,
|
23
|
-
AuthenticationError,
|
24
|
-
ProviderError,
|
25
|
-
ProviderNotFoundError,
|
26
|
-
ModelNotFoundError,
|
27
|
-
InvalidParametersError,
|
28
|
-
RequestError,
|
29
|
-
)
|
30
|
-
from .constants import (
|
31
|
-
DEFAULT_TEMPERATURE,
|
32
|
-
DEFAULT_MAX_TOKENS,
|
33
|
-
DEFAULT_TOP_P,
|
34
|
-
DEFAULT_FREQUENCY_PENALTY,
|
35
|
-
DEFAULT_PRESENCE_PENALTY,
|
36
|
-
DEFAULT_IMAGE_SIZE,
|
37
|
-
DEFAULT_IMAGE_COUNT,
|
38
|
-
)
|
39
|
-
from .utils import (
|
40
|
-
count_tokens,
|
41
|
-
calculate_cost,
|
42
|
-
format_timestamp,
|
43
|
-
)
|
44
|
-
|
45
|
-
__all__ = [
|
46
|
-
# Main client
|
47
|
-
"Client",
|
48
|
-
"IndoxRouter",
|
49
|
-
# Configuration
|
50
|
-
"Config",
|
51
|
-
"get_config",
|
52
|
-
# Database
|
53
|
-
"Database",
|
54
|
-
"get_database",
|
55
|
-
# Models
|
56
|
-
"ChatMessage",
|
57
|
-
"ChatResponse",
|
58
|
-
"CompletionResponse",
|
59
|
-
"EmbeddingResponse",
|
60
|
-
"ImageResponse",
|
61
|
-
"ModelInfo",
|
62
|
-
"Usage",
|
63
|
-
# Exceptions
|
64
|
-
"IndoxRouterError",
|
65
|
-
"AuthenticationError",
|
66
|
-
"ProviderError",
|
67
|
-
"ProviderNotFoundError",
|
68
|
-
"ModelNotFoundError",
|
69
|
-
"InvalidParametersError",
|
70
|
-
"RequestError",
|
71
|
-
# Constants
|
72
|
-
"DEFAULT_TEMPERATURE",
|
73
|
-
"DEFAULT_MAX_TOKENS",
|
74
|
-
"DEFAULT_TOP_P",
|
75
|
-
"DEFAULT_FREQUENCY_PENALTY",
|
76
|
-
"DEFAULT_PRESENCE_PENALTY",
|
77
|
-
"DEFAULT_IMAGE_SIZE",
|
78
|
-
"DEFAULT_IMAGE_COUNT",
|
79
|
-
# Utilities
|
80
|
-
"count_tokens",
|
81
|
-
"calculate_cost",
|
82
|
-
"format_timestamp",
|
83
|
-
]
|