metaai-sdk 2.1.1__tar.gz → 2.2.1__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.
Files changed (33) hide show
  1. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/CHANGELOG.md +79 -0
  2. {metaai_sdk-2.1.1/src/metaai_sdk.egg-info → metaai_sdk-2.2.1}/PKG-INFO +91 -18
  3. metaai_sdk-2.1.1/PKG-INFO → metaai_sdk-2.2.1/README.md +882 -854
  4. metaai_sdk-2.2.1/examples/complete_workflow_example.py +339 -0
  5. metaai_sdk-2.2.1/examples/image_upload_example.py +248 -0
  6. metaai_sdk-2.2.1/examples/image_workflow_complete.py +107 -0
  7. metaai_sdk-2.2.1/examples/practical_use_cases.py +309 -0
  8. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/pyproject.toml +2 -1
  9. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/setup.py +1 -1
  10. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/__init__.py +3 -1
  11. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/api_server.py +68 -3
  12. metaai_sdk-2.2.1/src/metaai_api/image_upload.py +173 -0
  13. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/main.py +199 -32
  14. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/utils.py +43 -6
  15. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/video_generation.py +24 -6
  16. metaai_sdk-2.1.1/README.md → metaai_sdk-2.2.1/src/metaai_sdk.egg-info/PKG-INFO +927 -810
  17. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_sdk.egg-info/SOURCES.txt +5 -0
  18. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_sdk.egg-info/requires.txt +1 -0
  19. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/CONTRIBUTING.md +0 -0
  20. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/LICENSE +0 -0
  21. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/MANIFEST.in +0 -0
  22. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/QUICK_REFERENCE.md +0 -0
  23. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/SECURITY.md +0 -0
  24. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/VIDEO_GENERATION_README.md +0 -0
  25. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/examples/simple_example.py +0 -0
  26. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/examples/test_example.py +0 -0
  27. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/examples/video_generation.py +0 -0
  28. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/requirements.txt +0 -0
  29. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/setup.cfg +0 -0
  30. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/client.py +0 -0
  31. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_api/exceptions.py +0 -0
  32. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_sdk.egg-info/dependency_links.txt +0 -0
  33. {metaai_sdk-2.1.1 → metaai_sdk-2.2.1}/src/metaai_sdk.egg-info/top_level.txt +0 -0
@@ -5,6 +5,85 @@ All notable changes to Meta AI Python SDK will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.1.0] - 2026-01-16
9
+
10
+ ### 🎉 Image Upload & Enhanced Features
11
+
12
+ Major update adding comprehensive image upload support with analysis, generation, and video creation capabilities.
13
+
14
+ ### Added
15
+
16
+ - 📤 **Image Upload Support** - Upload images for AI processing
17
+
18
+ - New `upload_image()` method in `MetaAI` class
19
+ - `ImageUploader` class using Meta's rupload protocol
20
+ - UUID-based upload session management
21
+ - Automatic MIME type detection and file size tracking
22
+ - Returns `media_id` for use in subsequent operations
23
+
24
+ - 🔍 **Image Analysis** - Analyze and describe uploaded images
25
+
26
+ - Chat endpoint now accepts `media_ids` parameter
27
+ - Support for `attachment_metadata` (file_size, mime_type)
28
+ - Multi-step agent response parsing for detailed descriptions
29
+ - Entrypoint routing (KADABRA**DISCOVER**UNIFIED_INPUT_BAR)
30
+
31
+ - 🎨 **Similar Image Generation** - Create variations of uploaded images
32
+
33
+ - Generate similar images in different styles
34
+ - Extract URLs from `content.imagine.session.media_sets`
35
+ - Support for 4 simultaneous image generations
36
+ - Fallback URL field checking (uri, image_uri, maybe_image_uri, url)
37
+
38
+ - 🎬 **Video from Images** - Animate uploaded static images
39
+
40
+ - Video generation now accepts uploaded image media_ids
41
+ - Full `attachment_metadata` support
42
+ - Integration with existing `VideoGenerator` class
43
+
44
+ - 🔧 **Response Parser Enhancements**
45
+
46
+ - Enhanced `format_response()` for multi-step agent responses
47
+ - Updated `extract_media()` with primary/fallback location checking
48
+ - Improved `extract_data()` with Kadabra structure support
49
+ - Added support for `XFBAbraMessageMultiStepResponseContent`
50
+
51
+ - 📚 **Comprehensive Documentation**
52
+
53
+ - Complete image upload guide (`IMAGE_UPLOAD_README.md`)
54
+ - Updated quick usage guide (`QUICK_USAGE.md`)
55
+ - New complete workflow example (`examples/image_workflow_complete.py`)
56
+ - API reference with all three use cases
57
+ - Working curl and Python examples
58
+
59
+ - 🧪 **Testing & Validation**
60
+ - Comprehensive test suite (`test_endpoints.py`)
61
+ - End-to-end workflow validation
62
+ - All features tested and confirmed working
63
+
64
+ ### Changed
65
+
66
+ - ♻️ Enhanced `MetaAI.prompt()` to support image attachments
67
+ - 🔄 Updated `MetaAI.generate_video()` with image support
68
+ - 📖 Updated main README with image upload section
69
+ - 🏗️ Refactored response parsing for better structure handling
70
+ - 🎯 Improved entrypoint selection logic (ABRA vs KADABRA)
71
+
72
+ ### Fixed
73
+
74
+ - 🐛 Fixed empty responses for chat with uploaded images
75
+ - 🐛 Fixed None URLs in image generation responses
76
+ - 🐛 Fixed response parsing for Kadabra structures
77
+ - 🐛 Fixed media extraction from nested content structures
78
+
79
+ ### Technical Details
80
+
81
+ - Uses Meta's rupload protocol for image uploads
82
+ - Proper GraphQL mutation selection (useKadabraSendMessageMutation)
83
+ - Correct doc_id routing (34429318783334028 for Kadabra)
84
+ - messagePersistentInput with attachment_size (bytes) and attachment_type (MIME)
85
+ - Multi-path response parsing (Abra and Kadabra structures)
86
+
8
87
  ## [2.0.0] - 2025-11-22
