MyShell
  • About MyShell
    • What is MyShell
    • MyShell in a Nutshell
    • Quickstart
  • Explore AI Agents
    • Image Generation
    • Video Generation
    • Meme Generation
    • Role-Playing Game
    • Character
    • Utility
  • Create AI Agents
    • Classic Mode
      • Enhanced Prompt
      • Knowledge Base
      • Telegram Integration
    • Pro Config Mode
      • Core Concepts
      • Tutorial
        • Tutorial Structure
        • Hello World with Pro Config
        • Building Workflow
        • Transitions
        • Expressions and Variables
        • Integration with Any Widget
        • An Advanced Example
      • Basic
        • Common
        • Atomic State
        • Transition
        • Automata
        • Modules
      • Advanced
        • Cron Pusher
        • Neutral Language To SD Prompt
        • Advanced Input Validation
        • Advanced Memory Manager in Prompt Widget
      • Tools
        • AutoConfig Agent
        • Cache Mode
        • Knowledge Base Agent
        • Crawler Widget
      • Example
        • Homeless With You
        • Random Routing
        • Function Calling
      • API Reference
        • Atomic State
        • Transition
        • Automata
        • Context
        • Module
          • AnyWidget Module
            • Prompt Widget
            • LLM Widget
            • TTS Widget
            • Code Runner Widget
            • Melo TTS
            • Age Transformation
            • ChatImg
            • GIF Generation
            • Music Generation
          • LLM Module
          • LLM Function Module
          • TTS Module
          • Google Search Module
        • Widgets
          • Bark TTS
          • Champ
          • CoinGecko
          • ControlNet with Civitai
          • Crawler
          • Crypto News
          • Data Visualizer
          • Email Sender
          • Google Flight Search
          • Google Hotel Search
          • Google Image Search
          • Google Map Search
          • Google News Search
          • Google Scholar Search
          • Google Search
          • GroundedSAM
          • Image Text Fuser
          • Information Extractor - OpenAI Schema Generator
          • Information Extractor
          • Instagram Search
          • JSON to Table
          • LinkedIn
          • MS Word to Markdown
          • Markdown to MS Word
          • Markdown to PDF
          • Mindmap Generator
          • Notion Database
          • OCR
          • Pdf to Markdown
          • RMBG
          • Stabel-Video-Diffusion
          • Stable Diffusion Inpaint
          • Stable Diffusion Recommend
          • Stable Diffusion Transform
          • Stable Diffusion Upscale
          • Stable Diffusion with 6 fixed category
          • Stable Diffusion with Civitai
          • Storydiffusion
          • Suno Lyrics Generator
          • Suno Music Generator
          • Table to Markdown
          • TripAdvisor
          • Twitter Search
          • UDOP: Document Question Answering
          • Weather forecasting
          • Whisper large-v3
          • Wikipedia
          • Wolfram Alpha Search
          • Yelp Search
          • YouTube Downloader
          • YouTube Transcriber
          • Youtube Search
      • FAQs
      • Changelog
    • ShellAgent Mode
      • Download and Installation
      • App Builder
      • Workflow
      • Build Custom Widget
      • Publish to MyShell
      • Example
        • Child Book X Agent (ft. DeepSeek)
        • Kids Book NFT AI Agent (ft. BNB Chain)
        • DeFAI Agent (ft. BNB Chain)
  • Shell Launchpad
    • How to Launch a Token
    • Trade Agent Tokens
  • Tokenomics
    • $SHELL Basics
    • $SHELL Token Utility
    • How to Obtain $SHELL
    • Roadmap
  • Open-source AI Framework/SDK
    • ShellAgent
    • OpenVoice
    • MeloTTS
    • JetMoE
    • AIlice
  • Links
Powered by GitBook
On this page
  • Widgets in Workshop
  • Config
  • Example
  1. Create AI Agents
  2. Pro Config Mode
  3. API Reference
  4. Module
  5. AnyWidget Module

Code Runner Widget

PreviousTTS WidgetNextMelo TTS

Last updated 1 year ago

Widgets in Workshop

Currently we only provide JavaScript code runner. The supported syntax remains consistent with , including ECMAScript 5.1 and certain 6+ features. We don't support third-party libraries or host-environment-specific API like fetch.

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.’

You can use the widget's 'Copy' button to get a stringified code snippet for code field.

Example

{
  "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"
      }
    }
  }
}
Code Runner Widget
Copy code
Expression