Skip to content

Commit 768a1cb

Browse files
feat: Making content type optional in upload document (#170)
## Description Following from cohere-ai/compass#1570, making content_type optional in skd also
1 parent 381b5d2 commit 768a1cb

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

cohere_compass/clients/compass.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,10 @@ def upload_document(
631631
index_name: str,
632632
filename: str,
633633
filebytes: bytes,
634-
content_type: ContentTypeEnum,
635634
document_id: str,
636635
attributes: DocumentAttributes = DocumentAttributes(),
637636
config: ParseableDocumentConfig = ParseableDocumentConfig(),
637+
content_type: ContentTypeEnum | None = None,
638638
max_retries: int | None = None,
639639
retry_wait: timedelta | None = None,
640640
timeout: timedelta | None = None,
@@ -645,7 +645,8 @@ def upload_document(
645645
:param index_name: The name of the index.
646646
:param filename: The filename of the document.
647647
:param filebytes: The raw bytes of the document.
648-
:param content_type: The content type of the document.
648+
:param content_type: optional content type of the document.
649+
Recommended to pass it otherwise auto-detected.
649650
:param document_id: The ID to assign to the document.
650651
:param attributes: Additional attributes to add to the document.
651652
:param config: Configuration for the document parsing.

cohere_compass/clients/compass_async.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ async def upload_document(
490490
index_name: str,
491491
filename: str,
492492
filebytes: bytes,
493-
content_type: ContentTypeEnum,
494493
document_id: str,
495494
attributes: DocumentAttributes = DocumentAttributes(),
496495
config: ParseableDocumentConfig = ParseableDocumentConfig(),
496+
content_type: ContentTypeEnum | None = None,
497497
max_retries: int | None = None,
498498
retry_wait: timedelta | None = None,
499499
timeout: timedelta | None = None,
@@ -504,7 +504,8 @@ async def upload_document(
504504
:param index_name: the name of the index
505505
:param filename: the filename of the document
506506
:param filebytes: the bytes of the document
507-
:param content_type: the content type of the document
507+
:param content_type: optional content type of the document.
508+
Recommended to pass it otherwise auto-detected.
508509
:param document_id: the id of the document (optional)
509510
:param attributes: Additional attributes to add to the document.
510511
:param config: Configuration for the document parsing.

cohere_compass/models/documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class ParseableDocument(BaseModel):
300300
filename: Annotated[
301301
str, StringConstraints(min_length=1)
302302
] # Ensures the filename is a non-empty string
303-
content_type: str
303+
content_type: str | None = None
304304
content_length_bytes: PositiveInt # File size must be a non-negative integer
305305
content_encoded_bytes: str # Base64-encoded file contents
306306
attributes: DocumentAttributes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cohere-compass-sdk"
3-
version = "2.2.0"
3+
version = "2.2.1"
44
authors = []
55
description = "Cohere Compass SDK"
66
readme = "README.md"

0 commit comments

Comments
 (0)