GPTRouter 0.3.5__tar.gz → 0.3.7__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.
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/GPTRouter.egg-info/PKG-INFO +1 -1
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/PKG-INFO +1 -1
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/gpt_router/client.py +12 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/gpt_router/enums.py +3 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/setup.py +1 -1
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/GPTRouter.egg-info/SOURCES.txt +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/GPTRouter.egg-info/dependency_links.txt +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/GPTRouter.egg-info/requires.txt +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/GPTRouter.egg-info/top_level.txt +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/LICENSE +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/README.md +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/gpt_router/__init__.py +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/gpt_router/constants.py +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/gpt_router/exceptions.py +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/gpt_router/models.py +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/pyproject.toml +0 -0
- {GPTRouter-0.3.5 → GPTRouter-0.3.7}/setup.cfg +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
import asyncio
|
|
2
3
|
from pydantic import parse_obj_as
|
|
3
4
|
import logging
|
|
4
5
|
import json
|
|
@@ -153,6 +154,7 @@ class GPTRouterClient:
|
|
|
153
154
|
|
|
154
155
|
async def astream_events(self, *, path: str, method: str, payload: dict, **kwargs):
|
|
155
156
|
retry_count = kwargs.get("stream_retry_count") or 1
|
|
157
|
+
stop_stream_signal = kwargs.get("stop_stream_signal")
|
|
156
158
|
async_retrying = AsyncRetrying(
|
|
157
159
|
stop=stop_after_attempt(retry_count),
|
|
158
160
|
wait=wait_fixed(0.5),
|
|
@@ -191,6 +193,10 @@ class GPTRouterClient:
|
|
|
191
193
|
raise ServerError("Server error")
|
|
192
194
|
response.raise_for_status()
|
|
193
195
|
async for line in response.aiter_lines():
|
|
196
|
+
if stop_stream_signal and stop_stream_signal.is_set():
|
|
197
|
+
logger.info("Stopping stream due to signal")
|
|
198
|
+
await response.aclose()
|
|
199
|
+
return
|
|
194
200
|
try:
|
|
195
201
|
if line.strip() == "":
|
|
196
202
|
continue
|
|
@@ -223,6 +229,10 @@ class GPTRouterClient:
|
|
|
223
229
|
) from err
|
|
224
230
|
except httpx.TimeoutException as err:
|
|
225
231
|
raise TimeoutError("Request timed out") from err
|
|
232
|
+
finally:
|
|
233
|
+
if stop_stream_signal and stop_stream_signal.is_set():
|
|
234
|
+
logger.info("Stream stopped due to signal")
|
|
235
|
+
return
|
|
226
236
|
|
|
227
237
|
def stream_events(
|
|
228
238
|
self, *, path: str, method: str, payload: dict, **kwargs
|
|
@@ -338,6 +348,7 @@ class GPTRouterClient:
|
|
|
338
348
|
ordered_generation_requests: List[ModelGenerationRequest],
|
|
339
349
|
is_stream=False,
|
|
340
350
|
model_router_metadata: Optional[GPTRouterMetadata] = None,
|
|
351
|
+
stop_stream_signal: Optional[asyncio.Event] = None,
|
|
341
352
|
**kwargs,
|
|
342
353
|
) -> GenerationResponse:
|
|
343
354
|
api_path = "/v1/generate"
|
|
@@ -355,6 +366,7 @@ class GPTRouterClient:
|
|
|
355
366
|
path=api_path,
|
|
356
367
|
method=api_method,
|
|
357
368
|
payload=api_payload,
|
|
369
|
+
stop_stream_signal=stop_stream_signal,
|
|
358
370
|
**kwargs,
|
|
359
371
|
)
|
|
360
372
|
result = await self._async_api_call(
|
|
@@ -93,6 +93,9 @@ class GPTRouterEngines(Enum):
|
|
|
93
93
|
OPENAI_GPT_4_O = ModelDetails(ProvidersEnum.CHAT_OPENAI.value, "gpt-4o")
|
|
94
94
|
|
|
95
95
|
OPENAI_GPT_4_O_MINI = ModelDetails(ProvidersEnum.CHAT_OPENAI.value, "gpt-4o-mini")
|
|
96
|
+
AZURE_GPT_4O_MINI_2024_07_18 = ModelDetails(
|
|
97
|
+
ProvidersEnum.AZURE_CHAT_OPENAI.value, "gpt-4o-mini-2024-07-18"
|
|
98
|
+
)
|
|
96
99
|
OPENAI_GPT_4_O_24_08_06 = ModelDetails(ProvidersEnum.CHAT_OPENAI.value, "gpt-4o-2024-08-06")
|
|
97
100
|
|
|
98
101
|
OPENAI_GPT_4_32K_0613 = ModelDetails(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|