GPTRouter 0.3.8__tar.gz → 0.3.9__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.8 → GPTRouter-0.3.9}/GPTRouter.egg-info/PKG-INFO +1 -1
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/PKG-INFO +1 -1
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/gpt_router/client.py +28 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/gpt_router/enums.py +8 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/gpt_router/models.py +44 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/setup.py +1 -1
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/GPTRouter.egg-info/SOURCES.txt +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/GPTRouter.egg-info/dependency_links.txt +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/GPTRouter.egg-info/requires.txt +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/GPTRouter.egg-info/top_level.txt +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/LICENSE +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/README.md +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/gpt_router/__init__.py +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/gpt_router/constants.py +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/gpt_router/exceptions.py +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/pyproject.toml +0 -0
- {GPTRouter-0.3.8 → GPTRouter-0.3.9}/setup.cfg +0 -0
|
@@ -13,6 +13,9 @@ from gpt_router.models import (
|
|
|
13
13
|
ModelGenerationRequest,
|
|
14
14
|
GenerationResponse,
|
|
15
15
|
ChunkedGenerationResponse,
|
|
16
|
+
ModelRouterEmbeddingsGenerationRequest,
|
|
17
|
+
ModelRouterGenerationResponse,
|
|
18
|
+
ModelRouterEmbeddingsGenerationResponse
|
|
16
19
|
)
|
|
17
20
|
from gpt_router.exceptions import (
|
|
18
21
|
GPTRouterApiTimeoutError,
|
|
@@ -71,6 +74,31 @@ class GPTRouterClient:
|
|
|
71
74
|
request_timeout if stream_read_timeout is None else stream_read_timeout
|
|
72
75
|
)
|
|
73
76
|
|
|
77
|
+
async def agenerate_embeddings(
|
|
78
|
+
self,
|
|
79
|
+
*,
|
|
80
|
+
ordered_generation_requests: List[
|
|
81
|
+
ModelRouterEmbeddingsGenerationRequest
|
|
82
|
+
],
|
|
83
|
+
model_router_metadata: Optional[GPTRouterMetadata] = None,
|
|
84
|
+
) -> ModelRouterGenerationResponse:
|
|
85
|
+
api_payload = {
|
|
86
|
+
"data": [
|
|
87
|
+
{
|
|
88
|
+
**request.dict(),
|
|
89
|
+
"order": index + 1,
|
|
90
|
+
}
|
|
91
|
+
for index, request in enumerate(ordered_generation_requests)
|
|
92
|
+
],
|
|
93
|
+
}
|
|
94
|
+
api_payload = self.add_metadata_info(api_payload, model_router_metadata)
|
|
95
|
+
response = await self._async_api_call(
|
|
96
|
+
path="/v1/generate/embeddings",
|
|
97
|
+
method="POST",
|
|
98
|
+
payload=api_payload,
|
|
99
|
+
)
|
|
100
|
+
return ModelRouterEmbeddingsGenerationResponse.parse_obj(response)
|
|
101
|
+
|
|
74
102
|
def add_metadata_info(
|
|
75
103
|
self,
|
|
76
104
|
payload: dict,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from collections import namedtuple
|
|
2
2
|
from enum import Enum
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
|
|
4
6
|
class ProvidersEnum(Enum):
|
|
5
7
|
OPENAI = "openai"
|
|
6
8
|
CHAT_OPENAI = "chat_openai"
|
|
@@ -16,6 +18,9 @@ class ProvidersEnum(Enum):
|
|
|
16
18
|
DALL_E = "dall-e"
|
|
17
19
|
OPENROUTER = "openrouter"
|
|
18
20
|
REPLICATE = "replicate"
|
|
21
|
+
OPENAI_EMBEDDINGS = "openai_embeddings"
|
|
22
|
+
AZURE_OPENAI_EMBEDDINGS = "azure_openai_embeddings"
|
|
23
|
+
|
|
19
24
|
|
|
20
25
|
class ModelsEnum(Enum):
|
|
21
26
|
OPENAI_GPT_35_TURBO_16K = "gpt-3.5-turbo-16k"
|
|
@@ -46,6 +51,9 @@ class ModelsEnum(Enum):
|
|
|
46
51
|
|
|
47
52
|
REPLICATE_FLUX = "black-forest-labs/flux-dev"
|
|
48
53
|
|
|
54
|
+
OPENAI_EMBEDDINGS_ADA_002 = "text-embedding-ada-002"
|
|
55
|
+
AZURE_OPENAI_EMBEDDINGS_ADA_002 = "text-embedding-ada-002"
|
|
56
|
+
|
|
49
57
|
class StreamingEventType(Enum):
|
|
50
58
|
UPDATE = "update"
|
|
51
59
|
META = "meta"
|
|
@@ -109,3 +109,47 @@ class ImageGenerationResponse(BaseModel):
|
|
|
109
109
|
url: str = None
|
|
110
110
|
base64: str = None
|
|
111
111
|
finish_reason: Optional[str] = Field(default="SUCCESS", alias='finishReason')
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class ModelRouterGenerationRequest(BaseModel):
|
|
115
|
+
model_name: str
|
|
116
|
+
model_provider: str
|
|
117
|
+
prompt_params: GenerationParams = Field(alias="promptParams")
|
|
118
|
+
should_validate_token_count: Optional[bool] = Field(
|
|
119
|
+
default=False, alias="shouldValidateTokenCount"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
class Config:
|
|
123
|
+
allow_population_by_field_name = True
|
|
124
|
+
|
|
125
|
+
def dict(self, *args, **kwargs):
|
|
126
|
+
# Generate the standard dict first.
|
|
127
|
+
result = super().dict(*args, **kwargs, exclude_none=True, by_alias=True)
|
|
128
|
+
|
|
129
|
+
result["providerName"] = self.model_provider
|
|
130
|
+
result["modelName"] = self.model_name
|
|
131
|
+
|
|
132
|
+
return result
|
|
133
|
+
|
|
134
|
+
class ModelRouterEmbeddingsGenerationParams(BaseModel):
|
|
135
|
+
input: List[str]
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class ModelRouterEmbeddingsGenerationRequest(ModelRouterGenerationRequest):
|
|
139
|
+
prompt_params: ModelRouterEmbeddingsGenerationParams = Field(alias="promptParams")
|
|
140
|
+
|
|
141
|
+
class ModelRouterGenerationResponse(BaseModel):
|
|
142
|
+
id: str
|
|
143
|
+
choices: List[Choice]
|
|
144
|
+
model: str
|
|
145
|
+
provider_id: Optional[str] = Field(None, alias="providerId")
|
|
146
|
+
model_id: Optional[str] = Field(None, alias="modelId")
|
|
147
|
+
meta: Optional[Usage]
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class EmbeddingsChoice(BaseModel):
|
|
152
|
+
embedding: List[float]
|
|
153
|
+
|
|
154
|
+
class ModelRouterEmbeddingsGenerationResponse(BaseModel):
|
|
155
|
+
choices: List[EmbeddingsChoice]
|
|
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
|