Skip to content

Fix Exa blocks handling of empty results #10005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions autogpt_platform/backend/backend/blocks/exa/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def run(
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
data = response.json()
yield "results", data.get("results", [])
results = data.get("results", [])
if not results:
yield "error", "results are empty"
else:
yield "results", results
except Exception as e:
yield "error", str(e)
yield "results", []
8 changes: 5 additions & 3 deletions autogpt_platform/backend/backend/blocks/exa/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ def run(
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
data = response.json()
# Extract just the results array from the response
yield "results", data.get("results", [])
results = data.get("results", [])
if not results:
yield "error", "results are empty"
else:
yield "results", results
except Exception as e:
yield "error", str(e)
yield "results", []
7 changes: 5 additions & 2 deletions autogpt_platform/backend/backend/blocks/exa/similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def run(
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
data = response.json()
yield "results", data.get("results", [])
results = data.get("results", [])
if not results:
yield "error", "results are empty"
else:
yield "results", results
except Exception as e:
yield "error", str(e)
yield "results", []
Loading