9
88
 
10
89
  ### 🎉 Initial Release
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metaai-sdk
3
- Version: 2.1.1
3
+ Version: 2.2.1
4
4
  Summary: Feature-rich Python SDK for Meta AI - Chat, Image & Video Generation powered by Llama 3
5
5
  Home-page: https://github.com/mir-ashiq/metaai-api
6
6
  Author: Ashiq Hussain Mir
@@ -27,6 +27,7 @@ Requires-Dist: requests>=2.31.0
27
27
  Requires-Dist: requests-html>=0.10.0
28
28
  Requires-Dist: lxml-html-clean>=0.1.1
29
29
  Requires-Dist: beautifulsoup4>=4.9.0
30
+ Requires-Dist: python-multipart>=0.0.21
30
31
  Provides-Extra: api
31
32
  Requires-Dist: fastapi<0.96.0,>=0.95.2; extra == "api"
32
33
  Requires-Dist: uvicorn[standard]<0.24.0,>=0.22.0; extra == "api"
@@ -95,16 +96,18 @@ All in one SDK
95
96
 
96
97
  ### 🌟 Core Capabilities
97
98
 
98
- | Feature | Description | Status |
99
- | ---------------------------- | -------------------------------------------- | -------- |
100
- | 💬 **Intelligent Chat** | Powered by Llama 3 with internet access | ✅ Ready |
101
- | 🎨 **Image Generation** | Create stunning AI-generated images | ✅ Ready |
102
- | 🎬 **Video Generation** | Generate videos from text prompts | ✅ Ready |
103
- | 🌐 **Real-time Data** | Get current information via Bing integration | ✅ Ready |
104
- | 📚 **Source Citations** | Responses include verifiable sources | ✅ Ready |
105
- | 🔄 **Streaming Support** | Real-time response streaming | ✅ Ready |
106
- | 🔐 **Auto Token Management** | Automatic authentication handling | ✅ Ready |
107
- | 🌍 **Proxy Support** | Route requests through proxies | ✅ Ready |
99
+ | Feature | Description | Status |
100
+ | ---------------------------- | ------------------------------------------------ | -------- |
101
+ | 💬 **Intelligent Chat** | Powered by Llama 3 with internet access | ✅ Ready |
102
+ | 📤 **Image Upload** | Upload & analyze images, generate similar images | ✅ Ready |
103
+ | 🎨 **Image Generation** | Create stunning AI-generated images | ✅ Ready |
104
+ | 🎬 **Video Generation** | Generate videos from text or uploaded images | ✅ Ready |
105
+ | 🔍 **Image Analysis** | Describe, analyze, and extract info from images | ✅ Ready |
106
+ | 🌐 **Real-time Data** | Get current information via Bing integration | ✅ Ready |
107
+ | 📚 **Source Citations** | Responses include verifiable sources | ✅ Ready |
108
+ | 🔄 **Streaming Support** | Real-time response streaming | ✅ Ready |
109
+ | 🔐 **Auto Token Management** | Automatic authentication handling | ✅ Ready |
110
+ | 🌍 **Proxy Support** | Route requests through proxies | ✅ Ready |
108
111
 
109
112
  ---
110
113
 
@@ -333,8 +336,9 @@ uvicorn metaai_api.api_server:app --host 0.0.0.0 --port 8000
333
336
 
334
337
  | Endpoint | Method | Description |
335
338
  | ---------------------- | ------ | -------------------------------------- |
336
- | `/chat` | POST | Send chat messages |
337
- | `/image` | POST | Generate images |
339
+ | `/upload` | POST | Upload images for analysis/generation |
340
+ | `/chat` | POST | Send chat messages (with/without imgs) |
341
+ | `/image` | POST | Generate images (from text or imgs) |
338
342
  | `/video` | POST | Generate video (blocks until complete) |
339
343
  | `/video/async` | POST | Start async video generation |
340
344
  | `/video/jobs/{job_id}` | GET | Poll async job status |
