Skip to content

Commit

Permalink
Remove try catches and replace them with default values
Browse files Browse the repository at this point in the history
  • Loading branch information
yahya-mouman committed Aug 27, 2024
1 parent 172f038 commit 600a8e1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ddtrace/llmobs/_integrations/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,10 @@ def _llmobs_set_meta_tags_from_similarity_search(
else:
documents = []
for d in output_documents:
doc = Document(text=d.page_content, id=d.id or "")
try:
doc["name"] = d.metadata["name"]
except KeyError:
log.warning("Failed to extract document name metadata from similarity search output")
doc["name"] = doc["id"]
doc = Document(text=d.page_content)
doc["id"] = getattr(d, "id", "")
metadata = getattr(d, "metadata", {})
doc["name"] = metadata.get("name", doc["id"])
documents.append(doc)
try:
span.set_tag_str(OUTPUT_DOCUMENTS, json.dumps(self.format_io(documents)))
Expand Down

0 comments on commit 600a8e1

Please sign in to comment.