Skip to content

Commit 1fd3c77

Browse files
committed
rename exa fetch tool to match other files
1 parent 688a1b0 commit 1fd3c77

File tree

5 files changed

+74
-14
lines changed

5 files changed

+74
-14
lines changed

agents/openscader/index.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Openscader
2+
description: openscader
3+
version: 0.1.0
4+
instructions: |
5+
You are a professional 3d designer, openscad user. You consult this cheatsheet often - https://openscad.org/cheatsheet/
6+
7+
<tools>
8+
{{__tools__}}
9+
</tools>
10+
11+
<system>
12+
cwd: {{__cwd__}}
13+
</system>
14+

agents/openscader/tools.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
web_search_exa.sh
2+
fetch_url_via_exa.sh
3+
fs_cat.sh
4+
fs_write.sh
5+
execute_openscad.sh

tools/execute_openscad.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# @describe Execute the openscad file.
5+
# @option --path! Path of the file to execute.
6+
7+
# @meta require-tools openscad
8+
9+
# @env LLM_OUTPUT=/dev/stdout The output path
10+
11+
ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
12+
13+
main() {
14+
openscad "$argc_path" -o /tmp/aichat_openscad.echo || true
15+
cat /tmp/aichat_openscad.echo >> "$LLM_OUTPUT"
16+
}
17+
18+
eval "$(argc --argc-eval "$0" "$@")"

tools/fetch_url_via_exa.sh

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,38 @@ set -e
1010
# @env EXA_API_KEY! The api key
1111
# @env LLM_OUTPUT=/dev/stdout The output path The output path
1212

13+
1314
main() {
14-
curl -fsS -X POST 'https://api.exa.ai/contents' \
15-
-H "x-api-key: $EXA_API_KEY" \
16-
-H 'Content-Type: application/json' \
17-
-d '{
18-
"urls": ["'"$argc_url"'"],
19-
"text": true,
20-
"livecrawlTimeout": 10000
21-
}' | \
22-
jq -r '.results[0].text' >> "$LLM_OUTPUT"
15+
# Make the API request and capture the full response
16+
response=$(curl -fsS -X POST 'https://api.exa.ai/contents' \
17+
-H "x-api-key: $EXA_API_KEY" \
18+
-H 'Content-Type: application/json' \
19+
-d '{
20+
"urls": ["'"$argc_url"'"],
21+
"text": true,
22+
"livecrawlTimeout": 10000
23+
}')
24+
25+
# Check if curl command succeeded
26+
if [ $? -ne 0 ]; then
27+
echo "Error: Failed to make API request" >> "$LLM_OUTPUT"
28+
exit 0
29+
fi
30+
31+
# Extract the status information
32+
status=$(echo "$response" | jq -r '.statuses[0].status')
33+
error_tag=$(echo "$response" | jq -r '.statuses[0].error.tag // "none"')
34+
http_status=$(echo "$response" | jq -r '.statuses[0].error.httpStatusCode // 200')
35+
36+
# Check if the status indicates an error
37+
if [ "$status" = "error" ] || [ "$http_status" != "200" ]; then
38+
echo "Error: This page is unavailable" >> "$LLM_OUTPUT"
39+
exit 0
40+
fi
41+
42+
# If successful, extract and output the text
43+
echo "$response" | jq -r '.results[0].text' >> "$LLM_OUTPUT"
2344
}
2445

2546
eval "$(argc --argc-eval "$0" "$@")"
47+

tools/web_search_exa.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ set -e
1212
# @env LLM_OUTPUT=/dev/stdout The output path The output path
1313

1414
main() {
15+
json_escaped_query=$(jq -R -s . <<< $argc_query)
1516
curl -fsS -X POST 'https://api.exa.ai/search' \
1617
-H "x-api-key: $EXA_API_KEY" \
1718
-H 'Content-Type: application/json' \
18-
-d '{
19-
"query": "'"$argc_query"'",
20-
"type": "keyword",
21-
"numResults": 20
22-
}' | \
19+
-d "{
20+
\"query\": $json_escaped_query,
21+
\"type\": \"keyword\",
22+
\"numResults\": 20
23+
}" | \
2324
jq -r '.results[] | (.title, .url, "")' >> "$LLM_OUTPUT"
2425
}
2526

0 commit comments

Comments
 (0)