feat: rename functions.txt to tools.txt (#35)
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/tmp
|
/tmp
|
||||||
functions.txt
|
tools.txt
|
||||||
functions.json
|
functions.json
|
||||||
/bin
|
/bin
|
||||||
/cache
|
/cache
|
||||||
|
|||||||
+6
-6
@@ -28,7 +28,7 @@ build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @cmd Build tools
|
# @cmd Build tools
|
||||||
# @option --names-file=functions.txt Path to a file containing tool filenames, one per line.
|
# @option --names-file=tools.txt Path to a file containing tool filenames, one per line.
|
||||||
# This file specifies which tools will be used.
|
# This file specifies which tools will be used.
|
||||||
# @option --declarations-file=functions.json <FILE> Path to a json file to save function declarations
|
# @option --declarations-file=functions.json <FILE> Path to a json file to save function declarations
|
||||||
# Example:
|
# Example:
|
||||||
@@ -40,7 +40,7 @@ build-tools() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @cmd Build tools to bin
|
# @cmd Build tools to bin
|
||||||
# @option --names-file=functions.txt Path to a file containing tool filenames, one per line.
|
# @option --names-file=tools.txt Path to a file containing tool filenames, one per line.
|
||||||
# @arg tools*[`_choice_tool`] The tool filenames
|
# @arg tools*[`_choice_tool`] The tool filenames
|
||||||
build-tools-bin() {
|
build-tools-bin() {
|
||||||
mkdir -p "$BIN_DIR"
|
mkdir -p "$BIN_DIR"
|
||||||
@@ -79,7 +79,7 @@ build-tools-bin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @cmd Build tool functions.json
|
# @cmd Build tool functions.json
|
||||||
# @option --names-file=functions.txt Path to a file containing tool filenames, one per line.
|
# @option --names-file=tools.txt Path to a file containing tool filenames, one per line.
|
||||||
# @option --declarations-file=functions.json <FILE> Path to a json file to save function declarations
|
# @option --declarations-file=functions.json <FILE> Path to a json file to save function declarations
|
||||||
# @arg tools*[`_choice_tool`] The tool filenames
|
# @arg tools*[`_choice_tool`] The tool filenames
|
||||||
build-tools-json() {
|
build-tools-json() {
|
||||||
@@ -125,9 +125,9 @@ build-tool-declaration() {
|
|||||||
"$cmd" "scripts/build-declarations.$lang" "tools/$1" | jq '.[0]'
|
"$cmd" "scripts/build-declarations.$lang" "tools/$1" | jq '.[0]'
|
||||||
}
|
}
|
||||||
|
|
||||||
# @cmd List tools that can be put into functions.txt
|
# @cmd List tools that can be put into tools.txt
|
||||||
# Examples:
|
# Examples:
|
||||||
# argc list-tools > functions.txt
|
# argc list-tools > tools.txt
|
||||||
list-tools() {
|
list-tools() {
|
||||||
_choice_tool
|
_choice_tool
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ test() {
|
|||||||
test-tools() {
|
test-tools() {
|
||||||
tmp_dir="cache/tmp"
|
tmp_dir="cache/tmp"
|
||||||
mkdir -p "$tmp_dir"
|
mkdir -p "$tmp_dir"
|
||||||
names_file="$tmp_dir/functions.txt"
|
names_file="$tmp_dir/tools.txt"
|
||||||
declarations_file="$tmp_dir/functions.json"
|
declarations_file="$tmp_dir/functions.json"
|
||||||
argc list-tools > "$names_file"
|
argc list-tools > "$names_file"
|
||||||
argc build-tools --names-file "$names_file" --declarations-file "$declarations_file"
|
argc build-tools --names-file "$names_file" --declarations-file "$declarations_file"
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ git clone https://github.com/sigoden/llm-functions
|
|||||||
|
|
||||||
**2. Build function declarations file and bin dir:**
|
**2. Build function declarations file and bin dir:**
|
||||||
|
|
||||||
First, create a `./functions.txt` file with each function name on a new line.
|
First, create a `./tools.txt` file with each tool name on a new line.
|
||||||
|
|
||||||
Then, run `argc build` to build function declarations file `./functions.json` and bin dir `./bin/`.
|
Then, run `argc build` to build declarations file (`./functions.json`) and binaries dir (`./bin/`).
|
||||||
|
|
||||||
**3. Configure your AIChat:**
|
**3. Configure your AIChat:**
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ Don't forget to add the following config to your AIChat `config.yaml` file:
|
|||||||
function_calling: true
|
function_calling: true
|
||||||
```
|
```
|
||||||
|
|
||||||
AIChat will automatically load `functions.json` and execute functions located in the `./bin` directory based on your prompts.
|
AIChat will automatically load `functions.json` and execute commands located in the `./bin` directory based on your prompts.
|
||||||
|
|
||||||
**4. Start using your functions:**
|
**4. Start using your functions:**
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ AIChat will ask permission before running the function.
|
|||||||
|
|
||||||
You can write functions in bash/javascript/python.
|
You can write functions in bash/javascript/python.
|
||||||
|
|
||||||
`llm-functions` will automatic generate function declarations from comments. Refer to `demo_tool.{sh,js,py}` for examples of how to use comments for autogeneration of declarations.
|
`llm-functions` will automatic generate function declarations from comments. Refer to `tools/demo_tool.{sh,js,py}` for examples of how to use comments for autogeneration of declarations.
|
||||||
|
|
||||||
### Bash
|
### Bash
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ function loadEnv(filePath) {
|
|||||||
|
|
||||||
async function run(toolPath, toolFunc, toolData) {
|
async function run(toolPath, toolFunc, toolData) {
|
||||||
let mod;
|
let mod;
|
||||||
if (os.platform() === "win32") {
|
if (os.platform() === "win32") {
|
||||||
toolPath = `file://${toolPath}`;
|
toolPath = `file://${toolPath}`;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user