Tool use in conversation

To best answer your question, the LLM system uses tools as needed. Create your own tools with N8N.

Now in UIUC.chat, you can create your own tools for the LLM to use seamlessly during a conversation. See our demo below.

Tools demo

Get access

Tools are invite-only during beta. Just shoot me an email and I'll send you an onboarding invite no problem.

Email me: kvday2@illinois.edu

I'm happy to onboard anyone. No need to justify anything, no calls required.

N8n to easily define tools!

To make it as easy as possible for you to create your own tools, we self-host n8n a visual workflow builder. We chose n8n after an intense study of the market because of:

Usage - Write your own tool

After receiving an invite, login on tools.UIUC.chat.

Tools can take text or images as input and text or images as output. These modalities are supported by current OpenAI models, maybe audio is coming soon.

Inputs

All tools MUST start with a n8n Form Trigger. Use this to define the inputs to your tool.

The AI will use the Form Title, Form Description and the Form Fields to decide when to use your tool, so make those as descriptive as possible so the AI will know how to best use your tool.

Text Outputs

No explicit return is necessary because we use the output of your last node as the return value of the tool. This works seamlessly across all the nodes offered by n8n.

Using Images in tools

Images are passed via an array of image_urls in a json object. They must be URLs to images, no raw/binary data.

{
   "image_urls": ["url","url","https://bucket.r2.cloudflare.com/img-path"],
   "other-useful-text": "These images depict the circle of life in the savanna."
}

Image Inputs

To take an image as input, put image_urls as a field in your n8n Form Trigger (shown below).

If you're using code, you'll have to parse this image_urls text into a JSON array. This is required because n8n doesn't allow JSON inputs, so we use a text input and have to parse the JSON data manually.

image_urls: List[str] = post_body.get('image_urls', []) # grab data from POST body

if image_urls and isinstance(image_urls, str):
  image_urls = json.loads(image_urls)
print(f"Parsed image URLs: {image_urls}")

Image Outputs

Your final node must return a JSON object that contains a top-level key "image_urls". You may return as many images as you'd like. They must be URLs to images, no raw/binary data.

You can return images + other text. That's fine and encouraged! Your tool can output arbitrary JSON data. Just the image_urls field is specially handled.

{
   "image_urls": ["url","url"],
   "other-useful-text": "These images depict the circle of life in the savanna.",
   "animals_detected": [
      "tigers": 5,
      "antelope": 1
   ]
}

Example tool using images

There's just two nodes: first capture input params, then call a POST endpoint hosted on Beam's serverless infra.

Step 1: Capture the input params. We just need the image_urls field.

Step 2: call a POST endpoint hosted on Beam. Auth is handled by an Authorization Header. The body uses the values from the last node as an input. No explicit return is necessary because we use the output of your last node as the return value of the tool. This works seamlessly across all the nodes offered by n8n.

In our experience, we like defining arbitrary python functions and run those as tools. Many of our tools look like a single n8n Form Trigger -> HTTP request to our python code.

I host these endpoints on Beam.cloud, which is a phenomenal "serverless" hosting service. They're super low cost, with a truly next-level development experience. I highly recommend them.

Development

During beta, try using the feature branch here: https://uiuc-chat-git-n8n-ui-kastandays-projects.vercel.app/

  1. Define tools in uiuc.chat/<YOUR-PROJECT>/tools

  2. Enable the tools you want active in your project

  3. Start chatting, tools will be invoked as needed.

Last updated