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]:
|
def _get_docs(response: Any) -> List[Document]:
|
||||||
docs = [
|
docs = (
|
||||||
|
[]
|
||||||
|
if "documents" not in response.generation_info
|
||||||
|
else [
|
||||||
Document(page_content=doc["snippet"], metadata=doc)
|
Document(page_content=doc["snippet"], metadata=doc)
|
||||||
for doc in response.generation_info["documents"]
|
for doc in response.generation_info["documents"]
|
||||||
]
|
]
|
||||||
|
)
|
||||||
docs.append(
|
docs.append(
|
||||||
Document(
|
Document(
|
||||||
page_content=response.message.content,
|
page_content=response.message.content,
|
||||||
|
Loading…
Reference in New Issue
Block a user