Back to blog

Sunday, September 15, 2024

Using Functions Calling and NGROK to Generate this MDX Page (via ChatGPT)

Introduction: The Future of Coding with Voice and LLMs

Imagine performing complex software engineering tasks effortlessly with just your voice. By harnessing the power of large language models (LLMs) like ChatGPT, Ingra functions, and ngrok, you can turn this vision into reality. In this blog post, we explore how you can use voice prompts through ChatGPT to control your local machine, showcasing how this very MDX file was created using remote shell execution and function calling.

Utilizing Ingra and ChatGPT to Control Your Local Machine

Leverage the power of Ngrok, Ingra functions, and ChatGPT to execute remote shell commands on your local machine seamlessly. Here’s how it all works:

  • Ngrok Setup: Using ngrok, we expose a local Flask server (./local-scripts/flask_server.py) to the internet, enabling secure remote access.
  • Ingra Functions: The executeRemoteShellCommand function is curated on the Ingra platform, allowing remote execution of shell commands.
  • ChatGPT Function Calling: ChatGPT triggers these shell commands to perform actions such as creating utility scripts, committing changes to GitHub, and more.

Step by step Guide

1

Run Flask Server in your local machine

You can view our own flask_server.py, or you can just copy and paste it to run it in your local.

python3 ./flask_server.py

Once you run it, remember the PORT where Flask server is running on. In my case, it's 5000

Bearer Token:

Ingra's flask_server.py require a bearer token which will be used at later stage.

2

Run Ngrok in your local machine

Setting up ngrok is simple and free, follow their guide at their page

Run Ngrok by specifying the Flask server PORT for secure access. In my case, it's 5000

ngrok http 5000

Once ngrok has started, it will provide you a public URL such as https://11a0-255-55-55-200.ngrok-free.app.

3

Saving to Ingra Environment Variables

Create new environment variables at Ingra;

NameValue
LOCAL_NGROK_URLhttps://11a0-255-55-55-200.ngrok-free.app
LOCAL_NGROK_BEARERYour-Bearer-Token-from-Step1

Via Web

You can add it at your Environment Variables at Ingra

Via GPT (ChatGPT)

To setup ChatGPT with Ingra, you can follow our guide here Setting up Ingra for Custom ChatGPT

And you can simply prompt the GPT with;

  Create new environment variables:
  - LOCAL_NGROK_URL: https://11a0-255-55-55-200.ngrok-free.app
  - LOCAL_NGROK_BEARER: Your-Bearer-Token-from-Step1
4

Create the function at Ingra

You have 3 options:

  • Visit and clone this executeRemoteShellCommand function
  • Subscribe to function above, or the collection that contains it.
  • Curate your own function, use above as reference.

Test the function:

Once you have the function, visit your Swagger to find the function and test it on the web.

5

Invoke the function from GPT

Once the function is set up, directly invoke it from ChatGPT by simply searching for the function. Since you already have Built-in function

Example Prompt:

  Search for a function for ngrok
  Search for a function named executeRemoteShellCommand

etc..

Have a look at how I did it here Shared ChatGPT Session

Updating OpenAPI:

Optionally, after you own the function - you can visit your OpenAPI and update to your own Custom ChatGPT.

Read more about that at Setting up Ingra for Custom ChatGPT

6

That's it!

You should now be able to run your home computer remotely, via ChatGPT.

A Fun Note:

Try prompting it with voice command with mobile ChatGPT application.

Understanding the Components

1. Ngrok

Ngrok creates a secure tunnel to your localhost, allowing for remote shell command execution on your local machine.

2. Ingra Functions

Ingra provides the executeRemoteShellCommand function, which allows you to execute shell commands on a remote server exposed via ngrok.

Executing Remote Commands

With this setup, commands like the following are executed remotely through ChatGPT prompts:

// Command to list files in the blog directory
executeRemoteShellCommand({ command: ls ./apps/docs/contents/blogs/ });

// Command to read content for the blog
executeRemoteShellCommand({ command: cat ./local-scripts/README.md });

// Command to create this MDX file
executeRemoteShellCommand({ command: "echo MDX content here > ./apps/docs/contents/blogs/new-blog.mdx" });

Automating with ChatGPT

By leveraging ChatGPT, you automate the execution of these commands, generate content, and manage files on your local machine—all through simple voice or text prompts.


Example Workflow: Creating This Blog Post

In this session, I set up ngrok on my local computer to point to ./local-scripts/flask_server.py. By configuring the LOCAL_NGROK_URL and LOCAL_NGROK_BEARER environment variables in Ingra, we enable secure communication.

Example Usage

With this setup, I utilized ChatGPT function calling to:

  • Curate executeRemoteShellCommand in Ingra: This function allows for the execution of remote shell commands.
  • Trigger Shell Commands via ChatGPT: Commands such as creating the local-scripts utility for the Ingra GitHub repository.
  • Automate Git Commands: Trigger git commit and git push through simple prompts.

Here’s a sample chat session that covered these actions:

Commands and Outputs

Output Function (executeRemoteShellCommand at Ingra):
Output Pull Request:
Output README: How You Can Remotely Control Your Computer with GPT

Conclusion: The Future is Voice and Automation

By combining the power of Ingra functions, ngrok, and ChatGPT, we’ve demonstrated how to generate this blog post and manage your local machine without manually writing a single line of code. This approach not only simplifies software engineering tasks but also makes them accessible to everyone, regardless of technical background.

Welcome to the future of software engineering, where complex workflows are just a conversation away. 🚀