How to enable Python support in Layla
- Layla

- 12 minutes ago
- 2 min read
Layla Agents can execute python! This is possible after update v6.7.0: https://www.layla-network.ai/post/layla-v6-7-0-has-been-published
To enable Python code execution, we need to install a few mini-apps. If you need a refresher on how to do this, here is a tutorial: https://www.layla-network.ai/post/how-to-add-features-mini-apps-in-layla
Step 1: You need the Agents mini-app and the Python Interpreter mini-app
Go to your apps, tap the plus sign, and browser mini-apps. Find the Agents and Python Interpreter mini-app. Tap Download to add them to Layla.


Step 2: Test out the Python Interpreter After you've installed those two mini-apps, let's go to the Python Interpreter mini-app to test it out.
Try executing a simple "Hello Layla" script by tapping the Run button at the top right.

You should see the green text "Hello Layla!" in the Console Output below. This confirms that Python is working in Layla!
Step 3 (optional): install dependencies
Python scripts aren't really useful unless you can install libraries and dependencies. Layla allows you to do that!
The "Package Manager" below the output allows you to install Python packages via "pip", just like how you would in a PC.
Let's try installing "requests", a popular library to make network requests (you will be needing this a lot!).

Type "requests" in the package manager input and tap "Add"
Tip: this input works just like a command line, you can add arguments such as "--upgrade" to replace already installed packages. You fix a version by using "[package name]==[version]". You can even install multiple packages by simply typing them with a space between their names!
Afterwards, you should see green text detailing the install progress.
Step 3: Create a test agent
Python scripting becomes a lot more useful if Agents can execute them; and Layla supports that.
In this article, we will create a simple test agent that prints something to be sent to the LLM. In future articles, we will go over creating more complicated agents.
Go back to the Agents mini-app. The easiest way is to duplicate an existing agent. Let's do that.
Edit the name and description to something you can remember.

Edit this new agent:

For now, we will just use the phrase "Python". This means whenever you mention "python" in your messages to Layla, this agent will be triggered. (Obviously more complex triggers are needed later for more complex agents!)
Add the "execute Python code" tool:

In the Python code tool, you are able to edit the script to execute, and add any dependencies that your code needs. For now, a simple "print" will do:

Since the "print" code requires not dependencies, we will leave that section blank.
That's it! Your agent is created.
Now, go back and start a chat with Layla (make sure your agent is enabled, you can check the toggle is ON in the agents list).
When you mention "python", the code will execute, and the output is sent to the LLM!




Comments