Skip to content

Commit

Permalink
Merge branch 'main' into artemiy/add-asset-type-2
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiyatcohere committed Dec 13, 2024
2 parents aa35c40 + d7a896b commit 770d0a8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cohere/compass/clients/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def _send_request_with_retry():
raise CompassAuthError(message=str(e))
elif 400 <= e.response.status_code < 500:
error = f"Client error occurred: {e.response.text}"
raise CompassClientError(message=error)
raise CompassClientError(message=error, code=e.response.status_code)
else:
error = str(e) + " " + e.response.text
logger.error(
Expand Down
3 changes: 2 additions & 1 deletion cohere/compass/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class CompassClientError(Exception):
"""Exception raised for all 4xx client errors in the Compass client."""

def __init__(self, message: str = "Client error occurred."):
def __init__(self, message: str = "Client error occurred.", code: int = 400):
self.message = message
self.code = code
super().__init__(self.message)


Expand Down
13 changes: 0 additions & 13 deletions cohere/compass/models/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,7 @@ class CompassDocumentMetadata(ValidatedModel):
parent_document_id: str = ""


class AssetType(str, Enum):
def __str__(self) -> str:
return self.value

# A page that has been rendered as an image
PAGE_IMAGE = "page_image"
# A Markdown representation of a page's content
PAGE_MARKDOWN = "page_markdown"
# A dump of the text extracted from a document
DOCUMENT_TEXT = "document_text"


class CompassDocumentChunkAsset(BaseModel):
asset_type: AssetType
content_type: str
asset_data: str

Expand Down
3 changes: 0 additions & 3 deletions cohere/compass/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
# 3rd party imports
from pydantic import BaseModel

from cohere.compass.models.documents import AssetType


class AssetInfo(BaseModel):
asset_type: AssetType
content_type: str
presigned_url: str

Expand Down
42 changes: 21 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "compass-sdk"
version = "0.9.1"
version = "0.9.4"
authors = []
description = "Compass SDK"
readme = "README.md"
packages = [{include = "cohere"}]

[tool.poetry.dependencies]
fsspec = "^2024.10.0"
fsspec = ">=2024.9.0"
joblib = "1.4.2"
pydantic = ">=2.6.3"
python = ">=3.9,<4.0"
Expand Down

0 comments on commit 770d0a8

Please sign in to comment.