Skip to content

Commit

Permalink
FIX: return all attributes in wikidata (#4786)
Browse files Browse the repository at this point in the history
  • Loading branch information
erichare authored Nov 22, 2024
1 parent a06f777 commit 4ee53f2
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/backend/base/langflow/components/tools/wikidata_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,12 @@ def results(self, query: str) -> list[dict[str, Any]]:
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."

raise ToolException(msg)

# 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
]
if results:
return results

error_message = "No search results found for the given query."

raise ToolException(error_message)

except Exception as e:
error_message = f"Error in Wikidata Search API: {e!s}"
Expand Down Expand Up @@ -99,11 +90,7 @@ def run_model(self) -> list[Data]:
data = [
Data(
text=result["label"],
metadata={
"id": result["id"],
"concepturi": result["concepturi"],
"description": result["description"],
},
metadata=result,
)
for result in results
]
Expand Down

0 comments on commit 4ee53f2

Please sign in to comment.