indoxrouter 0.1.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: indoxrouter
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A unified client for various AI providers
5
5
  Home-page: https://github.com/indoxrouter/indoxrouter
6
6
  Author: indoxRouter Team
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.8
13
13
  Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
16
17
  Requires-Python: >=3.8
17
18
  Description-Content-Type: text/markdown
18
19
  Requires-Dist: requests>=2.25.0
@@ -37,7 +38,7 @@ Dynamic: summary
37
38
 
38
39
  # IndoxRouter Client
39
40
 
40
- A unified client for various AI providers, including OpenAI, Anthropic, Cohere, Google, and Mistral.
41
+ A unified client for various AI providers, including OpenAI, Anthropic, Google, and Mistral.
41
42
 
42
43
  ## Features
43
44
 
@@ -59,19 +60,26 @@ pip install indoxrouter
59
60
  ```python
60
61
  from indoxrouter import Client
61
62
 
62
- # Initialize with API key
63
- client = Client(api_key="your_api_key", base_url="http://your-server-url:8000")
63
+ # Initialize with API key (default connects to localhost:8000)
64
+ client = Client(api_key="your_api_key")
64
65
 
65
- # Or initialize with username and password
66
+ # Or specify a custom server URL
66
67
  client = Client(
67
- username="your_username",
68
- password="your_password",
68
+ api_key="your_api_key",
69
69
  base_url="http://your-server-url:8000"
70
70
  )
71
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
+
72
78
  # Using environment variables
73
- # Set INDOXROUTER_API_KEY or INDOXROUTER_USERNAME and INDOXROUTER_PASSWORD
74
- client = Client(base_url="http://your-server-url:8000")
79
+ # Set INDOX_ROUTER_API_KEY environment variable
80
+ import os
81
+ os.environ["INDOX_ROUTER_API_KEY"] = "your_api_key"
82
+ client = Client()
75
83
  ```
76
84
 
77
85
  ### Chat Completions
@@ -82,8 +90,7 @@ response = client.chat(
82
90
  {"role": "system", "content": "You are a helpful assistant."},
83
91
  {"role": "user", "content": "Tell me a joke."}
84
92
  ],
85
- provider="openai",
86
- model="gpt-3.5-turbo",
93
+ model="openai/gpt-4o-mini", # Provider/model format
87
94
  temperature=0.7
88
95
  )
89
96
 
@@ -95,8 +102,7 @@ print(response["choices"][0]["message"]["content"])
95
102
  ```python
96
103
  response = client.completion(
97
104
  prompt="Once upon a time,",
98
- provider="openai",
99
- model="gpt-3.5-turbo-instruct",
105
+ model="openai/gpt-4o-mini",
100
106
  max_tokens=100
101
107
  )
102
108
 
@@ -108,12 +114,11 @@ print(response["choices"][0]["text"])
108
114
  ```python
109
115
  response = client.embeddings(
110
116
  text=["Hello world", "AI is amazing"],
111
- provider="openai",
112
- model="text-embedding-ada-002"
117
+ model="openai/text-embedding-3-small"
113
118
  )
114
119
 
115
- print(f"Dimensions: {response['dimensions']}")
116
- print(f"First embedding: {response['embeddings'][0][:5]}...")
120
+ print(f"Dimensions: {len(response['data'][0]['embedding'])}")
121
+ print(f"First embedding: {response['data'][0]['embedding'][:5]}...")
117
122
  ```
118
123
 
119
124
  ### Image Generation
@@ -121,12 +126,11 @@ print(f"First embedding: {response['embeddings'][0][:5]}...")
121
126
  ```python
122
127
  response = client.images(
123
128
  prompt="A serene landscape with mountains and a lake",
124
- provider="openai",
125
- model="dall-e-3",
129
+ model="openai/dall-e-3",
126
130
  size="1024x1024"
127
131
  )
128
132
 
129
- print(f"Image URL: {response['images'][0]['url']}")
133
+ print(f"Image URL: {response['data'][0]['url']}")
130
134
  ```
131
135
 
132
136
  ### Streaming Responses
@@ -134,9 +138,10 @@ print(f"Image URL: {response['images'][0]['url']}")
134
138
  ```python
135
139
  for chunk in client.chat(
136
140
  messages=[{"role": "user", "content": "Write a short story."}],
141
+ model="openai/gpt-4o-mini",
137
142
  stream=True
138
143
  ):
139
- if "choices" in chunk and len(chunk["choices"]) > 0:
144
+ if chunk.get("choices") and len(chunk["choices"]) > 0:
140
145
  content = chunk["choices"][0].get("delta", {}).get("content", "")
141
146
  print(content, end="", flush=True)
142
147
  ```
@@ -149,7 +154,7 @@ providers = client.models()
149
154
  for provider in providers:
150
155
  print(f"Provider: {provider['name']}")
151
156
  for model in provider["models"]:
152
- print(f" - {model['id']}: {model['name']}")
157
+ print(f" - {model['id']}: {model['description'] or ''}")
153
158
 
154
159
  # Get models for a specific provider
155
160
  openai_provider = client.models("openai")
@@ -162,11 +167,10 @@ print(f"OpenAI models: {[m['id'] for m in openai_provider['models']]}")
162
167
  from indoxrouter import Client, ModelNotFoundError, ProviderError
163
168
 
164
169
  try:
165
- client = Client(api_key="your_api_key", base_url="http://your-server-url:8000")
170
+ client = Client(api_key="your_api_key")
166
171
  response = client.chat(
167
172
  messages=[{"role": "user", "content": "Hello"}],
168
- provider="nonexistent",
169
- model="nonexistent-model"
173
+ model="nonexistent-provider/nonexistent-model"
170
174
  )
171
175
  except ModelNotFoundError as e:
172
176
  print(f"Model not found: {e}")
@@ -177,8 +181,11 @@ except ProviderError as e:
177
181
  ## Context Manager
178
182
 
179
183
  ```python
180
- with Client(api_key="your_api_key", base_url="http://your-server-url:8000") as client:
181
- response = client.chat([{"role": "user", "content": "Hello!"}])
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
+ )
182
189
  print(response["choices"][0]["message"]["content"])
183
190
  # Client is automatically closed when exiting the block
184
191
  ```
@@ -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,,
@@ -1,4 +0,0 @@
1
- indoxrouter-0.1.3.dist-info/METADATA,sha256=7efp8b9jiVIK0-EnavBfiufhCNy-MdmW2tPvPRm7Isk,5122
2
- indoxrouter-0.1.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
3
- indoxrouter-0.1.3.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- indoxrouter-0.1.3.dist-info/RECORD,,