mirror of
https://github.com/hwchase17/langchain
synced 2024-11-18 09:25:54 +00:00
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
This commit is contained in:
parent
d91126fc64
commit
b0c3e3db2b
@ -17,10 +17,14 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def _get_docs(response: Any) -> List[Document]:
|
||||
docs = [
|
||||
Document(page_content=doc["snippet"], metadata=doc)
|
||||
for doc in response.generation_info["documents"]
|
||||
]
|
||||
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…
Reference in New Issue
Block a user