GPTRouter 0.3.8__tar.gz → 0.4.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GPTRouter
3
- Version: 0.3.8
3
+ Version: 0.4.0
4
4
  Summary: A Python package for working with GPTRouter APIs
5
5
  Author-email: sirjanpreet@writesonic.com
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GPTRouter
3
- Version: 0.3.8
3
+ Version: 0.4.0
4
4
  Summary: A Python package for working with GPTRouter APIs
5
5
  Author-email: sirjanpreet@writesonic.com
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -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"
@@ -45,6 +50,12 @@ class ModelsEnum(Enum):
45
50
  STABLE_DIFFUSION_V6 = "stable-diffusion-v1-6"
46
51
 
47
52
  REPLICATE_FLUX = "black-forest-labs/flux-dev"
53
+ REPLICATE_FLUX_PRO = "black-forest-labs/flux-pro"
54
+ REPLICATE_FLUX_11_PRO = "black-forest-labs/flux-1.1-pro"
55
+ REPLICATE_FLUX_SCHNELL = "black-forest-labs/flux-schnell"
56
+
57
+ OPENAI_EMBEDDINGS_ADA_002 = "text-embedding-ada-002"
58
+ AZURE_OPENAI_EMBEDDINGS_ADA_002 = "text-embedding-ada-002"
48
59
 
49
60
  class StreamingEventType(Enum):
50
61
  UPDATE = "update"
@@ -156,6 +167,15 @@ class GPTRouterEngines(Enum):
156
167
  REPLICATE_FLUX = ModelDetails(
157
168
  ProvidersEnum.REPLICATE.value, "black-forest-labs/flux-dev"
158
169
  )
170
+ REPLICATE_FLUX_PRO = ModelDetails(
171
+ ProvidersEnum.REPLICATE.value, "black-forest-labs/flux-pro"
172
+ )
173
+ REPLICATE_FLUX_11_PRO = ModelDetails(
174
+ ProvidersEnum.REPLICATE.value, "black-forest-labs/flux-1.1-pro"
175
+ )
176
+ REPLICATE_FLUX_SCHNELL = ModelDetails(
177
+ ProvidersEnum.REPLICATE.value, "black-forest-labs/flux-schnell"
178
+ )
159
179
 
160
180
  LLAMA_3_70B_NITRO = ModelDetails(
161
181
  ProvidersEnum.OPENROUTER, "meta-llama/llama-3-70b-instruct:nitro"
@@ -89,6 +89,7 @@ class ImageGenerationRequest(BaseModel):
89
89
  num_images: int = Field(alias="numImages", default=1)
90
90
  width: Optional[int] = Field(None, alias="width")
91
91
  height: Optional[int] = Field(None, alias="height")
92
+ num_inference_steps: Optional[int] = Field(None, alias="numInferenceSteps")
92
93
 
93
94
  class Config:
94
95
  allow_population_by_field_name = True
@@ -109,3 +110,47 @@ class ImageGenerationResponse(BaseModel):
109
110
  url: str = None
110
111
  base64: str = None
111
112
  finish_reason: Optional[str] = Field(default="SUCCESS", alias='finishReason')
113
+
114
+
115
+ class ModelRouterGenerationRequest(BaseModel):
116
+ model_name: str
117
+ model_provider: str
118
+ prompt_params: GenerationParams = Field(alias="promptParams")
119
+ should_validate_token_count: Optional[bool] = Field(
120
+ default=False, alias="shouldValidateTokenCount"
121
+ )
122
+
123
+ class Config:
124
+ allow_population_by_field_name = True
125
+
126
+ def dict(self, *args, **kwargs):
127
+ # Generate the standard dict first.
128
+ result = super().dict(*args, **kwargs, exclude_none=True, by_alias=True)
129
+
130
+ result["providerName"] = self.model_provider
131
+ result["modelName"] = self.model_name
132
+
133
+ return result
134
+
135
+ class ModelRouterEmbeddingsGenerationParams(BaseModel):
136
+ input: List[str]
137
+
138
+
139
+ class ModelRouterEmbeddingsGenerationRequest(ModelRouterGenerationRequest):
140
+ prompt_params: ModelRouterEmbeddingsGenerationParams = Field(alias="promptParams")
141
+
142
+ class ModelRouterGenerationResponse(BaseModel):
143
+ id: str
144
+ choices: List[Choice]
145
+ model: str
146
+ provider_id: Optional[str] = Field(None, alias="providerId")
147
+ model_id: Optional[str] = Field(None, alias="modelId")
148
+ meta: Optional[Usage]
149
+
150
+
151
+
152
+ class EmbeddingsChoice(BaseModel):
153
+ embedding: List[float]
154
+
155
+ class ModelRouterEmbeddingsGenerationResponse(BaseModel):
156
+ choices: List[EmbeddingsChoice]
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="GPTRouter",
8
- version="0.3.8",
8
+ version="0.4.0",
9
9
  description="A Python package for working with GPTRouter APIs",
10
10
  long_description=long_description,
11
11
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes