metaai-sdk 2.3.6__py3-none-any.whl → 3.0.0__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.
- metaai_api/api_server.py +28 -7
- {metaai_sdk-2.3.6.dist-info → metaai_sdk-3.0.0.dist-info}/METADATA +1 -1
- {metaai_sdk-2.3.6.dist-info → metaai_sdk-3.0.0.dist-info}/RECORD +6 -6
- {metaai_sdk-2.3.6.dist-info → metaai_sdk-3.0.0.dist-info}/WHEEL +0 -0
- {metaai_sdk-2.3.6.dist-info → metaai_sdk-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {metaai_sdk-2.3.6.dist-info → metaai_sdk-3.0.0.dist-info}/top_level.txt +0 -0
metaai_api/api_server.py
CHANGED
|
@@ -107,12 +107,14 @@ class ImageRequest(BaseModel):
|
|
|
107
107
|
new_conversation: bool = False
|
|
108
108
|
media_ids: Optional[list] = None
|
|
109
109
|
attachment_metadata: Optional[dict] = None # {'file_size': int, 'mime_type': str}
|
|
110
|
+
orientation: Optional[str] = None # 'VERTICAL', 'LANDSCAPE' (not HORIZONTAL), or 'SQUARE'
|
|
110
111
|
|
|
111
112
|
|
|
112
113
|
class VideoRequest(BaseModel):
|
|
113
114
|
prompt: str
|
|
114
115
|
media_ids: Optional[list] = None
|
|
115
116
|
attachment_metadata: Optional[dict] = None # {'file_size': int, 'mime_type': str}
|
|
117
|
+
orientation: Optional[str] = None # 'VERTICAL', 'LANDSCAPE', or 'SQUARE'
|
|
116
118
|
wait_before_poll: int = Field(10, ge=0, le=60)
|
|
117
119
|
max_attempts: int = Field(30, ge=1, le=60)
|
|
118
120
|
wait_seconds: int = Field(5, ge=1, le=30)
|
|
@@ -206,7 +208,14 @@ async def chat(body: ChatRequest, cookies: Dict[str, str] = Depends(get_cookies)
|
|
|
206
208
|
raise HTTPException(status_code=400, detail="Streaming not supported via HTTP JSON; set stream=false")
|
|
207
209
|
ai = MetaAI(cookies=cookies, proxy=_get_proxies())
|
|
208
210
|
try:
|
|
209
|
-
return cast(Dict[str, Any],
|
|
211
|
+
return cast(Dict[str, Any], await run_in_threadpool(
|
|
212
|
+
ai.prompt,
|
|
213
|
+
body.message,
|
|
214
|
+
stream=False,
|
|
215
|
+
new_conversation=body.new_conversation,
|
|
216
|
+
media_ids=body.media_ids,
|
|
217
|
+
attachment_metadata=body.attachment_metadata
|
|
218
|
+
))
|
|
210
219
|
except Exception as exc: # noqa: BLE001
|
|
211
220
|
await cache.refresh_after_error()
|
|
212
221
|
raise HTTPException(status_code=502, detail=str(exc)) from exc
|
|
@@ -218,13 +227,15 @@ async def image(body: ImageRequest, cookies: Dict[str, str] = Depends(get_cookie
|
|
|
218
227
|
try:
|
|
219
228
|
# Automatically prepend "generate image of" to the prompt
|
|
220
229
|
prompt = f"generate image of {body.prompt}" if not body.prompt.lower().startswith(("generate image", "create image")) else body.prompt
|
|
221
|
-
return cast(Dict[str, Any],
|
|
222
|
-
prompt,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
return cast(Dict[str, Any], await run_in_threadpool(
|
|
231
|
+
ai.prompt,
|
|
232
|
+
prompt,
|
|
233
|
+
stream=False,
|
|
234
|
+
new_conversation=body.new_conversation,
|
|
235
|
+
media_ids=body.media_ids,
|
|
226
236
|
attachment_metadata=body.attachment_metadata,
|
|
227
|
-
is_image_generation=True # Image generation uses DISCOVER entrypoint
|
|
237
|
+
is_image_generation=True, # Image generation uses DISCOVER entrypoint
|
|
238
|
+
orientation=body.orientation # Support VERTICAL, HORIZONTAL, SQUARE
|
|
228
239
|
))
|
|
229
240
|
except Exception as exc: # noqa: BLE001
|
|
230
241
|
await cache.refresh_after_error()
|
|
@@ -233,6 +244,10 @@ async def image(body: ImageRequest, cookies: Dict[str, str] = Depends(get_cookie
|
|
|
233
244
|
|
|
234
245
|
@app.post("/video")
|
|
235
246
|
async def video(body: VideoRequest, cookies: Dict[str, str] = Depends(get_cookies)) -> Dict[str, Any]:
|
|
247
|
+
# Force refresh cookies before video generation for best results
|
|
248
|
+
await cache.refresh_if_needed(force=True)
|
|
249
|
+
cookies = await cache.snapshot()
|
|
250
|
+
|
|
236
251
|
ai = MetaAI(cookies=cookies, proxy=_get_proxies())
|
|
237
252
|
try:
|
|
238
253
|
# Automatically prepend "generate a video" to the prompt
|
|
@@ -242,6 +257,7 @@ async def video(body: VideoRequest, cookies: Dict[str, str] = Depends(get_cookie
|
|
|
242
257
|
prompt,
|
|
243
258
|
body.media_ids,
|
|
244
259
|
body.attachment_metadata,
|
|
260
|
+
body.orientation,
|
|
245
261
|
body.wait_before_poll,
|
|
246
262
|
body.max_attempts,
|
|
247
263
|
body.wait_seconds,
|
|
@@ -254,6 +270,10 @@ async def video(body: VideoRequest, cookies: Dict[str, str] = Depends(get_cookie
|
|
|
254
270
|
|
|
255
271
|
@app.post("/video/async")
|
|
256
272
|
async def video_async(body: VideoRequest, cookies: Dict[str, str] = Depends(get_cookies)) -> Dict[str, str]:
|
|
273
|
+
# Force refresh cookies before video generation
|
|
274
|
+
await cache.refresh_if_needed(force=True)
|
|
275
|
+
cookies = await cache.snapshot()
|
|
276
|
+
|
|
257
277
|
job = await jobs.create()
|
|
258
278
|
asyncio.create_task(_run_video_job(job.job_id, body, cookies))
|
|
259
279
|
return {"job_id": job.job_id, "status": "pending"}
|
|
@@ -322,6 +342,7 @@ async def _run_video_job(job_id: str, body: VideoRequest, cookies: Dict[str, str
|
|
|
322
342
|
body.prompt,
|
|
323
343
|
body.media_ids,
|
|
324
344
|
body.attachment_metadata,
|
|
345
|
+
body.orientation,
|
|
325
346
|
body.wait_before_poll,
|
|
326
347
|
body.max_attempts,
|
|
327
348
|
body.wait_seconds,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
metaai_api/__init__.py,sha256=YT4Dn_m1Fm3Hh10D4Z9jtmADjQHnZSsdtwIn8IlCjN4,714
|
|
2
|
-
metaai_api/api_server.py,sha256=
|
|
2
|
+
metaai_api/api_server.py,sha256=Tb5spAef-kKglEfGP96Fzruw8V0hHUKLqgrz04RDH0M,14000
|
|
3
3
|
metaai_api/client.py,sha256=Th46qW1l8OS8Hu5pj0aGFn4iQNz62A3sbXko-LP-SAU,5263
|
|
4
4
|
metaai_api/exceptions.py,sha256=MRRAppZa0OFA0QLSvC0nABgZN_Ll1dUq9JfhECTqV-Q,114
|
|
5
5
|
metaai_api/image_upload.py,sha256=DQ2xqKdM1I_pF1rZBsB7-QTvXLzke2_0XiIOxFhpc70,6563
|
|
6
6
|
metaai_api/main.py,sha256=nskRHsJknxV_wJ25nJAetDodypKtQ_Lz2gpYqtfTyi0,36743
|
|
7
7
|
metaai_api/utils.py,sha256=qzfIO3WkRH-gSV99b8RiECnMOku8lZEY3Jka9lTLExA,11979
|
|
8
8
|
metaai_api/video_generation.py,sha256=JWrSyx7UhHFOHNiyNds7V_hGkwPHB_SiiApe9jQfp0U,37485
|
|
9
|
-
metaai_sdk-
|
|
10
|
-
metaai_sdk-
|
|
11
|
-
metaai_sdk-
|
|
12
|
-
metaai_sdk-
|
|
13
|
-
metaai_sdk-
|
|
9
|
+
metaai_sdk-3.0.0.dist-info/licenses/LICENSE,sha256=hRLLSBixyX0tRh2k0iOGoF7nx-l-vBChNffFfVOIEtc,1290
|
|
10
|
+
metaai_sdk-3.0.0.dist-info/METADATA,sha256=OeI0MdIvd8dyemT120QD137noiwPNUct-689j62uj2U,28998
|
|
11
|
+
metaai_sdk-3.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
12
|
+
metaai_sdk-3.0.0.dist-info/top_level.txt,sha256=R6YCiIQLYFKKaqhNZXDwXbpj1u01P_YhcMCVbJiDUJs,11
|
|
13
|
+
metaai_sdk-3.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|