diff --git a/docs/docs/integrations/tools/wikidata.ipynb b/docs/docs/integrations/tools/wikidata.ipynb index f316108b80a13..8ec1d88e3acdf 100644 --- a/docs/docs/integrations/tools/wikidata.ipynb +++ b/docs/docs/integrations/tools/wikidata.ipynb @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3d9195d4", + "id": "d622c581", "metadata": { "vscode": { "languageId": "shellscript" @@ -23,7 +23,7 @@ }, "outputs": [], "source": [ - "%pip install --upgrade --quiet \"wikibase-rest-api-client<0.2\" mediawikiapi" + "%pip install --upgrade --quiet wikibase-rest-api-client mediawikiapi" ] }, { @@ -110,7 +110,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.5" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/libs/community/langchain_community/utilities/wikidata.py b/libs/community/langchain_community/utilities/wikidata.py index 3b2d877766200..4e2e3c0697750 100644 --- a/libs/community/langchain_community/utilities/wikidata.py +++ b/libs/community/langchain_community/utilities/wikidata.py @@ -147,7 +147,9 @@ def _item_to_document(self, qid: str) -> Optional[Document]: doc_lines.append(f"Aliases: {', '.join(resp.aliases)}") for prop, values in resp.statements.items(): if values: - doc_lines.append(f"{prop.label}: {', '.join(values)}") + doc_lines.append( + f"{prop.label}: {', '.join([v.value or 'unknown' for v in values])}" + ) return Document( page_content=("\n".join(doc_lines))[: self.doc_content_chars_max],