From 4d5cfa778ca2d740f95dfdec52c49f81dd5f5f7d Mon Sep 17 00:00:00 2001 From: Devlin Date: Wed, 26 Feb 2025 17:40:23 -0800 Subject: [PATCH 01/23] refactor input --- .../templates/src/run_model | 100 +----------------- 1 file changed, 3 insertions(+), 97 deletions(-) diff --git a/src/create_lilypad_module/templates/src/run_model b/src/create_lilypad_module/templates/src/run_model index 76346ce..808bae1 100644 --- a/src/create_lilypad_module/templates/src/run_model +++ b/src/create_lilypad_module/templates/src/run_model @@ -5,81 +5,7 @@ mkdir -p /outputs # Parse base64 input argument and decode to JSON echo "Raw input (base64): $1" >&2 -input_json=$(echo "$1" | base64 --d) - -# Parse arguments -prompt=$(echo "$input_json" | sed -n 's/.*"prompt":[[:space:]]*"\([^"]*\)".*/\1/p') -system=$(echo "$input_json" | sed -n 's/.*"system":[[:space:]]*"\([^"]*\)".*/\1/p') -mirostat=$(echo "$input_json" | sed -n 's/.*"mirostat":[[:space:]]*"\([^"]*\)".*/\1/p') -mirostat_eta=$(echo "$input_json" | sed -n 's/.*"mirostat_eta":[[:space:]]*"\([^"]*\)".*/\1/p') -mirostat_tau=$(echo "$input_json" | sed -n 's/.*"mirostat_tau":[[:space:]]*"\([^"]*\)".*/\1/p') -num_ctx=$(echo "$input_json" | sed -n 's/.*"num_ctx":[[:space:]]*"\([^"]*\)".*/\1/p') -repeat_last_n=$(echo "$input_json" | sed -n 's/.*"repeat_last_n":[[:space:]]*"\([^"]*\)".*/\1/p') -repeat_penalty=$(echo "$input_json" | sed -n 's/.*"repeat_penalty":[[:space:]]*"\([^"]*\)".*/\1/p') -temperature=$(echo "$input_json" | sed -n 's/.*"temperature":[[:space:]]*"\([^"]*\)".*/\1/p') -seed=$(echo "$input_json" | sed -n 's/.*"seed":[[:space:]]*"\([^"]*\)".*/\1/p') -num_predict=$(echo "$input_json" | sed -n 's/.*"num_predict":[[:space:]]*"\([^"]*\)".*/\1/p') -top_k=$(echo "$input_json" | sed -n 's/.*"top_k":[[:space:]]*"\([^"]*\)".*/\1/p') -top_p=$(echo "$input_json" | sed -n 's/.*"top_p":[[:space:]]*"\([^"]*\)".*/\1/p') -min_p=$(echo "$input_json" | sed -n 's/.*"min_p":[[:space:]]*"\([^"]*\)".*/\1/p') - -# Initialize default values -mirostat=${mirostat:-"0"} -mirostat_eta=${mirostat_eta:-"0.1"} -mirostat_tau=${mirostat_tau:-"5.0"} -num_ctx=${num_ctx:-"2048"} -repeat_last_n=${repeat_last_n:-"64"} -repeat_penalty=${repeat_penalty:-"1.1"} -temperature=${temperature:-"0.8"} -seed=${seed:-"0"} -num_predict=${num_predict:-"-1"} -top_k=${top_k:-"40"} -top_p=${top_p:-"0.9"} -min_p=${min_p:-"0.0"} - -if [[ -z "$prompt" ]]; then - echo "❌ Error: Prompt is required" >&2 - exit 1 -fi - -echo "Prompt: $prompt" >&2 - -# Prepare the messages array -if [[ -z "$system" ]]; then - messages=( - "[{\"role\": \"user\", \"content\": \"$prompt\"}]" - ) -else - messages=( - "[{\"role\": \"system\", \"content\": \"$system\"}, - {\"role\": \"user\", \"content\": \"$prompt\"}]" - ) -fi - -# Prepare the chat completion request -request=$( - cat <&2 @@ -107,32 +33,12 @@ response=$(curl -s http://127.0.0.1:11434/api/chat \ -H "Content-Type: application/json" \ -d "$request") -# Create JSON structure following OpenAI format -escaped_response=$(echo "$response" | sed 's/"/\\"/g') -formatted_response="{ - 'id': 'cmpl-$(openssl rand -hex 12)', - 'object': 'text_completion', - 'created': "$(date +%s)", - 'model': '$MODEL_ID', - 'choices': [{ - 'text': '$escaped_response', - 'index': 0, - 'logprobs': null, - 'finish_reason': 'stop' - }], - 'usage': { - 'prompt_tokens': null, - 'completion_tokens': null, - 'total_tokens': null - } -}" - # Save debug info { echo "=== Debug Info ===" date - echo "System: $system" - echo "Input: $prompt" + echo "Input (base64): $1" + echo "Decoded input: $input_json" echo "Request to Ollama: $request" echo "Response from Ollama:" echo "$response" From ca14097d77149d9ec8dcaabadbf76ad82ff73807 Mon Sep 17 00:00:00 2001 From: Devlin Date: Wed, 26 Feb 2025 18:06:52 -0800 Subject: [PATCH 02/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b1ed63..6116781 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.32", + "version": "0.0.33", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold" From ef00cd893bcad9155b72389cc65a120eb4b43b99 Mon Sep 17 00:00:00 2001 From: Devlin Date: Wed, 26 Feb 2025 19:05:43 -0800 Subject: [PATCH 03/23] change to request --- src/create_lilypad_module/templates/lilypad_module.json.tmpl | 2 +- src/create_lilypad_module/templates/src/run_model | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/create_lilypad_module/templates/lilypad_module.json.tmpl b/src/create_lilypad_module/templates/lilypad_module.json.tmpl index 67ec51d..b6f3959 100644 --- a/src/create_lilypad_module/templates/lilypad_module.json.tmpl +++ b/src/create_lilypad_module/templates/lilypad_module.json.tmpl @@ -7,7 +7,7 @@ "Docker": { "WorkingDirectory": "/app", "Entrypoint": [ - "/app/src/run_model", {{ .input }} + "/app/src/run_model", {{ .request }} ], "Image": "dockerhub_username/image:v0.0.0" }, diff --git a/src/create_lilypad_module/templates/src/run_model b/src/create_lilypad_module/templates/src/run_model index 808bae1..f7e3399 100644 --- a/src/create_lilypad_module/templates/src/run_model +++ b/src/create_lilypad_module/templates/src/run_model @@ -5,7 +5,7 @@ mkdir -p /outputs # Parse base64 input argument and decode to JSON echo "Raw input (base64): $1" >&2 -input_json=$(echo "$1" | base64 -d) +request=$(echo "$1" | base64 -d) # Start the ollama server in the background echo "Starting Ollama server..." >&2 @@ -38,7 +38,6 @@ response=$(curl -s http://127.0.0.1:11434/api/chat \ echo "=== Debug Info ===" date echo "Input (base64): $1" - echo "Decoded input: $input_json" echo "Request to Ollama: $request" echo "Response from Ollama:" echo "$response" From 243c378750a90c1db9f6f56fb0bf359208925e35 Mon Sep 17 00:00:00 2001 From: Devlin Date: Wed, 26 Feb 2025 19:05:59 -0800 Subject: [PATCH 04/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6116781..b41a2e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.33", + "version": "0.0.34", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold" From 243ffee5c509aa43095a5ebcae2314c99644246d Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 13:30:37 -0800 Subject: [PATCH 05/23] move version bump --- src/create_lilypad_module/templates/scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create_lilypad_module/templates/scripts/build b/src/create_lilypad_module/templates/scripts/build index 77582c9..81a21de 100644 --- a/src/create_lilypad_module/templates/scripts/build +++ b/src/create_lilypad_module/templates/scripts/build @@ -37,7 +37,6 @@ for arg in $@; do VERSION="v$MAJOR.$MINOR.$PATCH" echo "New version: $VERSION" - sed -i "" "s/^VERSION=.*/VERSION=$VERSION/" .env fi if [ $arg == "--no-cache" ]; then @@ -91,6 +90,7 @@ if [ -z $local ]; then echo "✅ Docker image built and published to Docker Hub successfully." echo -e "\thttps://hub.docker.com/repository/docker/$DOCKER_HUB_REPO/general" echo -e "\n\tscripts/run_module" + sed -i "" "s/^VERSION=.*/VERSION=$VERSION/" .env else echo "✅ Docker image built and loaded into local daemon successfully." echo -e "\n\tscripts/run_module --local" From 87067b9be7b2e90f6ae1229d62507a6e9a4a69fc Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 13:31:22 -0800 Subject: [PATCH 06/23] remove workingdirectory --- src/create_lilypad_module/templates/lilypad_module.json.tmpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/create_lilypad_module/templates/lilypad_module.json.tmpl b/src/create_lilypad_module/templates/lilypad_module.json.tmpl index b6f3959..c376cfa 100644 --- a/src/create_lilypad_module/templates/lilypad_module.json.tmpl +++ b/src/create_lilypad_module/templates/lilypad_module.json.tmpl @@ -5,11 +5,10 @@ "Spec": { "Deal": { "Concurrency": 1 }, "Docker": { - "WorkingDirectory": "/app", "Entrypoint": [ "/app/src/run_model", {{ .request }} ], - "Image": "dockerhub_username/image:v0.0.0" + "Image": "dockerhub_username/image@" }, "Engine": "Docker", "Network": { "Type": "None" }, From 52d2e85f957b7f48792e3083f7851f5a0f6d0f2b Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 13:31:59 -0800 Subject: [PATCH 07/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b41a2e6..997e940 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.34", + "version": "0.0.35", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold" From eafb9dff6fabaebf0e30dea92dfe4f293643006f Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 15:32:52 -0800 Subject: [PATCH 08/23] update example command --- src/create_lilypad_module/templates/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/create_lilypad_module/templates/README.md b/src/create_lilypad_module/templates/README.md index a96fb3b..89002b9 100644 --- a/src/create_lilypad_module/templates/README.md +++ b/src/create_lilypad_module/templates/README.md @@ -22,7 +22,18 @@ Once your Docker image has been pushed to Docker Hub, you can run your module on ```sh export WEB3_PRIVATE_KEY=WEB3_PRIVATE_KEY -lilypad run github.com/github_username/module_repo:v0.0.0 -i input=$(echo '{"prompt": "Which animal order do frogs belong to?", "system": "You are a helpful AI assistant", "temperature": "0.4"}' | base64 -w 0) +lilypad run github.com/GITHUB_USERNAME/MODULE_REPO:TAG \ + -i request="$(echo -n '{ + "model": "MODEL_NAME:MODEL_VERSION", + "messages": [{ + "role": "user", + "content": "what is the animal order of the frog?" + }], + "stream": false, + "options": { + "temperature": 0.8 + } + }' | base64 -w 0)" ``` ### Valid Parameters and Default Values From fd12604e09d101e86d92cdc69bb3c45bc685a780 Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 15:33:07 -0800 Subject: [PATCH 09/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 997e940..dad5a17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.35", + "version": "0.0.36", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold" From 5d1b4ec3ef5080880f71df91615c4be530e3dc79 Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 17:36:43 -0800 Subject: [PATCH 10/23] add `system` message to example; update options parameters --- src/create_lilypad_module/templates/README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/create_lilypad_module/templates/README.md b/src/create_lilypad_module/templates/README.md index 89002b9..5e0842d 100644 --- a/src/create_lilypad_module/templates/README.md +++ b/src/create_lilypad_module/templates/README.md @@ -26,24 +26,26 @@ lilypad run github.com/GITHUB_USERNAME/MODULE_REPO:TAG \ -i request="$(echo -n '{ "model": "MODEL_NAME:MODEL_VERSION", "messages": [{ + "role": "system", + "content": "you are a helpful AI assistant" + }, + { "role": "user", "content": "what is the animal order of the frog?" }], "stream": false, "options": { - "temperature": 0.8 + "temperature": 1.0 } }' | base64 -w 0)" ``` -### Valid Parameters and Default Values +### Valid Options Parameters and Default Values -> \* === Required +- [Ollama Modelfile](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values) | Parameter | Description | Default | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| prompt\* | The content of the message sent from the user to the model. | `""` | -| system | The content of the message sent from the system to the model. | `""` | | mirostat | Enable Mirostat sampling for controlling perplexity. (0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0) | `0` | | mirostat_eta | Influences how quickly the algorithm responds to feedback from the generated text. A lower learning rate will result in slower adjustments, while a higher learning rate will make the algorithm more responsive. | `0.1` | | mirostat_tau | Controls the balance between coherence and diversity of the output. A lower value will result in more focused and coherent text. | `5` | @@ -52,7 +54,8 @@ lilypad run github.com/GITHUB_USERNAME/MODULE_REPO:TAG \ | repeat_penalty | Sets how strongly to penalize repetitions. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. | `1.1` | | temperature | The temperature of the model. Increasing the temperature will make the model answer more creatively. | `0.8` | | seed | Sets the random number seed to use for generation. Setting this to a specific number will make the model generate the same text for the same prompt. | `0` | -| num_predict | Maximum number of tokens to predict when generating text. (-1 = infinite generation) | `-1` | +| stop | Sets the stop sequences to use. When this pattern is encountered the LLM will stop generating text and return. Multiple stop patterns may be set by specifying multiple separate stop parameters in a modelfile. | | +| num_predict | Maximum number of tokens to predict when generating text. (-1 = infinite generation) | `-1` | | top_k | Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a lower value (e.g. 10) will be more conservative. | `40` | | top_p | Works together with top-k. A higher value (e.g., 0.95) will lead to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text. | `0.9` | | min_p | Alternative to the top_p, and aims to ensure a balance of quality and variety. The parameter p represents the minimum probability for a token to be considered, relative to the probability of the most likely token. For example, with p=0.05 and the most likely token having a probability of 0.9, logits with a value less than 0.045 are filtered out. | `0.0` | From 945d7551f127528f8d12f8cde9baff54ecc40ea1 Mon Sep 17 00:00:00 2001 From: Devlin Date: Thu, 27 Feb 2025 17:36:58 -0800 Subject: [PATCH 11/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dad5a17..8afeb03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.36", + "version": "0.0.37", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold" From f223edbb9fc8325b5395c29badaf85decbf3b679 Mon Sep 17 00:00:00 2001 From: Devlin Date: Fri, 28 Feb 2025 10:17:40 -0800 Subject: [PATCH 12/23] add back `formatted_response` --- .../templates/src/run_model | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/create_lilypad_module/templates/src/run_model b/src/create_lilypad_module/templates/src/run_model index f7e3399..00bc337 100644 --- a/src/create_lilypad_module/templates/src/run_model +++ b/src/create_lilypad_module/templates/src/run_model @@ -33,6 +33,24 @@ response=$(curl -s http://127.0.0.1:11434/api/chat \ -H "Content-Type: application/json" \ -d "$request") +formatted_response="{ + 'id': 'cmpl-$(openssl rand -hex 12)', + 'object': 'text_completion', + 'created': "$(date +%s)", + 'model': '$MODEL_ID', + 'choices': [{ + 'text': '$escaped_response', + 'index': 0, + 'logprobs': null, + 'finish_reason': 'stop' + }], + 'usage': { + 'prompt_tokens': null, + 'completion_tokens': null, + 'total_tokens': null + } +}" + # Save debug info { echo "=== Debug Info ===" From 43e507e007eb7f27d1f7c9a8832f83853b911d52 Mon Sep 17 00:00:00 2001 From: Devlin Date: Fri, 28 Feb 2025 10:17:56 -0800 Subject: [PATCH 13/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8afeb03..1ad019e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.37", + "version": "0.0.38", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold" From 70f7942674f8f72543e5ba320a3250a4a88aaa9d Mon Sep 17 00:00:00 2001 From: Devlin Date: Fri, 28 Feb 2025 15:24:17 -0800 Subject: [PATCH 14/23] update CLI command --- src/create_lilypad_module/templates/README.md | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/create_lilypad_module/templates/README.md b/src/create_lilypad_module/templates/README.md index 5e0842d..8552f4d 100644 --- a/src/create_lilypad_module/templates/README.md +++ b/src/create_lilypad_module/templates/README.md @@ -17,27 +17,27 @@ Your module's ready! 🎉 Once your Docker image has been pushed to Docker Hub, you can run your module on Lilypad Network. -> Make sure that you Base64 encode your input. +> Make sure that you Base64 encode your request. ```sh export WEB3_PRIVATE_KEY=WEB3_PRIVATE_KEY lilypad run github.com/GITHUB_USERNAME/MODULE_REPO:TAG \ - -i request="$(echo -n '{ - "model": "MODEL_NAME:MODEL_VERSION", - "messages": [{ - "role": "system", - "content": "you are a helpful AI assistant" - }, - { - "role": "user", - "content": "what is the animal order of the frog?" - }], - "stream": false, - "options": { - "temperature": 1.0 - } - }' | base64 -w 0)" +-i request="$(echo -n '{ + "model": "MODEL_NAME:MODEL_VERSION", + "messages": [{ + "role": "system", + "content": "you are a helpful AI assistant" + }, + { + "role": "user", + "content": "what is the animal order of the frog?" + }], + "stream": false, + "options": { + "temperature": 1.0 + } +}' | base64 -w 0)" ``` ### Valid Options Parameters and Default Values From 0747853acaa36d587213591932c4ddbf794cdec3 Mon Sep 17 00:00:00 2001 From: Devlin Date: Sat, 1 Mar 2025 17:53:02 -0800 Subject: [PATCH 15/23] change tense --- src/create_lilypad_module/templates/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/create_lilypad_module/templates/README.md b/src/create_lilypad_module/templates/README.md index 8552f4d..2fea58f 100644 --- a/src/create_lilypad_module/templates/README.md +++ b/src/create_lilypad_module/templates/README.md @@ -66,8 +66,8 @@ In the project directory, you can run: ### [`scripts/configure`](scripts/configure) -Configure your module. -Set the following values in the [`.env` file](.env) +Configures your module. +Sets the following values in the [`.env` file](.env) ``` MODEL_NAME @@ -83,7 +83,7 @@ Builds the Docker image and pushes it to Docker Hub. ### `--major`, `--minor`, and `--patch` Flags -Increment the specified version before building the Docker image. +Increments the specified version before building the Docker image. #### `--local` Flag @@ -91,7 +91,7 @@ Loads the built Docker image into the local Docker daemon. ### [`scripts/run`](scripts/run) -Run your module. +Runs your module. ## Learn More From 4638b018e8ea4cf11033e1e7f583ac452424958b Mon Sep 17 00:00:00 2001 From: Devlin Date: Sat, 1 Mar 2025 18:00:32 -0800 Subject: [PATCH 16/23] fix run command --- .../templates/scripts/run | 80 +++++++++++++------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/src/create_lilypad_module/templates/scripts/run b/src/create_lilypad_module/templates/scripts/run index aa209d4..6502b05 100644 --- a/src/create_lilypad_module/templates/scripts/run +++ b/src/create_lilypad_module/templates/scripts/run @@ -1,39 +1,69 @@ #!/usr/bin/env bash -if [ $# -lt 1 ] || [ $# -gt 2 ]; then - echo "Usage: scripts/run [--local] " - 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}" +} + +if [ $# -gt 2 ]; then + echo "Usage: scripts/run [--local] " + 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..." + lcoal=true + REQUEST=$2 + else + REQUEST=$1 + fi + done fi -# 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 $full_request | base64 -w 0) +echo $WEB3_PRIVATE_KEY -if [ $local != true ]; then +if [ -z $lcoal ]; 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 From 54c352a0f49edf46e7931e31b469624efa3af376 Mon Sep 17 00:00:00 2001 From: Devlin Date: Sat, 1 Mar 2025 18:01:15 -0800 Subject: [PATCH 17/23] add `-l` as valid `--local` flag --- src/create_lilypad_module/templates/scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create_lilypad_module/templates/scripts/build b/src/create_lilypad_module/templates/scripts/build index 81a21de..2697f35 100644 --- a/src/create_lilypad_module/templates/scripts/build +++ b/src/create_lilypad_module/templates/scripts/build @@ -13,7 +13,7 @@ if [ -z $MODEL_NAME ] || [ -z $MODEL_VERSION ] || [ -z $DOCKER_IMAGE ]; then fi for arg in $@; do - if [ $arg == "--local" ]; then + if [ $1 == "--local" ] || [ $1 == "-l" ]; then echo "Building the Docker image and loading it into the local Docker daemon..." local=true fi From ae2ea9721fada26479a8462b15e3935623fe6420 Mon Sep 17 00:00:00 2001 From: Devlin Date: Sat, 1 Mar 2025 18:05:04 -0800 Subject: [PATCH 18/23] uniform language --- src/create_lilypad_module/templates/Dockerfile | 2 +- src/create_lilypad_module/templates/help | 2 +- src/create_lilypad_module/templates/src/run_model | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/create_lilypad_module/templates/Dockerfile b/src/create_lilypad_module/templates/Dockerfile index 9944d1e..74b3186 100644 --- a/src/create_lilypad_module/templates/Dockerfile +++ b/src/create_lilypad_module/templates/Dockerfile @@ -29,7 +29,7 @@ RUN mkdir -p ./outputs && chmod 777 ./outputs # Set outputs directory as a volume VOLUME ./outputs -# Copy a script to start ollama and handle input +# Copy a source code and handle request COPY src ./src RUN chmod +x ./src/run_model diff --git a/src/create_lilypad_module/templates/help b/src/create_lilypad_module/templates/help index fe52640..613f8db 100644 --- a/src/create_lilypad_module/templates/help +++ b/src/create_lilypad_module/templates/help @@ -9,6 +9,6 @@ else echo "Available commands:" echo -e "\tscripts/configure Configure the module" echo -e "\tscripts/build [--local] [--major] [--minor] [--patch] Build and push a new Docker image" - echo -e "\tscripts/run [--local] Run the module" + echo -e "\tscripts/run [--local] Run the module" exit 1 fi diff --git a/src/create_lilypad_module/templates/src/run_model b/src/create_lilypad_module/templates/src/run_model index 00bc337..1b8bf21 100644 --- a/src/create_lilypad_module/templates/src/run_model +++ b/src/create_lilypad_module/templates/src/run_model @@ -3,8 +3,8 @@ # Create output directory if it doesn't exist mkdir -p /outputs -# Parse base64 input argument and decode to JSON -echo "Raw input (base64): $1" >&2 +# Parse Base64 request argument and decode to JSON +echo "Raw request (Base64): $1" >&2 request=$(echo "$1" | base64 -d) # Start the ollama server in the background @@ -55,7 +55,7 @@ formatted_response="{ { echo "=== Debug Info ===" date - echo "Input (base64): $1" + echo "Request (Base64): $1" echo "Request to Ollama: $request" echo "Response from Ollama:" echo "$response" From 1bb38c588f9fec2173ad884b75707d407cd0b3af Mon Sep 17 00:00:00 2001 From: Devlin Date: Sun, 2 Mar 2025 05:25:28 -0800 Subject: [PATCH 19/23] fix typo --- src/create_lilypad_module/templates/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create_lilypad_module/templates/Dockerfile b/src/create_lilypad_module/templates/Dockerfile index 74b3186..86f011a 100644 --- a/src/create_lilypad_module/templates/Dockerfile +++ b/src/create_lilypad_module/templates/Dockerfile @@ -29,7 +29,7 @@ RUN mkdir -p ./outputs && chmod 777 ./outputs # Set outputs directory as a volume VOLUME ./outputs -# Copy a source code and handle request +# Copy source code and handle request COPY src ./src RUN chmod +x ./src/run_model From 961a3d70e14bc5029aee2e32ff5e8f5feb3c671a Mon Sep 17 00:00:00 2001 From: Devlin Date: Sun, 2 Mar 2025 13:29:25 -0800 Subject: [PATCH 20/23] fix errors --- .../templates/scripts/run | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/create_lilypad_module/templates/scripts/run b/src/create_lilypad_module/templates/scripts/run index 6502b05..f1c2992 100644 --- a/src/create_lilypad_module/templates/scripts/run +++ b/src/create_lilypad_module/templates/scripts/run @@ -41,29 +41,28 @@ else request fi echo "Running the Lilypad module Docker image locally..." - lcoal=true - REQUEST=$2 + local=true + request=$2 else - REQUEST=$1 + request=$1 fi done fi # Base64 encode the request -BASE64_REQUEST=$(echo $full_request | base64 -w 0) -echo $WEB3_PRIVATE_KEY +base64_request=$(echo $request | base64 -w 0) -if [ -z $lcoal ]; 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 request: $request" - echo "Base64 encoded: $BASE64_REQUEST" - lilypad run $MODULE -i request=$BASE64_REQUEST --web3-private-key=$WEB3_PRIVATE_KEY + 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 request: $request" - echo "Base64 encoded: $BASE64_REQUEST" - docker run $MODULE $BASE64_REQUEST + echo "Base64 encoded: $base64_request" + docker run $MODULE $base64_request fi From 2d01db29cf7b598145409077b9c1a1cb116a4ef8 Mon Sep 17 00:00:00 2001 From: Devlin Date: Sun, 2 Mar 2025 14:57:33 -0800 Subject: [PATCH 21/23] fix run --- .../templates/scripts/run | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/create_lilypad_module/templates/scripts/run b/src/create_lilypad_module/templates/scripts/run index f1c2992..5aeee54 100644 --- a/src/create_lilypad_module/templates/scripts/run +++ b/src/create_lilypad_module/templates/scripts/run @@ -8,9 +8,11 @@ function request { printf "Enter your wallet private key: " read -r private_key WEB3_PRIVATE_KEY=$private_key + echo "Private key set" + echo "(Hint: Use 'export WEB3_PRIVATE_KEY=' to avoid this prompt in the future)" fi echo "Copy the JSON below to form your request:" - printf ' + echo ' "messages": [{ "role": "system", "content": "you are a helpful AI assistant" @@ -23,9 +25,9 @@ function request { "temperature": 1.0 } ' - printf "\n(Paste JSON as one line) ➔ " + printf "(Paste JSON as one line) ➔ " read -r request - request="{"model": $MODEL_NAME:$MODEL_VERSION, $request, "stream": false}" + request="{\"model\": \"$MODEL_NAME:$MODEL_VERSION\", $request, \"stream\": false}" } if [ $# -gt 2 ]; then @@ -35,18 +37,23 @@ if [ $# -gt 2 ]; then elif [ $# -eq 0 ]; then request else - for arg in $@; do - if [ $# -eq 1 ] && ([ $1 == "--local" ] || [ $1 == "-l" ]); then - if [ $# -ne 2 ]; then - request - fi + while [[ $# -gt 0 ]]; do + case $1 in + --local | -l) echo "Running the Lilypad module Docker image locally..." local=true - request=$2 - else + shift + ;; + *) request=$1 - fi + shift + ;; + esac done + + if [[ -z $request ]]; then + request + fi fi # Base64 encode the request @@ -58,6 +65,7 @@ if [ -z $local ]; then echo "Running $MODULE on Lilypad Network..." echo "Original request: $request" echo "Base64 encoded: $base64_request" + echo lilypad run $MODULE -i request=$base64_request --web3-private-key=$WEB3_PRIVATE_KEY lilypad run $MODULE -i request=$base64_request --web3-private-key=$WEB3_PRIVATE_KEY else MODULE=$DOCKER_IMAGE:$VERSION From 36890215e191a388b5e85f6f43d0d9930dc71505 Mon Sep 17 00:00:00 2001 From: Devlin Date: Sun, 2 Mar 2025 15:08:10 -0800 Subject: [PATCH 22/23] remove debug echo --- src/create_lilypad_module/templates/scripts/run | 1 - 1 file changed, 1 deletion(-) diff --git a/src/create_lilypad_module/templates/scripts/run b/src/create_lilypad_module/templates/scripts/run index 5aeee54..f6e7f2d 100644 --- a/src/create_lilypad_module/templates/scripts/run +++ b/src/create_lilypad_module/templates/scripts/run @@ -65,7 +65,6 @@ if [ -z $local ]; then echo "Running $MODULE on Lilypad Network..." echo "Original request: $request" echo "Base64 encoded: $base64_request" - echo lilypad run $MODULE -i request=$base64_request --web3-private-key=$WEB3_PRIVATE_KEY lilypad run $MODULE -i request=$base64_request --web3-private-key=$WEB3_PRIVATE_KEY else MODULE=$DOCKER_IMAGE:$VERSION From 8051a13cfa128c977716615a2816d56edaeebd1e Mon Sep 17 00:00:00 2001 From: Devlin Date: Sun, 2 Mar 2025 15:08:25 -0800 Subject: [PATCH 23/23] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ad019e..6bf223b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-lilypad-module", - "version": "0.0.38", + "version": "0.0.39", "description": "Create Lilypad modules with a modern Docker setup and minimal configuration.", "bin": { "create-lilypad-module": "src/create_lilypad_module/scaffold"