feat: link web_search/code_interperter tools (#65)
This commit is contained in:
@@ -5,6 +5,8 @@ functions.json
|
|||||||
/bin
|
/bin
|
||||||
/cache
|
/cache
|
||||||
/tools/test.*
|
/tools/test.*
|
||||||
|
/tools/web_search.*
|
||||||
|
/tools/code_interpreter.*
|
||||||
/.env
|
/.env
|
||||||
__pycache__
|
__pycache__
|
||||||
/venv
|
/venv
|
||||||
|
|||||||
+29
-7
@@ -71,9 +71,6 @@ build() {
|
|||||||
# @option --names-file=tools.txt Path to a file containing tool filenames, one per line.
|
# @option --names-file=tools.txt Path to a file containing tool filenames, one per line.
|
||||||
# This file specifies which tools will be used.
|
# This file specifies which tools will be used.
|
||||||
# @option --declarations-file=functions.json <FILE> Path to a json file to save function declarations
|
# @option --declarations-file=functions.json <FILE> Path to a json file to save function declarations
|
||||||
# Example:
|
|
||||||
# get_current_weather.sh
|
|
||||||
# execute_js_code.js
|
|
||||||
# @arg tools*[`_choice_tool`] The tool filenames
|
# @arg tools*[`_choice_tool`] The tool filenames
|
||||||
build@tool() {
|
build@tool() {
|
||||||
if [[ "${#argc_tools[@]}" -gt 0 ]]; then
|
if [[ "${#argc_tools[@]}" -gt 0 ]]; then
|
||||||
@@ -184,9 +181,6 @@ generate-declarations@tool() {
|
|||||||
# @cmd Build agents
|
# @cmd Build agents
|
||||||
# @alias agent:build
|
# @alias agent:build
|
||||||
# @option --names-file=agents.txt Path to a file containing agent filenames, one per line.
|
# @option --names-file=agents.txt Path to a file containing agent filenames, one per line.
|
||||||
# Example:
|
|
||||||
# hackernews
|
|
||||||
# spotify
|
|
||||||
# @arg agents*[`_choice_agent`] The agent filenames
|
# @arg agents*[`_choice_agent`] The agent filenames
|
||||||
build@agent() {
|
build@agent() {
|
||||||
if [[ "${#argc_agents[@]}" -gt 0 ]]; then
|
if [[ "${#argc_agents[@]}" -gt 0 ]]; then
|
||||||
@@ -269,7 +263,6 @@ build-declarations@agent() {
|
|||||||
agent_dir="agents/$name"
|
agent_dir="agents/$name"
|
||||||
declarations_file="$agent_dir/functions.json"
|
declarations_file="$agent_dir/functions.json"
|
||||||
tool_names_file="$agent_dir/tools.txt"
|
tool_names_file="$agent_dir/tools.txt"
|
||||||
rm -rf "$declarations_file"
|
|
||||||
found=false
|
found=false
|
||||||
if [[ -d "$agent_dir" ]]; then
|
if [[ -d "$agent_dir" ]]; then
|
||||||
found=true
|
found=true
|
||||||
@@ -482,6 +475,24 @@ clean@agent() {
|
|||||||
_choice_agent | xargs -I{} rm -rf agents/{}/functions.json
|
_choice_agent | xargs -I{} rm -rf agents/{}/functions.json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @cmd Symlink web_search tool
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# argc link-web-search search_bing.sh
|
||||||
|
# @arg tool![`_choice_tool`] The tool work as web_search
|
||||||
|
link-web-search() {
|
||||||
|
_link_tool $1 web_search
|
||||||
|
}
|
||||||
|
|
||||||
|
# @cmd Symlink code_interpreter tool
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# argc link-code-interpreter execute_py_code.py
|
||||||
|
# @arg tool![`_choice_tool`] The tool work as code_interpreter
|
||||||
|
link-code-interpreter() {
|
||||||
|
_link_tool $1 code_interpreter
|
||||||
|
}
|
||||||
|
|
||||||
# @cmd Install this repo to aichat functions_dir
|
# @cmd Install this repo to aichat functions_dir
|
||||||
install() {
|
install() {
|
||||||
functions_dir="$(aichat --info | grep -w functions_dir | awk '{print $2}')"
|
functions_dir="$(aichat --info | grep -w functions_dir | awk '{print $2}')"
|
||||||
@@ -564,6 +575,17 @@ $run "%script_dir%scripts\run-$kind.$lang" "%script_name%" %*
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_link_tool() {
|
||||||
|
from="$1"
|
||||||
|
to="$2.${1##*.}"
|
||||||
|
rm -rf tools/$to
|
||||||
|
if _is_win; then
|
||||||
|
(cd tools && cmd <<< "mklink $to $from" > /dev/null)
|
||||||
|
else
|
||||||
|
(cd tools && ln -rs $from $to)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_ask_json_data() {
|
_ask_json_data() {
|
||||||
declaration="$1"
|
declaration="$1"
|
||||||
echo 'Missing the JSON data but here are its properties:'
|
echo 'Missing the JSON data but here are its properties:'
|
||||||
|
|||||||
Reference in New Issue
Block a user