metaai-sdk 2.3.5__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 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], ai.prompt(body.message, stream=False, new_conversation=body.new_conversation, media_ids=body.media_ids, attachment_metadata=body.attachment_metadata))
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], ai.prompt(
222
- prompt,
223
- stream=False,
224
- new_conversation=body.new_conversation,
225
- media_ids=body.media_ids,
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,
metaai_api/main.py CHANGED
@@ -239,7 +239,7 @@ class MetaAI:
239
239
  "promptType": None,
240
240
  "artifactRewriteOptions": None,
241
241
  "imagineOperationRequest": None,
242
- "imagineClientOptions": {"orientation": orientation.upper() if orientation else "VERTICAL"},
242
+ "imagineClientOptions": {"orientation": str(orientation).upper() if orientation else "VERTICAL"},
243
243
  "spaceId": None,
244
244
  "sparkSnapshotId": None,
245
245
  "topicPageId": None,
@@ -236,7 +236,7 @@ class VideoGenerator:
236
236
  "promptType": None,
237
237
  "artifactRewriteOptions": None,
238
238
  "imagineOperationRequest": None,
239
- "imagineClientOptions": {"orientation": orientation.upper() if orientation else "VERTICAL"},
239
+ "imagineClientOptions": {"orientation": str(orientation).upper() if orientation else "VERTICAL"},
240
240
  "spaceId": None,
241
241
  "sparkSnapshotId": None,
242
242
  "topicPageId": None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metaai-sdk
3
- Version: 2.3.5
3
+ Version: 3.0.0
4
4
  Summary: Feature-rich Python SDK for Meta AI - Chat, Image & Video Generation powered by Llama 3
5
5
  Author-email: Ashiq Hussain Mir <imseldrith@gmail.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,13 @@
1
+ metaai_api/__init__.py,sha256=YT4Dn_m1Fm3Hh10D4Z9jtmADjQHnZSsdtwIn8IlCjN4,714
2
+ metaai_api/api_server.py,sha256=Tb5spAef-kKglEfGP96Fzruw8V0hHUKLqgrz04RDH0M,14000
3
+ metaai_api/client.py,sha256=Th46qW1l8OS8Hu5pj0aGFn4iQNz62A3sbXko-LP-SAU,5263
4
+ metaai_api/exceptions.py,sha256=MRRAppZa0OFA0QLSvC0nABgZN_Ll1dUq9JfhECTqV-Q,114
5
+ metaai_api/image_upload.py,sha256=DQ2xqKdM1I_pF1rZBsB7-QTvXLzke2_0XiIOxFhpc70,6563
6
+ metaai_api/main.py,sha256=nskRHsJknxV_wJ25nJAetDodypKtQ_Lz2gpYqtfTyi0,36743
7
+ metaai_api/utils.py,sha256=qzfIO3WkRH-gSV99b8RiECnMOku8lZEY3Jka9lTLExA,11979
8
+ metaai_api/video_generation.py,sha256=JWrSyx7UhHFOHNiyNds7V_hGkwPHB_SiiApe9jQfp0U,37485
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.10.1)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,13 +0,0 @@
1
- metaai_api/__init__.py,sha256=YT4Dn_m1Fm3Hh10D4Z9jtmADjQHnZSsdtwIn8IlCjN4,714
2
- metaai_api/api_server.py,sha256=hb1C3rEarPOHF6W-qqENaxrZWwn8A0qUrjSVlRtNV2s,13248
3
- metaai_api/client.py,sha256=Th46qW1l8OS8Hu5pj0aGFn4iQNz62A3sbXko-LP-SAU,5263
4
- metaai_api/exceptions.py,sha256=MRRAppZa0OFA0QLSvC0nABgZN_Ll1dUq9JfhECTqV-Q,114
5
- metaai_api/image_upload.py,sha256=DQ2xqKdM1I_pF1rZBsB7-QTvXLzke2_0XiIOxFhpc70,6563
6
- metaai_api/main.py,sha256=bZrao6uZI-CdtHvdu64jUH72h0R7atN2PNrP5TaHpMM,36738
7
- metaai_api/utils.py,sha256=qzfIO3WkRH-gSV99b8RiECnMOku8lZEY3Jka9lTLExA,11979
8
- metaai_api/video_generation.py,sha256=Kw0Hwqeai6EexPhJsN-0eLSmIL0zDp95EwAPk6UQ9Rs,37480
9
- metaai_sdk-2.3.5.dist-info/licenses/LICENSE,sha256=hRLLSBixyX0tRh2k0iOGoF7nx-l-vBChNffFfVOIEtc,1290
10
- metaai_sdk-2.3.5.dist-info/METADATA,sha256=adQytqJvLOkHunqgkZet0ImIU74pTSbZK2udaC0utN4,28998
11
- metaai_sdk-2.3.5.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
12
- metaai_sdk-2.3.5.dist-info/top_level.txt,sha256=R6YCiIQLYFKKaqhNZXDwXbpj1u01P_YhcMCVbJiDUJs,11
13
- metaai_sdk-2.3.5.dist-info/RECORD,,