community[patch]: Correct the calling to collection_name in qdrant (#16920)

## Description

In #16608, the calling `collection_name` was wrong.
I made a fix for it. 
Sorry for the inconvenience!

## Issue

https://github.com/langchain-ai/langchain/issues/16962

## Dependencies

N/A



<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is
whichever of langchain, community, core, experimental, etc. is being
modified.

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes if applicable,
  - **Dependencies:** any dependencies required for this change,
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` from the root
of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc: https://python.langchain.com/docs/contributing/

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->

---------

Co-authored-by: Kumar Shivendu <kshivendu1@gmail.com>
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
Killinsun - Ryota Takeuchi
2024-02-05 03:45:35 +09:00
committed by GitHub
parent 849051102a
commit bcfce146d8
10 changed files with 123 additions and 52 deletions

View File

@@ -620,7 +620,10 @@ class Qdrant(VectorStore):
return [
(
self._document_from_scored_point(
result, self.content_payload_key, self.metadata_payload_key
result,
self.collection_name,
self.content_payload_key,
self.metadata_payload_key,
),
result.score,
)
@@ -713,7 +716,10 @@ class Qdrant(VectorStore):
return [
(
self._document_from_scored_point(
result, self.content_payload_key, self.metadata_payload_key
result,
self.collection_name,
self.content_payload_key,
self.metadata_payload_key,
),
result.score,
)
@@ -1051,7 +1057,10 @@ class Qdrant(VectorStore):
return [
(
self._document_from_scored_point(
results[i], self.content_payload_key, self.metadata_payload_key
results[i],
self.collection_name,
self.content_payload_key,
self.metadata_payload_key,
),
results[i].score,
)
@@ -1123,7 +1132,10 @@ class Qdrant(VectorStore):
return [
(
self._document_from_scored_point(
results[i], self.content_payload_key, self.metadata_payload_key
results[i],
self.collection_name,
self.content_payload_key,
self.metadata_payload_key,
),
results[i].score,
)
@@ -1938,12 +1950,13 @@ class Qdrant(VectorStore):
def _document_from_scored_point(
cls,
scored_point: Any,
collection_name: str,
content_payload_key: str,
metadata_payload_key: str,
) -> Document:
metadata = scored_point.payload.get(metadata_payload_key) or {}
metadata["_id"] = scored_point.id
metadata["_collection_name"] = scored_point.collection_name
metadata["_collection_name"] = collection_name
return Document(
page_content=scored_point.payload.get(content_payload_key),
metadata=metadata,