aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Argcfile.sh51
-rw-r--r--README.md2
-rw-r--r--agents/demo/README.md44
-rw-r--r--agents/demo/index.yaml17
-rw-r--r--agents/demo/tools.js9
-rw-r--r--agents/demo/tools.py12
-rwxr-xr-xagents/demo/tools.sh12
-rw-r--r--agents/demo/tools.txt1
-rw-r--r--tools/demo_js.js (renamed from tools/demo_tool.js)0
-rw-r--r--tools/demo_py.py (renamed from tools/demo_tool.py)0
-rwxr-xr-xtools/demo_sh.sh (renamed from tools/demo_tool.sh)0
11 files changed, 116 insertions, 32 deletions
diff --git a/Argcfile.sh b/Argcfile.sh
index 72b9894..5a9fcce 100644
--- a/Argcfile.sh
+++ b/Argcfile.sh
@@ -289,7 +289,7 @@ build-declarations@agent() {
fi
if [[ "$ok" == "true" ]]; then
if [[ -n "$agent_json_data" ]] && [[ -n "$tools_json_data" ]]; then
- json_data="$(jq -s '.[0] + .[1]' <(echo "$agent_json_data") <(echo "$tools_json_data"))"
+ json_data="$(echo "[$agent_json_data,$tools_json_data]" | jq 'flatten')"
elif [[ -n "$agent_json_data" ]]; then
json_data="$agent_json_data"
elif [[ -n "$tools_json_data" ]]; then
@@ -397,9 +397,10 @@ test-execute-code-tools() {
test-demo-tools() {
for item in "${LANG_CMDS[@]}"; do
lang="${item%:*}"
- echo "---- Test demo_tool.$lang ---"
- argc build-bin@tool "demo_tool.$lang"
- argc run@tool demo_tool '{
+ tool="demo_$lang.$lang"
+ echo "---- Test $tool ---"
+ argc build-bin@tool "$tool"
+ argc run@tool $tool '{
"boolean": true,
"string": "Hello",
"string_enum": "foo",
@@ -428,37 +429,24 @@ test@agent() {
names_file="$tmp_dir/agents.txt"
argc list@agent > "$names_file"
argc build@agent --names-file "$names_file"
- test-todo-agents
+ test-demo-agents
}
-# @cmd Test todo-* agents
-# @alias agent:test-todo
-test-todo-agents() {
- if _is_win; then
- ext=".cmd"
- fi
- test_cases=( \
- 'add_todo#{"desc":"Add a todo item"}' \
- 'add_todo#{"desc":"Add another todo item"}' \
- 'del_todo#{"id":1}' \
- 'list_todos#{}' \
- 'clear_todos#{}' \
- )
+# @cmd Test demo agents
+# @alias agent:test-demo
+test-demo-agents() {
+ echo "Test demo agent:"
+ argc run@agent demo get_sysinfo '{}'
for item in "${LANG_CMDS[@]}"; do
cmd="${item#*:}"
- if command -v "$cmd" &> /dev/null; then
- lang="${item%:*}"
- agent_name="todo-$lang"
- rm -rf "cache/$agent_name/todos.json"
- for test_case in "${test_cases[@]}"; do
- IFS='#' read -r action data <<<"${test_case}"
- cmd_path="$BIN_DIR/$agent_name$ext"
- echo "Test $cmd_path: "
- "$cmd_path" "$action" "$data"
- done
+ lang="${item%:*}"
+ echo "Test agents/demo/tools.$lang:"
+ if [[ "$cmd" == "sh" ]]; then
+ "$(argc --argc-shell-path)" ./scripts/run-agent.sh demo get_sysinfo '{}'
+ elif command -v "$cmd" &> /dev/null; then
+ $cmd ./scripts/run-agent.$lang demo get_sysinfo '{}'
fi
done
-
}
# @cmd Clean tools
@@ -475,7 +463,7 @@ clean@agent() {
_choice_agent | xargs -I{} rm -rf agents/{}/functions.json
}
-# @cmd Symlink web_search tool
+# @cmd Link a tool as web_search tool
#
# Example:
# argc link-web-search search_bing.sh
@@ -484,7 +472,7 @@ link-web-search() {
_link_tool $1 web_search
}
-# @cmd Symlink code_interpreter tool
+# @cmd Link a tool as code_interpreter tool
#
# Example:
# argc link-code-interpreter execute_py_code.py
@@ -550,6 +538,7 @@ _get_agent_tools_path() {
entry_file="agents/$name/tools.$lang"
if [[ -f "agents/$name/tools.$lang" ]]; then
echo "$entry_file"
+ break
fi
done
}
diff --git a/README.md b/README.md
index 10a6656..cccf5f5 100644
--- a/README.md
+++ b/README.md
@@ -134,7 +134,7 @@ The agent definition file (`index.yaml`) defines crucial aspects of your agent:
```yaml
name: TestAgent
description: This is test agent
-version: v0.1.0
+version: 0.1.0
instructions: You are a test ai agent to ...
conversation_starters:
- What can you do?
diff --git a/agents/demo/README.md b/agents/demo/README.md
new file mode 100644
index 0000000..888b236
--- /dev/null
+++ b/agents/demo/README.md
@@ -0,0 +1,44 @@
+# Demo
+
+This is demo agent.
+
+## tools.{sh,js,py}
+
+You only need one of the `tools.sh`, `tools.js`, or `tools.py` files. All three are provided so that everyone can understand how to implement the tools in each language.
+
+## tools.txt
+
+The `tools.txt` is used to reuse the tools in the `tools/` directory.
+
+## index.yaml
+
+This document is essential as it defines the agent.
+
+### variables
+
+Variables are generally used to record a certain behavior or preference of a user.
+
+```yaml
+variables:
+ - name: foo
+ description: This is a foo
+ - name: bar
+ description: This is a bar with default value
+ default: val
+```
+
+Variables can be used in the `instructions`.
+
+```yaml
+instructions: |
+ The instructions can inline {{foo}} and {{bar}} variables.
+```
+
+### documents
+
+Documents are used for RAG.
+
+```yaml
+documents:
+ - https://raw.githubusercontent.com/sigoden/llm-functions/main/README.md
+``` \ No newline at end of file
diff --git a/agents/demo/index.yaml b/agents/demo/index.yaml
new file mode 100644
index 0000000..44cd616
--- /dev/null
+++ b/agents/demo/index.yaml
@@ -0,0 +1,17 @@
+name: Demo
+description: This is demo agent.
+version: 0.1.0
+instructions: |
+ You are a AI agent designed to demonstrate agent capabilities.
+ Use prefer language {{lang}} to answer the question, regardless of the input language.
+ When the user asks for the system info, retrieve it by running the get_sysinfo tool.
+ When the user asks for the current time, retrieve it by using the get_current_time tool.
+variables:
+ - name: lang
+ description: Your prefer language
+conversation_starters:
+ - What is the prefer language
+ - Show me the system info
+ - Tell me the current time
+documents:
+ - https://raw.githubusercontent.com/sigoden/llm-functions/main/README.md \ No newline at end of file
diff --git a/agents/demo/tools.js b/agents/demo/tools.js
new file mode 100644
index 0000000..37f8937
--- /dev/null
+++ b/agents/demo/tools.js
@@ -0,0 +1,9 @@
+const os = require("node:os");
+/**
+ * Get the system info
+ */
+exports.get_sysinfo = function getSysinfo() {
+ return `OS: ${os.type()}
+Arch: ${os.arch()}
+User: ${process.env["USER"]}`
+}
diff --git a/agents/demo/tools.py b/agents/demo/tools.py
new file mode 100644
index 0000000..5f1a4fc
--- /dev/null
+++ b/agents/demo/tools.py
@@ -0,0 +1,12 @@
+import os
+import platform
+
+def get_sysinfo():
+ """
+ Get the system info
+ """
+ return "\n".join([
+ f"OS: {platform.system()}",
+ f"Arch: {platform.machine()}",
+ f"User: {os.environ.get('USER')}"
+ ]) \ No newline at end of file
diff --git a/agents/demo/tools.sh b/agents/demo/tools.sh
new file mode 100755
index 0000000..4b5849b
--- /dev/null
+++ b/agents/demo/tools.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+set -e
+
+# @cmd Get the system info
+get_sysinfo() {
+ echo "OS: $(uname)"
+ echo "Arch: $(arch)"
+ echo "User: $USER"
+}
+
+# See more details at https://github.com/sigoden/argc
+eval "$(argc --argc-eval "$0" "$@")"
diff --git a/agents/demo/tools.txt b/agents/demo/tools.txt
new file mode 100644
index 0000000..35fdac3
--- /dev/null
+++ b/agents/demo/tools.txt
@@ -0,0 +1 @@
+get_current_time.sh \ No newline at end of file
diff --git a/tools/demo_tool.js b/tools/demo_js.js
index c8b7237..c8b7237 100644
--- a/tools/demo_tool.js
+++ b/tools/demo_js.js
diff --git a/tools/demo_tool.py b/tools/demo_py.py
index d53cd0b..d53cd0b 100644
--- a/tools/demo_tool.py
+++ b/tools/demo_py.py
diff --git a/tools/demo_tool.sh b/tools/demo_sh.sh
index da35e8f..da35e8f 100755
--- a/tools/demo_tool.sh
+++ b/tools/demo_sh.sh