-
Notifications
You must be signed in to change notification settings - Fork 0
Support Anura API #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4d5cfa7
refactor input
DevlinRocha ca14097
bump version
DevlinRocha ef00cd8
change to request
DevlinRocha 243c378
bump version
DevlinRocha 243ffee
move version bump
DevlinRocha 87067b9
remove workingdirectory
DevlinRocha 52d2e85
bump version
DevlinRocha eafb9df
update example command
DevlinRocha fd12604
bump version
DevlinRocha 5d1b4ec
add `system` message to example; update options parameters
DevlinRocha 945d755
bump version
DevlinRocha f223edb
add back `formatted_response`
DevlinRocha 43e507e
bump version
DevlinRocha 70f7942
update CLI command
DevlinRocha 0747853
change tense
DevlinRocha 4638b01
fix run command
DevlinRocha 54c352a
add `-l` as valid `--local` flag
DevlinRocha ae2ea97
uniform language
DevlinRocha 1bb38c5
fix typo
DevlinRocha 961a3d7
fix errors
DevlinRocha 2d01db2
fix run
DevlinRocha 3689021
remove debug echo
DevlinRocha 8051a13
bump version
DevlinRocha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,39 +1,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ $# -lt 1 ] || [ $# -gt 2 ]; then | ||
echo "Usage: scripts/run [--local] <input>" | ||
echo "Example: scripts/run 'What animal order do frogs belong to?'" | ||
exit 1 | ||
fi | ||
CONFIG_FILE=".env" | ||
source $CONFIG_FILE | ||
|
||
if [ $1 == "--local" ] || [ $1 == "-l" ]; then | ||
if [ $# -ne 2 ]; then | ||
echo "❌ Error: Input is required." | ||
echo "Example: scripts/run --local 'What animal order do frogs belong to?'" | ||
exit 1 | ||
function request { | ||
if ! printenv | grep -q "WEB3_PRIVATE_KEY=."; then | ||
printf "Enter your wallet private key: " | ||
read -r private_key | ||
WEB3_PRIVATE_KEY=$private_key | ||
fi | ||
echo "Running the Lilypad module Docker image locally..." | ||
local=true | ||
INPUT=$2 | ||
echo "Copy the JSON below to form your request:" | ||
printf ' | ||
"messages": [{ | ||
"role": "system", | ||
"content": "you are a helpful AI assistant" | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "what is the animal order of the frog?" | ||
}], | ||
"options": { | ||
"temperature": 1.0 | ||
} | ||
' | ||
printf "\n(Paste JSON as one line) ➔ " | ||
read -r request | ||
request="{"model": $MODEL_NAME:$MODEL_VERSION, $request, "stream": false}" | ||
} | ||
DevlinRocha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ $# -gt 2 ]; then | ||
echo "Usage: scripts/run [--local] <request>" | ||
echo "Example: scripts/run 'What animal order do frogs belong to?'" | ||
exit 1 | ||
elif [ $# -eq 0 ]; then | ||
request | ||
else | ||
INPUT=$1 | ||
for arg in $@; do | ||
if [ $# -eq 1 ] && ([ $1 == "--local" ] || [ $1 == "-l" ]); then | ||
if [ $# -ne 2 ]; then | ||
request | ||
fi | ||
echo "Running the Lilypad module Docker image locally..." | ||
local=true | ||
request=$2 | ||
else | ||
request=$1 | ||
fi | ||
done | ||
fi | ||
DevlinRocha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Base64 encode the input | ||
JSON_INPUT="{"messages": [{"role": "user", "content": "$INPUT"}]}" | ||
BASE64_INPUT=$(echo $JSON_INPUT | base64) | ||
commit_hash=$(git log --pretty=format:%H | head -n 1) | ||
# Base64 encode the request | ||
base64_request=$(echo $request | base64 -w 0) | ||
DevlinRocha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ $local != true ]; then | ||
if [ -z $local ]; then | ||
commit_hash=$(git log --pretty=format:%H | head -n 1) | ||
MODULE=$GITHUB_REPO:$commit_hash | ||
echo "Running $MODULE on Lilypad Network..." | ||
echo "Original input: $JSON_INPUT" | ||
echo "Base64 encoded: $BASE64_INPUT" | ||
lilypad run $MODULE -i prompt=$BASE64_INPUT | ||
echo "Original request: $request" | ||
echo "Base64 encoded: $base64_request" | ||
lilypad run $MODULE -i request=$base64_request --web3-private-key=$WEB3_PRIVATE_KEY | ||
else | ||
MODULE=$DOCKER_IMAGE:$VERSION | ||
echo "Running $MODULE locally..." | ||
echo "Original input: $JSON_INPUT" | ||
echo "Base64 encoded: $BASE64_INPUT" | ||
docker run $MODULE $BASE64_INPUT | ||
echo "Original request: $request" | ||
echo "Base64 encoded: $base64_request" | ||
docker run $MODULE $base64_request | ||
fi | ||
DevlinRocha marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.