refactor: demo agent (#81)
This commit is contained in:
+4
-3
@@ -422,15 +422,16 @@ test@agent() {
|
|||||||
# @alias agent:test-demo
|
# @alias agent:test-demo
|
||||||
test-demo@agent() {
|
test-demo@agent() {
|
||||||
echo "---- 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
|
for item in "${LANG_CMDS[@]}"; do
|
||||||
cmd="${item#*:}"
|
cmd="${item#*:}"
|
||||||
lang="${item%:*}"
|
lang="${item%:*}"
|
||||||
echo "---- Test agents/demo/tools.$lang ---"
|
echo "---- Test agents/demo/tools.$lang ---"
|
||||||
if [[ "$cmd" == "sh" ]]; then
|
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
|
elif command -v "$cmd" &> /dev/null; then
|
||||||
$cmd ./scripts/run-agent.$lang demo get_sysinfo '{}'
|
$cmd ./scripts/run-agent.$lang "${args[@]}"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
+28
-14
@@ -1,22 +1,14 @@
|
|||||||
# Demo
|
# Demo
|
||||||
|
|
||||||
This is demo agent.
|
This agent serves as a demo to guide agent development and showcase various agent capabilities.
|
||||||
|
|
||||||
## 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
|
## index.yaml
|
||||||
|
|
||||||
This document is essential as it defines the agent.
|
This file defines the agent.
|
||||||
|
|
||||||
### variables
|
### 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
|
```yaml
|
||||||
variables:
|
variables:
|
||||||
@@ -27,11 +19,23 @@ variables:
|
|||||||
default: val
|
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
|
```yaml
|
||||||
instructions: |
|
instructions: |
|
||||||
The instructions can inline {{foo}} and {{bar}} variables.
|
The instructions can inline user defined variables: {{foo}}, {{bar}} and builtin variables {{__shell__}}.
|
||||||
```
|
```
|
||||||
|
|
||||||
### documents
|
### documents
|
||||||
@@ -43,4 +47,14 @@ documents:
|
|||||||
- local-file.txt
|
- local-file.txt
|
||||||
- local-dir/
|
- local-dir/
|
||||||
- https://example.com/remote-file.txt
|
- 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.
|
description: This is demo agent.
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
instructions: |
|
instructions: |
|
||||||
You are a AI agent designed to demonstrate agent capabilities.
|
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.
|
<tools>
|
||||||
When the user asks for the current time, retrieve it by using the get_current_time tool.
|
__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:
|
variables:
|
||||||
- name: lang
|
- name: username
|
||||||
description: Your prefer language
|
description: Your user name
|
||||||
conversation_starters:
|
conversation_starters:
|
||||||
- What is the prefer language?
|
- What is my username?
|
||||||
- What is the llm-functions?
|
- What is my current shell?
|
||||||
- Show me the system info
|
- What is my ip?
|
||||||
- Tell me the current time
|
- How much disk space is left on my PC??
|
||||||
|
- How to create an agent?
|
||||||
documents:
|
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
|
* Get the system info
|
||||||
*/
|
*/
|
||||||
exports.get_sysinfo = function getSysinfo() {
|
exports.get_ipinfo = async function getIpinfo() {
|
||||||
return `OS: ${os.type()}
|
const res = await fetch("https://httpbin.org/ip")
|
||||||
Arch: ${os.arch()}`
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import os
|
import urllib.request
|
||||||
import platform
|
|
||||||
|
|
||||||
def get_sysinfo():
|
def get_ipinfo():
|
||||||
"""
|
"""
|
||||||
Get the system info
|
Get the ip info
|
||||||
"""
|
"""
|
||||||
return "\n".join([
|
with urllib.request.urlopen("https://httpbin.org/ip") as response:
|
||||||
f"OS: {platform.system()}",
|
data = response.read()
|
||||||
f"Arch: {platform.machine()}",
|
return data.decode('utf-8')
|
||||||
])
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# @cmd Get the system info
|
# @cmd Get the ip info
|
||||||
get_sysinfo() {
|
get_ipinfo() {
|
||||||
cat <<EOF >> "$LLM_OUTPUT"
|
curl -fsSL https://httpbin.org/ip >> "$LLM_OUTPUT"
|
||||||
OS: $(uname)
|
|
||||||
Arch: $(arch)
|
|
||||||
EOF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# See more details at https://github.com/sigoden/argc
|
# 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