community[patch]: Handle when documents are not provided in the Cohere response (#16144)

- **Description:** This handles the cohere response when documents
aren't included in the response
  - **Issue:** N/A
  - **Dependencies:** N/A
  - **Twitter handle:** N/A
pull/16062/head
BeatrixCohere 9 months ago committed by GitHub
parent d91126fc64
commit b0c3e3db2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,10 +17,14 @@ if TYPE_CHECKING:
def _get_docs(response: Any) -> List[Document]:
docs = [
docs = (
[]
if "documents" not in response.generation_info
else [
Document(page_content=doc["snippet"], metadata=doc)
for doc in response.generation_info["documents"]
]
)
docs.append(
Document(
page_content=response.message.content,

Loading…
Cancel
Save