-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: thxCode <[email protected]>
- Loading branch information
Showing
7 changed files
with
384 additions
and
200 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# MIT license | ||
# Copyright (c) 2024 llama-box authors | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
function get_location() { | ||
ARGS="${1}" | ||
ID="${2}" | ||
|
||
LOCATION="$(curl -s https://wttr.in/?format="%l")" | ||
|
||
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"location\\\":\\\"${LOCATION}\\\"}\",\"tool_call_id\":\"${ID}\"}" | ||
echo "${MESSAGE}" | ||
} | ||
|
||
function register_tool_get_location() { | ||
TOOLNAMES+=("get_location") | ||
TOOLS+=("{\"type\":\"function\",\"function\":{\"name\":\"get_location\",\"description\":\"Return the location without any arguments.\",\"parameters\":{\"type\":\"object\",\"properties\":{},\"required\":[]}}}") | ||
} | ||
|
||
register_tool_get_location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# MIT license | ||
# Copyright (c) 2024 llama-box authors | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
function get_temperature() { | ||
ARGS="${1}" | ||
ID="${2}" | ||
|
||
LOCATION=$(echo "${ARGS}" | jq -cr '.location') | ||
TEMPERATURE="$(curl -s https://wttr.in/"${LOCATION}"?format="%t")" | ||
|
||
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"temperature\\\":\\\"${TEMPERATURE%%°C}\\\"}\",\"tool_call_id\":\"${ID}\"}" | ||
echo "${MESSAGE}" | ||
} | ||
|
||
function register_tool_get_temperature() { | ||
TOOLNAMES+=("get_temperature") | ||
TOOLS+=("{\"type\":\"function\",\"function\":{\"name\":\"get_temperature\",\"description\":\"Return the degrees Celsius temperature value of the given location.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"location\":{\"type\":\"string\"}},\"required\":[\"location\"]}}}") | ||
} | ||
|
||
register_tool_get_temperature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# MIT license | ||
# Copyright (c) 2024 llama-box authors | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
function get_weather() { | ||
ARGS="${1}" | ||
ID="${2}" | ||
|
||
LOCATION=$(echo "${ARGS}" | jq -cr '.location') | ||
WEATHER="$(curl -s https://wttr.in/"${LOCATION}"?format="%C")" | ||
|
||
MESSAGE="{\"role\":\"tool\",\"content\":\"{\\\"weather\\\":\\\"${WEATHER}\\\"}\",\"tool_call_id\":\"${ID}\"}" | ||
echo "${MESSAGE}" | ||
} | ||
|
||
function register_tool_get_weather() { | ||
TOOLNAMES+=("get_weather") | ||
TOOLS+=("{\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"description\":\"Return the weather by the given location.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"location\":{\"type\":\"string\"}},\"required\":[\"location\"]}}}") | ||
} | ||
|
||
register_tool_get_weather |
Oops, something went wrong.