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]]:
|
||||
try:
|
||||
results = self.results(query)
|
||||
if not results:
|
||||
msg = "No search results found for the given query."
|
||||
if results:
|
||||
return results
|
||||
|
||||
raise ToolException(msg)
|
||||
error_message = "No search results found for the given query."
|
||||
|
||||
# Process and structure the results
|
||||
return [
|
||||
{
|
||||
"label": result.get("label", ""),
|
||||
"description": result.get("description", ""),
|
||||
"concepturi": result.get("concepturi", ""),
|
||||
"id": result.get("id", ""),
|
||||
}
|
||||
for result in results
|
||||
]
|
||||
raise ToolException(error_message)
|
||||
|
||||
except Exception as e:
|
||||
error_message = f"Error in Wikidata Search API: {e!s}"
|
||||
|
|
@ -99,11 +90,7 @@ class WikidataAPIComponent(LCToolComponent):
|
|||
data = [
|
||||
Data(
|
||||
text=result["label"],
|
||||
metadata={
|
||||
"id": result["id"],
|
||||
"concepturi": result["concepturi"],
|
||||
"description": result["description"],
|
||||
},
|
||||
metadata=result,
|
||||
)
|
||||
for result in results
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue