Skip to content

Commit

Permalink
fix: data source error message
Browse files Browse the repository at this point in the history
  • Loading branch information
levanion committed Mar 20, 2024
1 parent cc5fe72 commit 4e71efd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
13 changes: 9 additions & 4 deletions apps/server/controllers/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,19 @@ def index_documents(value: str, datasource_id: UUID, account: AccountOutput):
similarity_top_k,
)
retriever.index_documents(file_urls)

datasource.status = DatasourceStatus.READY.value
datasource.error = None

except Exception as err:
print(err)
sentry_sdk.capture_exception(err)
datasource.status = DatasourceStatus.FAILED.value
datasource.error = str(err)
try:
error_body = json.loads(err.body)
error_message = error_body.get("error", {}).get("message", "")
print("HERE: ", error_message)
datasource.error = str(error_message)
except (AttributeError, json.JSONDecodeError):
sentry_sdk.capture_exception(err)
datasource.error = str(err)

session.add(datasource)
session.commit()
Expand Down
15 changes: 6 additions & 9 deletions apps/server/datasources/file/file_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,12 @@ def get_vector_store(self, is_retriever: bool = False):
)

if not is_retriever:
try:
pc.create_index(
index_name,
dimension=1536,
metric="cosine",
spec=ServerlessSpec(cloud="aws", region="us-west-2"),
)
except Exception as err:
print("PINE ERROR:", err)
pc.create_index(
index_name,
dimension=1536,
metric="cosine",
spec=ServerlessSpec(cloud="aws", region="us-west-2"),
)

pinecone_index = pc.Index(index_name)

Expand Down

0 comments on commit 4e71efd

Please sign in to comment.