minhvtt commited on
Commit
3900fea
·
verified ·
1 Parent(s): 500cf95

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +39 -6
main.py CHANGED
@@ -171,15 +171,31 @@ async def root():
171
  "description": "Index multiple texts and images (NEW: up to 10 each)",
172
  "content_type": "multipart/form-data",
173
  "body": {
174
- "id": "string (required) - Document ID",
175
  "texts": "List[string] (optional) - Up to 10 texts",
176
- "images": "List[UploadFile] (optional) - Up to 10 images"
 
 
177
  },
178
- "example": "curl -X POST '/index' -F 'id=doc1' -F 'texts=Text 1' -F 'texts=Text 2' -F 'images=@img1.jpg'",
179
  "response": {
180
  "success": True,
181
  "id": "doc1",
182
  "message": "Indexed successfully with 2 texts and 1 images"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
184
  },
185
  "POST /documents": {
@@ -417,20 +433,35 @@ async def root():
417
  async def index_data(
418
  id: str = Form(...),
419
  texts: Optional[List[str]] = Form(None),
420
- images: Optional[List[UploadFile]] = File(None)
 
 
421
  ):
422
  """
423
  Index data vào vector database (hỗ trợ nhiều texts và images)
424
 
425
  Body:
426
- - id: Document ID (event ID, post ID, etc.)
427
  - texts: List of text contents (tiếng Việt supported) - Tối đa 10 texts
428
  - images: List of image files (optional) - Tối đa 10 images
 
 
429
 
430
  Returns:
431
  - success: True/False
432
  - id: Document ID
433
  - message: Status message
 
 
 
 
 
 
 
 
 
 
 
434
  """
435
  try:
436
  # Validation
@@ -490,7 +521,9 @@ async def index_data(
490
  "texts": texts if texts else [],
491
  "text_count": len(texts) if texts else 0,
492
  "image_count": len(images) if images else 0,
493
- "image_filenames": [img.filename for img in images] if images else []
 
 
494
  }
495
 
496
  result = qdrant_service.index_data(
 
171
  "description": "Index multiple texts and images (NEW: up to 10 each)",
172
  "content_type": "multipart/form-data",
173
  "body": {
174
+ "id": "string (required) - Document ID (primary)",
175
  "texts": "List[string] (optional) - Up to 10 texts",
176
+ "images": "List[UploadFile] (optional) - Up to 10 images",
177
+ "id_use": "string (optional) - ID của SocialMedia hoặc EventCode",
178
+ "id_user": "string (optional) - ID của User"
179
  },
180
+ "example": "curl -X POST '/index' -F 'id=doc1' -F 'id_use=social_123' -F 'id_user=user_789' -F 'texts=Text 1' -F 'images=@img1.jpg'",
181
  "response": {
182
  "success": True,
183
  "id": "doc1",
184
  "message": "Indexed successfully with 2 texts and 1 images"
185
+ },
186
+ "use_cases": {
187
+ "social_media_post": {
188
+ "id": "post_uuid_123",
189
+ "id_use": "social_media_456",
190
+ "id_user": "user_789",
191
+ "description": "Link post to social media account and user"
192
+ },
193
+ "event_post": {
194
+ "id": "post_uuid_789",
195
+ "id_use": "event_code_ABC123",
196
+ "id_user": "user_101",
197
+ "description": "Link post to event and user"
198
+ }
199
  }
200
  },
201
  "POST /documents": {
 
433
  async def index_data(
434
  id: str = Form(...),
435
  texts: Optional[List[str]] = Form(None),
436
+ images: Optional[List[UploadFile]] = File(None),
437
+ id_use: Optional[str] = Form(None),
438
+ id_user: Optional[str] = Form(None)
439
  ):
440
  """
441
  Index data vào vector database (hỗ trợ nhiều texts và images)
442
 
443
  Body:
444
+ - id: Document ID (primary ID)
445
  - texts: List of text contents (tiếng Việt supported) - Tối đa 10 texts
446
  - images: List of image files (optional) - Tối đa 10 images
447
+ - id_use: ID của SocialMedia hoặc EventCode (optional)
448
+ - id_user: ID của User (optional)
449
 
450
  Returns:
451
  - success: True/False
452
  - id: Document ID
453
  - message: Status message
454
+
455
+ Example:
456
+ ```bash
457
+ curl -X POST '/index' \
458
+ -F 'id=doc123' \
459
+ -F 'id_use=social_media_456' \
460
+ -F 'id_user=user_789' \
461
+ -F 'texts=Post content 1' \
462
+ -F 'texts=Post content 2' \
463
+ -F 'images=@image1.jpg'
464
+ ```
465
  """
466
  try:
467
  # Validation
 
521
  "texts": texts if texts else [],
522
  "text_count": len(texts) if texts else 0,
523
  "image_count": len(images) if images else 0,
524
+ "image_filenames": [img.filename for img in images] if images else [],
525
+ "id_use": id_use if id_use else None, # ID của SocialMedia hoặc EventCode
526
+ "id_user": id_user if id_user else None # ID của User
527
  }
528
 
529
  result = qdrant_service.index_data(