You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Already on GitHub?
Sign in
to your account
TypeError: sequence item 0: expected str instance, FluentValue found - Error while invoking WikidataQueryRun
#24093
TypeError: sequence item 0: expected str instance, FluentValue found - Error while invoking WikidataQueryRun
#24093
venkee70
opened this issue
Jul 10, 2024
· 4 comments
· May be fixed by
#27316
I added a very descriptive title to this issue.
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangChain rather than my code.
The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
from langchain_community.tools.wikidata.tool import WikidataAPIWrapper, WikidataQueryRun
wikidata_tool = WikidataQueryRun(api_wrapper=WikidataAPIWrapper())
wikidata_tool.name, wikidata_tool.description
File ~.virtualenvs\udemy-llm-agents-juqR4cf2\lib\site-packages\langchain_community\utilities\wikidata.py:177, in WikidataAPIWrapper.run(self, query)
175 docs = []
176 for item in items[: self.top_k_results]:
--> 177 if doc := self._item_to_document(item):
178 docs.append(f"Result {item}:\n{doc.page_content}")
179 if not docs:
File ~.virtualenvs\udemy-llm-agents-juqR4cf2\lib\site-packages\langchain_community\utilities\wikidata.py:149, in WikidataAPIWrapper._item_to_document(self, qid)
147 for prop, values in resp.statements.items():
148 if values:
--> 149 doc_lines.append(f"{prop.label}: {', '.join(values)}")
151 return Document(
152 page_content=("\n".join(doc_lines))[: self.doc_content_chars_max],
153 meta={"title": qid, "source": f"
https://www.wikidata.org/wiki/{qid}"}
,
154 )
TypeError: sequence item 0: expected str instance, FluentValue found
Description
I'm trying to use various tools from the 'langchain' library.
Call to wikidata_tool.run("string") resulted in the above error.
Hi
@venkee70
I encountered the same issue, and I discovered the root cause is an incompatible version of
wikibase-rest-api-client
.
As outlined in the documentation
here
, the required version should be below 0.2. To resolve this, you can use the following:
cc @derenrich May I ask for your advice on whether we should update the Wikidata tool to support the latest version of wikibase-rest-api-client? If so, I'd be happy to submit a PR to address this.
Hey. Yeah sorry for the delay. To bring this up to the most recent version we just need to change