refactor: demo tools/agents (#67)

This commit is contained in:
sigoden
2024-07-09 21:17:12 +08:00
committed by GitHub
parent 0dbdc9e710
commit 02e335c995
11 changed files with 116 additions and 32 deletions
+44
View File
@@ -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
```
+17
View File
@@ -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
+9
View File
@@ -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"]}`
}
+12
View File
@@ -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')}"
])
+12
View File
@@ -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" "$@")"
+1
View File
@@ -0,0 +1 @@
get_current_time.sh