refactor: demo agent (#81)
This commit is contained in:
+4
-3
@@ -422,15 +422,16 @@ test@agent() {
|
||||
# @alias agent:test-demo
|
||||
test-demo@agent() {
|
||||
echo "---- Test demo agent ---"
|
||||
argc run@agent demo get_sysinfo '{}'
|
||||
args=(demo get_ipinfo '{}')
|
||||
argc run@agent "${args[@]}"
|
||||
for item in "${LANG_CMDS[@]}"; do
|
||||
cmd="${item#*:}"
|
||||
lang="${item%:*}"
|
||||
echo "---- Test agents/demo/tools.$lang ---"
|
||||
if [[ "$cmd" == "sh" ]]; then
|
||||
"$(argc --argc-shell-path)" ./scripts/run-agent.sh demo get_sysinfo '{}'
|
||||
"$(argc --argc-shell-path)" ./scripts/run-agent.sh "${args[@]}"
|
||||
elif command -v "$cmd" &> /dev/null; then
|
||||
$cmd ./scripts/run-agent.$lang demo get_sysinfo '{}'
|
||||
$cmd ./scripts/run-agent.$lang "${args[@]}"
|
||||
echo
|
||||
fi
|
||||
done
|
||||
|
||||
+28
-14
@@ -1,22 +1,14 @@
|
||||
# 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.
|
||||
This agent serves as a demo to guide agent development and showcase various agent capabilities.
|
||||
|
||||
## index.yaml
|
||||
|
||||
This document is essential as it defines the agent.
|
||||
This file defines the agent.
|
||||
|
||||
### variables
|
||||
|
||||
Variables are generally used to record a certain behavior or preference of a user.
|
||||
Variables are generally used to store information about a user's behavior or preferences.
|
||||
|
||||
```yaml
|
||||
variables:
|
||||
@@ -27,11 +19,23 @@ variables:
|
||||
default: val
|
||||
```
|
||||
|
||||
Variables can be used in the `instructions`.
|
||||
When use define variables, please avoid these built-in variables:
|
||||
|
||||
| name | description | example |
|
||||
| :------------ | :-------------------------------------------- | :----------------------- |
|
||||
| __os__ | Operating system name | linux |
|
||||
| __os_family__ | Operating system family | unix |
|
||||
| __arch__ | System architecture | x86_64 |
|
||||
| __shell__ | Current user's default shell | bash |
|
||||
| __locale__ | User's preferred language and region settings | en-US |
|
||||
| __now__ | Current timestamp in ISO 8601 format | 2024-07-29T08:11:24.367Z |
|
||||
| __cwd__ | Current working directory | /tmp |
|
||||
|
||||
Variables should be used in the `instructions` field.
|
||||
|
||||
```yaml
|
||||
instructions: |
|
||||
The instructions can inline {{foo}} and {{bar}} variables.
|
||||
The instructions can inline user defined variables: {{foo}}, {{bar}} and builtin variables {{__shell__}}.
|
||||
```
|
||||
|
||||
### documents
|
||||
@@ -43,4 +47,14 @@ documents:
|
||||
- local-file.txt
|
||||
- local-dir/
|
||||
- https://example.com/remote-file.txt
|
||||
```
|
||||
```
|
||||
|
||||
## tools.{sh,js,py}
|
||||
|
||||
The tool script implements agent-specific tools.
|
||||
|
||||
> You only need one of the `tools.sh`, `tools.js`, or `tools.py`.
|
||||
|
||||
## tools.txt
|
||||
|
||||
The `tools.txt` file enables tool reuse from the `/tools` folder in this project.
|
||||
|
||||
+28
-11
@@ -2,17 +2,34 @@ 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.
|
||||
You are a AI agent designed to demonstrate agent capabilities.
|
||||
|
||||
<tools>
|
||||
__TOOLS__
|
||||
</tools>
|
||||
|
||||
<system>
|
||||
os: {{__os__}}
|
||||
os_family: {{__os_family__}}
|
||||
arch: {{__arch__}}
|
||||
shell: {{__shell__}}
|
||||
locale: {{__locale__}}
|
||||
now: {{__now__}}
|
||||
cwd: {{__cwd__}}
|
||||
</system>
|
||||
|
||||
<user>
|
||||
username: {{username}}
|
||||
</user>
|
||||
variables:
|
||||
- name: lang
|
||||
description: Your prefer language
|
||||
- name: username
|
||||
description: Your user name
|
||||
conversation_starters:
|
||||
- What is the prefer language?
|
||||
- What is the llm-functions?
|
||||
- Show me the system info
|
||||
- Tell me the current time
|
||||
- What is my username?
|
||||
- What is my current shell?
|
||||
- What is my ip?
|
||||
- How much disk space is left on my PC??
|
||||
- How to create an agent?
|
||||
documents:
|
||||
- https://raw.githubusercontent.com/sigoden/llm-functions/main/README.md
|
||||
- README.md
|
||||
- https://github.com/sigoden/llm-functions/blob/main/README.md
|
||||
@@ -1,8 +1,7 @@
|
||||
const os = require("node:os");
|
||||
/**
|
||||
* Get the system info
|
||||
*/
|
||||
exports.get_sysinfo = function getSysinfo() {
|
||||
return `OS: ${os.type()}
|
||||
Arch: ${os.arch()}`
|
||||
exports.get_ipinfo = async function getIpinfo() {
|
||||
const res = await fetch("https://httpbin.org/ip")
|
||||
return res.json();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import os
|
||||
import platform
|
||||
import urllib.request
|
||||
|
||||
def get_sysinfo():
|
||||
def get_ipinfo():
|
||||
"""
|
||||
Get the system info
|
||||
Get the ip info
|
||||
"""
|
||||
return "\n".join([
|
||||
f"OS: {platform.system()}",
|
||||
f"Arch: {platform.machine()}",
|
||||
])
|
||||
with urllib.request.urlopen("https://httpbin.org/ip") as response:
|
||||
data = response.read()
|
||||
return data.decode('utf-8')
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# @cmd Get the system info
|
||||
get_sysinfo() {
|
||||
cat <<EOF >> "$LLM_OUTPUT"
|
||||
OS: $(uname)
|
||||
Arch: $(arch)
|
||||
EOF
|
||||
# @cmd Get the ip info
|
||||
get_ipinfo() {
|
||||
curl -fsSL https://httpbin.org/ip >> "$LLM_OUTPUT"
|
||||
}
|
||||
|
||||
# See more details at https://github.com/sigoden/argc
|
||||
|
||||
@@ -1 +1 @@
|
||||
get_current_time.sh
|
||||
execute_command.sh
|
||||
Reference in New Issue
Block a user