MyShell 백서

MyShell

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 16쪽

ab" alt=""><figcaption><p>Melo TTS</p></figcaption></figure> `AnyWidgetConfig` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------- | | widget\_id | string (Required) | Creators can select their desired widget in the Workshop, and copy the widget id. | '1743340032770445312' | | output\_name | string (Required) | Specifies the name of the output in AnyWidgetConfig. | 'result' | | cache | boolean (Optional) | <p>Flag to enable cache mode. When set to true, the state will run only once and store the result.<br>Default to false.</p> | | # Prompt Widget ### Widgets in Workshop ![Prompt widget](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FOZQSYsfR6m8vl15yK4ar%2Fprompt_widget.png?alt=media\&token=18d29daa-e0ab-415e-b1ae-4179f911bd06) ### Config Fields besides `widget_id` and `output_name` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | ------------------------------------------------ | -------- | | content | string (Required) | User input message processed by language models. | ‘Hello.’ | ### Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "input_message": { "type": "text", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1743157315558707200", "content": "{{input_message}}", "output_name": "result" } } ], "render": { "text": "{{result}}", "buttons": [ { "content":"Chat Again", "description":"", "on_click":"chat" } ] }, "transitions": { "chat": "home_state" } } } } ``` # LLM Widget ### Widgets in Workshop ![LLM widget](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FZZ3h7XudryX5TEHG28pg%2Fllm%20widget.png?alt=media\&token=c71c4ada-2fe8-47e8-be13-629176c3baaf) ### Config Most fields are compatible with [OpenAI API](https://platform.openai.com/docs/api-reference/chat/create). Fields besides `widget_id` and `output_name` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ---------------------- | ------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | temperature | number (Optional) | Controls randomness in the LLMConfig model's responses. | 0.6 | | top\_p | number (Optional) | Controls diversity via nucleus sampling in LLMConfig. | 0.8 | | max\_tokens | number (Optional) | Determines the maximum length of the model’s response in LLMConfig. | 150 | | presence\_penalty | number (Optional) | Influences the likelihood of the model to talk about new topics in LLMConfig. | 0.6 | | frequency\_penalty | number (Optional) | Controls how often the model makes use of infrequent words in LLMConfig. | 0.5 | | memory | MemoryItem\[] (Optional) | Stores information acquired across multiple rounds of dialog in LLMConfig. | \[{ role: 'user', content: 'Hello World' }] | | need\_memory | boolean (Optional) | Determines if memory usage is required in LLMConfig. | true | | system\_prompt | string | Expression (Required) | Provides system prompt for the user in LLMConfig. | | user\_prompt | string | Expression (Required) | Provides user prompt for the system in LLMConfig. | | function\_name | string (Optional) | Specifies the name of the function in LLMFunctionConfig. | 'get\_current\_weather' | | function\_description | string (Optional) | Provides a description of the function in LLMFunctionConfig. | 'Get the current weather in a given location' | | function\_parameters | FunctionParameter\[] (Optional) | Specifies the parameters of the function in LLMFunctionConfig. | \[{name: 'city', type: 'string', description: 'The city, e.g. San Francisco, CA'}] | | knowledge\_base\_token | string (Optional) | Specify the knowledge base the widget uses. | | `FunctionParameter` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | ---------------------------------------------------------------------- | ---------------------------------- | | name | string (Required) | Specifies the name of the function parameter in FunctionParameter. | 'city' | | type | string (Required) | Specifies the type of the function parameter in FunctionParameter. | 'list', 'string' or 'number' | | description | string (Required) | Provides a description of the function parameter in FunctionParameter. | 'The city, e.g. San Francisco, CA' | ### Function Call If you want to execute LLM function calls, you may specify `function_name`, `function_description` and `function_parameters` fields. {% hint style="info" %} Function calls can be seen as a formatting wrapper provided by LLM (currently only supports OpenAI series models), allowing parameters to be input via JSON, and outputting a serial JSON.&#x20; Reference: * <https://www.promptingguide.ai/applications/function_calling> * <https://platform.openai.com/docs/api-reference/chat/create> {% endhint %} For LLM function calls, the output of the widget is a JSON object, which includes the LLM returned results and will be automatically output to the state machine output in the form of key-value pairs. ### Example ```json { "id": "prompt_widget_template", "initial": "home_state", "states": { "home_state": { "inputs": { "input_message": { "type": "IM", "user_input": true } }, "tasks": [ { "name": "llm_widget_example_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1744214047475109888", "user_prompt": "{{input_message}}", // the text inputted into prompt widget, you can get it from user input or upper state "system_prompt": "Act as ...", // Optional field. You can input system prompt of bot. "top_p": 0.5, // Optional field. Default value is 0.5 "temperature": 0.5, // Optional field. Default value is 0.5 "frequency_penalty": 0, // Optional field. Default value is 0 "presence_penalty": 0, // Optional field. Default value is 0 "output_name": "result" } } ], "render": { "text": "{{result}}", // it's a string produced by prompt widget. "buttons": [ { "content": "Chat Again", "description": "", "on_click": "rerun" } ] }, "transitions": { "rerun": "home_state", "CHAT": "home_state" } } } } ``` # TTS Widget Widget in Workshop ![Untitled](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2F4GBQIJy0nFiJ8jxpJoTb%2Fvoice%20widget.png?alt=media\&token=a2a08f68-55e3-4421-aeb2-c5cbae09397e) Config Fields besides `widget_id` and `output_name` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | ----------------------------------------------------- | -------- | | content | string (Required) | User input message processed by language models. | ‘Hello.’ | | speed | number (Optional) | Speed of audio. The number should be between 0 and 2. | '1.5' | Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "read_text": { "type": "text", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1743159010695057408", "content": "{{read_text}}", "speed": 1, "output_name": "result" } } ], "render": { "text": "{{read_text}}", "audio": "{{result}}", "buttons": [ { "content":"Listen Again", "description":"", "on_click":"listen" } ] }, "transitions": { "listen": "home_state" } } } } ``` # Code Runner Widget ### Widgets in Workshop ![Code Runner Widget](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FIkolB5fg8F4RkKliEssu%2Fjs%20code%20widget.png?alt=media\&token=9e84a463-225f-4901-86ac-f5fabe352aa5) {% hint style="info" %} Currently we only provide JavaScript code runner. The supported syntax remains consistent with [Common](/create/pro-config-mode/basic/common#expression), including ECMAScript 5.1 and certain 6+ features.\ We don't support third-party libraries or host-environment-specific API like `fetch.` {% endhint %} ### Config Fields besides `widget_id` and `output_name` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | code | string (Required) | A stringified code snippet. It should contain one or more function definitions. | "function main(params) {\n const { a, b } = params;\n const sum = a + b;\n return sum;\n}" | | function | string (Optional) | The name of the function you want to call in the code snippet. Defaults to `main`. | 'main' | | params | Object (Optional) | The parameters you pass to the calling function. | ‘Hello.’ | {% hint style="info" %} You can use the widget's 'Copy' button to get a stringified code snippet for `code` field. {% endhint %} <figure><img src="https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FwykXLLRGtNmFngqM4uJ6%2Fcopy%20code.png?alt=media&amp;token=da27878d-8683-4824-9fd4-3e231efb1545" alt=""><figcaption><p>Copy code</p></figcaption></figure> ### Example {% code overflow="wrap" %} ```json { "id": "code_widget_template", "initial": "home_state", "states": { "home_state": { "tasks": [ { "name": "code_widget_example_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1751859390353202447", "params": { "a": "{{1}}", "b": "{{2}}" }, "code": "function main(params) {\n const { a, b } = params;\n const sum = a + b;\n return sum;\n}", // the text inputted into prompt widget, you can get it from user input or upper state "output_name": "result" } } ], "render": { "text": "{{result}}", // it's a string produced by prompt widget. "buttons": [ { "content": "Run Again", "description": "", "on_click": "rerun" } ] }, "transitions": { "rerun": "home_state", "CHAT": "home_state" } } } } ``` {% endcode %} # Melo TTS ### Widget {% embed url="<https://app.myshell.ai/widget/32AnEr>" %} ### Config ![Melo TTS](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FgNq0wqzGy6TeKbXeKAaq%2Fmelo_tts.png?alt=media\&token=2eeb0d59-7124-4f9a-b72f-4f20aaf0f5ab) ### Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "input_message": { "type": "text", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1745097608856756779", "language": "en_us", "speed": 1, "text": "{{input_message}}", "output_name": "result" } } ], "render": { "text": "My Voice", "audio": "{{result.file_url}}", "buttons": [ { "content": "Listen Again", "description": "", "on_click": "listen" } ] }, "transitions": { "listen": "home_state" } } } } ``` # Age Transformation ### Widget {% embed url="<https://app.myshell.ai/widget/vEfYV3>" %} ### Config ![Age Transformation](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FuqGDY4iuuWgThNCSUlNO%2Fage_transformation.png?alt=media\&token=b42b217a-c8e1-43ef-be36-7593e0b56b3c) ### Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "your_face_image_url": { "type": "image", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1743838658173079552", "image": "{{your_face_image_url}}", "target_age": "default", "output_name": "result" } } ], "render": { "text": "Result", "image": "{{result.file_url}}", "buttons": [ { "content": "Generate Again", "description": "", "on_click": "generate" } ] }, "transitions": { "generate": "home_state" } } } } ``` # ChatImg ### Widget {% embed url="<https://app.myshell.ai/widget/eemAzu>" %} ### Config ![ChatImg](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FewCM5mH2OgFvp0qRESfP%2Fchat_img.png?alt=media\&token=22c58a3f-b11c-48ad-be6d-390b503184bd) ### Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "your_image_url": { "type": "image", "user_input": true }, "your_question": { "type": "text", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1743838640687026176", "output_name": "result", "image": "{{your_image_url}}", "prompt": "{{your_question}}", "top_p": 1, "temperature": 0.2, "max_tokens": 1024 } } ], "render": { "text": "{{result.content}}", "buttons": [ { "content": "Generate Again", "description": "", "on_click": "generate" } ] }, "transitions": { "generate": "home_state" } } } } ``` # GIF Generation ### GIF Generation ### Widget {% embed url="<https://app.myshell.ai/widget/N32eA3>" %} ### Config ![GIF Generation](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2F52D0MoVK2HSfxUEbI8qD%2Fgif_gen.png?alt=media\&token=37dc9dd7-4745-4fe6-ad54-d2523f18e60b) ### Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "prompt": { "type": "text", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1743838648844947456", "output_name": "result", "prompt": "{{prompt}}", "negative_prompt": "blurry", "width": 672, "height": 384, "scheduler": "EulerAncestralDiscreteScheduler", "steps": 30, "mp4": false, "seed": 6226 } } ], "render": { "text": "Result", "image": "{{result.file_url}}", "buttons": [ { "content": "Generate Again", "description": "", "on_click": "generate" } ] }, "transitions": { "generate": "home_state" } } } } ``` # Music Generation ### Widget {% embed url="<https://app.myshell.ai/widget/MJBzEb>" %} ### Config ![Music Generation](https://2975681513-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDtmZwLatyyBFLUK6P6Pj%2Fuploads%2FqzQa9QxTS8s0smiRs2wk%2Friffusion.png?alt=media\&token=284597fd-555d-4905-898b-12d8b7b4d0b4) ### Example ```json { "id": "test", "initial": "home_state", "states": { "home_state": { "inputs": { "prompt_a": { "type": "text", "user_input": true }, "prompt_b": { "type": "text", "user_input": true } }, "tasks": [ { "name": "any_module_test_task", "module_type": "AnyWidgetModule", "module_config": { "widget_id": "1743838636299784192", "output_name": "result", "prompt_a": "{{prompt_a}}", "denoising": 0.75, "prompt_b": "{{prompt_b}}", "alpha": 0.5, "num_inference_steps": 50, "seed_image_id": "vibes" } } ], "render": { "text": "Result", "audio": "{{result.audio}}", "buttons": [ { "content": "Generate Again", "description": "", "on_click": "generate" } ] }, "transitions": { "generate": "home_state" } } } } ``` # LLM Module Most fields are compatible with [OpenAI API](https://platform.openai.com/docs/api-reference/chat/create). `LLMConfig` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------------ | ----------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------- | | model | "gpt-35-turbo-16k" | "gpt-4-1116-preview" (Required) | Determines the OpenAI language model to be used in LLMConfig. | | temperature | number (Optional) | Controls randomness in the LLMConfig model's responses. | 0.6 | | top\_p | number (Optional) | Controls diversity via nucleus sampling in LLMConfig. | 0.8 | | max\_tokens | number (Optional) | Determines the maximum length of the model’s response in LLMConfig. | 150 | | presence\_penalty | number (Optional) | Influences the likelihood of the model to talk about new topics in LLMConfig. | 0.6 | | frequency\_penalty | number (Optional) | Controls how often the model makes use of infrequent words in LLMConfig. | 0.5 | | memory | MemoryItem\[] (Optional) | Stores information acquired across multiple rounds of dialog in LLMConfig. | \[{ role: 'user', content: 'Hello World' }] | | need\_memory | boolean (Optional) | Determines if memory usage is required in LLMConfig. | true | | system\_prompt | string | Expression (Required) | Provides system prompt for the user in LLMConfig. | | user\_prompt | string | Expression (Required) | Provides user prompt for the system in LLMConfig. | | output\_name | string (Required) | Determines the name of the module output in LLMConfig, defaults to 'reply'. | "reply" | `MemoryItem` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | --------------------- | ------------------------------------------------------------ | | role | user | assistant (Required) | Specifies the source of the memory item in MemoryItem. | | content | string | Expression (Required) | Specifies the actual value of the memory item in MemoryItem. | #### # LLM Function Module `LLMFunctionModule` is a module used for executing LLM function calls. Function calls can be seen as a formatting wrapper provided by LLM (currently only supports OpenAI series models), allowing parameters to be input via JSON, and outputting a serial JSON as we defined in `function_parameters`. Reference: * <https://www.promptingguide.ai/applications/function_calling> * <https://platform.openai.com/docs/api-reference/chat/create> The module input can be specified by each parameter in the config. The output of the module is a JSON object, which includes the LLM return results and will be automatically output to the state machine output in the form of key-value pairs. `LLMFunctionConfig` is similar to `LLMConfig`. It only differs by: * the lack of `output_name` * three fields starting with `function_`, which are vital for the LLMFunctionModule as they control the function behavior. They will be placed in the tools field of the LLM Request Body. `LLMFunctionConfig` | Field's Name | JSON Type (Required/Optional) | Description | Example | | --------------------- | ------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | function\_name | string (Required) | Specifies the name of the function in LLMFunctionConfig. | 'get\_current\_weather' | | function\_description | string (Required) | Provides a description of the function in LLMFunctionConfig. | 'Get the current weather in a given location' | | function\_parameters | FunctionParameter\[] (Required) | Specifies the parameters of the function in LLMFunctionConfig. | \[{name: 'city', type: 'string', description: 'The city, e.g. San Francisco, CA'}] | `FunctionParameter` | Field's Name | JSON Type (Required/Optional) | Description | Example | | ------------ | ----------------------------- | ---------------------------------------------------------------------- | ---------------------------------- | | nam
프로젝트로 돌아가기