refactor: demo_tool.* inspect LLM_* env vars (#33)
This commit is contained in:
+37
-8
@@ -11,10 +11,10 @@ LANG_CMDS=( \
|
|||||||
"py:python" \
|
"py:python" \
|
||||||
)
|
)
|
||||||
|
|
||||||
# @cmd Call the function
|
# @cmd Run the tool
|
||||||
# @arg cmd![`_choice_cmd`] The function command
|
# @arg cmd![`_choice_cmd`] The function command
|
||||||
# @arg json The json data
|
# @arg json The json data
|
||||||
call() {
|
run-tool() {
|
||||||
if _is_win; then
|
if _is_win; then
|
||||||
ext=".cmd"
|
ext=".cmd"
|
||||||
fi
|
fi
|
||||||
@@ -128,16 +128,18 @@ list-tools() {
|
|||||||
|
|
||||||
# @cmd Test the project
|
# @cmd Test the project
|
||||||
test() {
|
test() {
|
||||||
mkdir -p tmp/tests
|
test-tools
|
||||||
names_file=tmp/tests/functions.txt
|
|
||||||
declarations_file=tmp/tests/functions.json
|
|
||||||
argc list-tools > "$names_file"
|
|
||||||
argc build --names-file "$names_file" --declarations-file "$declarations_file"
|
|
||||||
argc test-tools
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# @cmd Test call functions
|
# @cmd Test call functions
|
||||||
test-tools() {
|
test-tools() {
|
||||||
|
tmp_dir="cache/tmp"
|
||||||
|
mkdir -p "$tmp_dir"
|
||||||
|
names_file="$tmp_dir/functions.txt"
|
||||||
|
declarations_file="$tmp_dir/functions.json"
|
||||||
|
argc list-tools > "$names_file"
|
||||||
|
argc build --names-file "$names_file" --declarations-file "$declarations_file"
|
||||||
|
|
||||||
if _is_win; then
|
if _is_win; then
|
||||||
ext=".cmd"
|
ext=".cmd"
|
||||||
fi
|
fi
|
||||||
@@ -162,6 +164,33 @@ test-tools() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @cmd Test all demo tools
|
||||||
|
test-demo-tools() {
|
||||||
|
for item in "${LANG_CMDS[@]}"; do
|
||||||
|
lang="${item%:*}"
|
||||||
|
echo "---- Test demo_tool.$lang ---"
|
||||||
|
argc build-bin "demo_tool.$lang"
|
||||||
|
argc run-tool demo_tool '{
|
||||||
|
"boolean": true,
|
||||||
|
"string": "Hello",
|
||||||
|
"string_enum": "foo",
|
||||||
|
"integer": 123,
|
||||||
|
"number": 3.14,
|
||||||
|
"array": [
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c"
|
||||||
|
],
|
||||||
|
"string_optional": "OptionalValue",
|
||||||
|
"array_optional": [
|
||||||
|
"x",
|
||||||
|
"y"
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# @cmd Install this repo to aichat functions_dir
|
# @cmd Install this repo to aichat functions_dir
|
||||||
install() {
|
install() {
|
||||||
functions_dir="$(aichat --info | grep functions_dir | awk '{print $2}')"
|
functions_dir="$(aichat --info | grep functions_dir | awk '{print $2}')"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ EOF
|
|||||||
cat <<-'EOF' >> "$output"
|
cat <<-'EOF' >> "$output"
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
( set -o posix ; set ) | grep ^argc_ # inspect all argc variables
|
( set -o posix ; set ) | grep ^argc_
|
||||||
}
|
}
|
||||||
|
|
||||||
eval "$(argc --argc-eval "$0" "$@")"
|
eval "$(argc --argc-eval "$0" "$@")"
|
||||||
|
|||||||
+9
-1
@@ -12,5 +12,13 @@
|
|||||||
* @param {Args} args
|
* @param {Args} args
|
||||||
*/
|
*/
|
||||||
exports.run = function run(args) {
|
exports.run = function run(args) {
|
||||||
console.log(JSON.stringify(args, null, 2));
|
for (const [key, value] of Object.entries(args)) {
|
||||||
|
console.log(`${key}: ${JSON.stringify(value)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(process.env)) {
|
||||||
|
if (key.startsWith("LLM_")) {
|
||||||
|
console.log(`${key}: ${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-9
@@ -1,6 +1,6 @@
|
|||||||
|
import os
|
||||||
from typing import List, Literal, Optional
|
from typing import List, Literal, Optional
|
||||||
|
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
boolean: bool,
|
boolean: bool,
|
||||||
string: str,
|
string: str,
|
||||||
@@ -22,11 +22,9 @@ def run(
|
|||||||
string_optional: Define a optional string property
|
string_optional: Define a optional string property
|
||||||
array_optional: Define a optional string array property
|
array_optional: Define a optional string array property
|
||||||
"""
|
"""
|
||||||
print(f"boolean: {boolean}")
|
for key, value in locals().items():
|
||||||
print(f"string: {string}")
|
print(f"{key}: {value}")
|
||||||
print(f"string_enum: {string_enum}")
|
|
||||||
print(f"integer: {integer}")
|
for key, value in os.environ.items():
|
||||||
print(f"number: {number}")
|
if key.startswith("LLM_"):
|
||||||
print(f"array: {array}")
|
print(f"{key}: {value}")
|
||||||
print(f"string_optional: {string_optional}")
|
|
||||||
print(f"array_optional: {array_optional}")
|
|
||||||
+2
-1
@@ -9,7 +9,8 @@
|
|||||||
# @option --array-optional* Define a optional string array property
|
# @option --array-optional* Define a optional string array property
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
( set -o posix ; set ) | grep ^argc_ # inspect all argc variables
|
( set -o posix ; set ) | grep ^argc_
|
||||||
|
printenv | grep '^LLM_'
|
||||||
}
|
}
|
||||||
|
|
||||||
eval "$(argc --argc-eval "$0" "$@")"
|
eval "$(argc --argc-eval "$0" "$@")"
|
||||||
Reference in New Issue
Block a user