@@ -516,6 +520,72 @@ if result["success"]:
516
520
 
517
521
  ---
518
522
 
523
+ ## 📤 Image Upload & Analysis
524
+
525
+ Upload images to Meta AI for analysis, similar image generation, and video creation:
526
+
527
+ ### Upload & Analyze Images
528
+
529
+ ```python
530
+ from metaai_api import MetaAI
531
+
532
+ # Initialize with Facebook cookies (required for image operations)
533
+ ai = MetaAI(cookies={
534
+ "datr": "your_datr_cookie",
535
+ "abra_sess": "your_abra_sess_cookie"
536
+ })
537
+
538
+ # Step 1: Upload an image
539
+ result = ai.upload_image("path/to/image.jpg")
540
+
541
+ if result["success"]:
542
+ media_id = result["media_id"]
543
+ metadata = {
544
+ 'file_size': result['file_size'],
545
+ 'mime_type': result['mime_type']
546
+ }
547
+
548
+ # Step 2: Analyze the image
549
+ response = ai.prompt(
550
+ message="What do you see in this image? Describe it in detail.",
551
+ media_ids=[media_id],
552
+ attachment_metadata=metadata
553
+ )
554
+ print(f"🔍 Analysis: {response['message']}")
555
+
556
+ # Step 3: Generate similar images
557
+ response = ai.prompt(
558
+ message="Create a similar image in watercolor painting style",
559
+ media_ids=[media_id],
560
+ attachment_metadata=metadata,
561
+ is_image_generation=True
562
+ )
563
+ print(f"🎨 Generated {len(response['media'])} similar images")
564
+
565
+ # Step 4: Generate video from image
566
+ video = ai.generate_video(
567
+ prompt="generate a video with zoom in effect on this image",
568
+ media_ids=[media_id],
569
+ attachment_metadata=metadata
570
+ )
571
+ if video["success"]:
572
+ print(f"🎬 Video: {video['video_urls'][0]}")
573
+ ```
574
+
575
+ **Output:**
576
+
577
+ ```
578
+ 🔍 Analysis: The image captures a serene lake scene set against a majestic mountain backdrop. In the foreground, there's a small, golden-yellow wooden boat with a bright yellow canopy floating on calm, glass‑like water...
579
+
580
+ 🎨 Generated 4 similar images
581
+
582
+ 🎬 Video: https://scontent.fsxr1-2.fna.fbcdn.net/o1/v/t6/f2/m421/video.mp4
583
+ ```
584
+
585
+ 📖 **Full Image Upload Guide:** See [IMAGE_UPLOAD_README.md](IMAGE_UPLOAD_README.md) for complete documentation!
586
+
587
+ ---
588
+
519
589
  ## 🎨 Image Generation
520
590
 
521
591
  Generate AI-powered images (requires Facebook authentication):
@@ -559,11 +629,12 @@ for i, image in enumerate(response['media'], 1):
559
629
 
560
630
  Explore working examples in the `examples/` directory:
561
631
 
562
- | File | Description | Features |
563
- | ---------------------------------------------------------- | ----------------- | --------------------------------- |
564
- | 📄 **[simple_example.py](examples/simple_example.py)** | Quick start guide | Basic chat + video generation |
565
- | 📄 **[video_generation.py](examples/video_generation.py)** | Video generation | Multiple examples, error handling |
566
- | 📄 **[test_example.py](examples/test_example.py)** | Testing suite | Validation and testing |
632
+ | File | Description | Features |
633
+ | ------------------------------------------------------------------------ | ----------------------- | -------------------------------------- |
634
+ | 📄 **[image_workflow_complete.py](examples/image_workflow_complete.py)** | Complete image workflow | Upload, analyze, generate images/video |
635
+ | 📄 **[simple_example.py](examples/simple_example.py)** | Quick start guide | Basic chat + video generation |
636
+ | 📄 **[video_generation.py](examples/video_generation.py)** | Video generation | Multiple examples, error handling |
637
+ | 📄 **[test_example.py](examples/test_example.py)** | Testing suite | Validation and testing |
567
638
 
568
639
  ### Run an Example
569
640
 
@@ -587,8 +658,10 @@ python examples/video_generation.py
587
658
 
588
659
  | Document | Description |
589
660
  | ----------------------------------------------------------- | --------------------------------------- |
661
+ | 📘 **[Image Upload Guide](IMAGE_UPLOAD_README.md)** | Complete image upload documentation |
590
662
  | 📘 **[Video Generation Guide](VIDEO_GENERATION_README.md)** | Complete video generation documentation |
591
663
  | 📙 **[Quick Reference](QUICK_REFERENCE.md)** | Fast lookup for common tasks |
664
+ | 📙 **[Quick Usage](QUICK_USAGE.md)** | Image upload quick reference |
592
665
  | 📗 **[Architecture Guide](ARCHITECTURE.md)** | Technical architecture details |
593
666
  | 📕 **[Contributing Guide](CONTRIBUTING.md)** | How to contribute to the project |
594
667
  | 📔 **[Changelog](CHANGELOG.md)** | Version history and updates |