FIX: return all attributes in wikidata (#4786)
This commit is contained in:
parent
a06f777f9c
commit
4ee53f2ea1
1 changed files with 5 additions and 18 deletions
|
|
@ -39,21 +39,12 @@ class WikidataAPIWrapper(BaseModel):
|
||||||
def run(self, query: str) -> list[dict[str, Any]]:
|
def run(self, query: str) -> list[dict[str, Any]]:
|
||||||
try:
|
try:
|
||||||
results = self.results(query)
|
results = self.results(query)
|
||||||
if not results:
|
if results:
|
||||||
msg = "No search results found for the given query."
|
return results
|
||||||
|
|
||||||
raise ToolException(msg)
|
error_message = "No search results found for the given query."
|
||||||
|
|
||||||
# Process and structure the results
|
raise ToolException(error_message)
|
||||||
return [
|
|
||||||
{
|
|
||||||
"label": result.get("label", ""),
|
|
||||||
"description": result.get("description", ""),
|
|
||||||
"concepturi": result.get("concepturi", ""),
|
|
||||||
"id": result.get("id", ""),
|
|
||||||
}
|
|
||||||
for result in results
|
|
||||||
]
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_message = f"Error in Wikidata Search API: {e!s}"
|
error_message = f"Error in Wikidata Search API: {e!s}"
|
||||||
|
|
@ -99,11 +90,7 @@ class WikidataAPIComponent(LCToolComponent):
|
||||||
data = [
|
data = [
|
||||||
Data(
|
Data(
|
||||||
text=result["label"],
|
text=result["label"],
|
||||||
metadata={
|
metadata=result,
|
||||||
"id": result["id"],
|
|
||||||
"concepturi": result["concepturi"],
|
|
||||||
"description": result["description"],
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
for result in results
|
for result in results
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue