From d090a5852f2d86844aa9e80c2207a2b82950f1d8 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Mon, 12 May 2025 22:26:14 +0900 Subject: [PATCH 1/2] fix: Lua LLM/simpleLLM data format --- srp/lua.md | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/srp/lua.md b/srp/lua.md index d89fc33..5987b17 100644 --- a/srp/lua.md +++ b/srp/lua.md @@ -178,7 +178,7 @@ Perform a similarity sort between the source and value. source must be a array of strings, and value must be a string. return a array of index sorted by similarity. -This is a async function. use `similarity(triggerId, source, value):await()` to wait for the result. +This is an async function. Use `similarity(triggerId, source, value):await()` to wait for the result. ### `generateImage(triggerId, prompt, negative)` @@ -186,53 +186,62 @@ This is a async function. use `similarity(triggerId, source, value):await()` to Generate an image with the prompt and negative. returns the asset CBS (like `{{asset::assetId}}`). -This is a async function. use `generateImage(triggerId, prompt, negative):await()` to wait for the result. +This is an async function. Use `generateImage(triggerId, prompt, negative):await()` to wait for the result. ### `LLM(triggerId, data)` > This function requires low level access. -Performs a llm request with the data. returns the response. +Performs a LLM request with a message data. Returns the response. + +The message data must be a table of messages in the format of: -data must be a message format, with the format of: ```lua { -- the message role, can be "system", "assistant", "user" { role = "system", - data = "system message" + content = "system message" }, { role = "assistant", - data = "char message" + content = "char message" }, { role = "user", - data = "user message" + content = "user message" } ... } ``` -the response format is: +The response format is: ```lua { success = true, - message = "response message", + result = "response message", } ``` -This is a async function. use `LLM(triggerId, data):await()` to wait for the result. +This is an async function. Use `LLM(triggerId, data):await()` to wait for the result. ### `simpleLLM(triggerId, message)` > This function requires low level access. -Performs a simple llm request with the message. returns the response. -both the message and response format is string. +Performs a LLM request with a string prompt. Returns the response. + +The response format is: + +```lua +{ + success = true, + result = "response message", +} +``` -This is a async function. use `simpleLLM(triggerId, message):await()` to wait for the result. +This is an async function. Use `simpleLLM(triggerId, message):await()` to wait for the result. ## Tips @@ -246,4 +255,4 @@ This is a async function. use `simpleLLM(triggerId, message):await()` to wait fo - The lua script is executed in a sandbox environment, so you can't access the file system or network. - You can't use external libraries except the included `json.lua`. - If error occurs in the lua script, the application will work as if the script is not executed, and the error message will be displayed in the console. -- The Lua version is based on [Lua 5.4](https://www.lua.org/manual/5.4/) \ No newline at end of file +- The Lua version is based on [Lua 5.4](https://www.lua.org/manual/5.4/) From 4e5d19cfc86f1cb54f937e813c1e2d40cb2e356e Mon Sep 17 00:00:00 2001 From: alattalatta Date: Mon, 12 May 2025 23:15:16 +0900 Subject: [PATCH 2/2] fix: LLM/simpleLLM should not be awaited --- srp/lua.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/srp/lua.md b/srp/lua.md index 5987b17..342c6b6 100644 --- a/srp/lua.md +++ b/srp/lua.md @@ -224,8 +224,6 @@ The response format is: } ``` -This is an async function. Use `LLM(triggerId, data):await()` to wait for the result. - ### `simpleLLM(triggerId, message)` > This function requires low level access. @@ -241,8 +239,6 @@ The response format is: } ``` -This is an async function. Use `simpleLLM(triggerId, message):await()` to wait for the result. - ## Tips