aboutsummaryrefslogtreecommitdiffstats
path: root/agents/demo
diff options
context:
space:
mode:
Diffstat (limited to 'agents/demo')
-rw-r--r--agents/demo/README.md42
-rw-r--r--agents/demo/index.yaml39
-rw-r--r--agents/demo/tools.js7
-rw-r--r--agents/demo/tools.py14
-rwxr-xr-xagents/demo/tools.sh9
-rw-r--r--agents/demo/tools.txt2
6 files changed, 69 insertions, 44 deletions
diff --git a/agents/demo/README.md b/agents/demo/README.md
index d430477..ab9831d 100644
--- a/agents/demo/README.md
+++ b/agents/demo/README.md
@@ -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
-``` \ No newline at end of file
+```
+
+## 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.
diff --git a/agents/demo/index.yaml b/agents/demo/index.yaml
index ce4520f..18116b6 100644
--- a/agents/demo/index.yaml
+++ b/agents/demo/index.yaml
@@ -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 \ No newline at end of file
+ - README.md
+ - https://github.com/sigoden/llm-functions/blob/main/README.md \ No newline at end of file
diff --git a/agents/demo/tools.js b/agents/demo/tools.js
index 6a5c071..a3b141b 100644
--- a/agents/demo/tools.js
+++ b/agents/demo/tools.js
@@ -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();
}
diff --git a/agents/demo/tools.py b/agents/demo/tools.py
index ec7ca2b..be8a773 100644
--- a/agents/demo/tools.py
+++ b/agents/demo/tools.py
@@ -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()}",
- ]) \ No newline at end of file
+ with urllib.request.urlopen("https://httpbin.org/ip") as response:
+ data = response.read()
+ return data.decode('utf-8')
diff --git a/agents/demo/tools.sh b/agents/demo/tools.sh
index 98f3d47..af8ddc8 100755
--- a/agents/demo/tools.sh
+++ b/agents/demo/tools.sh
@@ -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
diff --git a/agents/demo/tools.txt b/agents/demo/tools.txt
index 35fdac3..6a1cecc 100644
--- a/agents/demo/tools.txt
+++ b/agents/demo/tools.txt
@@ -1 +1 @@
-get_current_time.sh \ No newline at end of file
+execute_command.sh \ No newline at end of file