mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 13:23:35 +00:00
lagchain-pinecone: add id to similarity documents results (#25630)
- **Description:** This change adds the ID field that's required in Pinecone to the result documents of the similarity search method. - **Issue:** Lack of document metadata namely the ID field - [x] **Add tests and docs**: 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. - [x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17. --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
parent
01ded5e2f9
commit
e5bb4cb646
@ -344,10 +344,13 @@ class PineconeVectorStore(VectorStore):
|
||||
)
|
||||
for res in results["matches"]:
|
||||
metadata = res["metadata"]
|
||||
id = res.get("id")
|
||||
if self._text_key in metadata:
|
||||
text = metadata.pop(self._text_key)
|
||||
score = res["score"]
|
||||
docs.append((Document(page_content=text, metadata=metadata), score))
|
||||
docs.append(
|
||||
(Document(id=id, page_content=text, metadata=metadata), score)
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
f"Found document with no `{self._text_key}` key. Skipping."
|
||||
|
Loading…
Reference in New Issue
Block a user