Assistant vs Tool / Function Prompt: A Comprehensive Guide

Assistant vs Tool / Function Prompt: A Comprehensive Guide

Table of contents:

In artificial intelligence (AI), the ability to communicate clearly with applications is important to fully leverage an LLM's capabilities. Prompt engineering is an important skill that enables us to interact with AI and achieve whatever outcomes we specify.

We've previously discussed the distinction between system prompts and user prompts. This article builds upon that foundation, exploring the intricacies of assistant prompts and tool / function prompts. These message types are crucial for understanding the dynamics of conversational AI and how LLMs can interact with external systems.

What is an Assistant Prompt?

An assistant prompt, often referred to as an assistant message, represents the AI's response within a dialogue. It's the LLM's turn to contribute to the conversation after receiving input from a user.

Think of it this way: conversations with LLMs are structured in turns:

  • User Message: The user initiates the interaction with a question, request, or statement.
  • Assistant Message: The LLM processes the user's input and generates a reply.

This exchange can repeat, creating a dynamic and interactive conversation. The content of an assistant message can vary widely depending on the user's input and the LLM's capabilities.

Here are some examples of what an assistant message might contain:

  • Answers to questions: Providing factual information or explanations.
    • For example, if a user asks "What is the capital of France?", the assistant message would be "The capital of France is Paris."
  • Generating text: Creating stories, poems, articles, or other forms of written content based on the user's request.
  • Making suggestions: Offering recommendations or advice, such as suggesting good restaurants in a city.
  • Clarifying questions: Asking for more information to better understand the user's needs and provide a more relevant response. For instance, if a user asks about the weather, the assistant might respond, "Which city are you interested in the weather for?"
  • Performing actions (with tools/functions): As we'll explore in the next section, assistant messages can also involve interacting with external systems or APIs.

Example of an Assistant prompt:

User: What are some good places to visit in Rome?

Assistant Message: Rome is a fantastic city with many historical sites and beautiful attractions! Here are a few suggestions:

  • The Colosseum: An iconic amphitheater from the Roman Empire.
  • The Vatican City: Home to St. Peter's Basilica and the Vatican Museums.
  • The Trevi Fountain: A stunning Baroque fountain where you can toss a coin for good luck.
  • The Roman Forum: The ruins of ancient government buildings.

In essence, the assistant message is the LLM's way of participating in a dialogue, offering responses to meet the user's needs.

🍰
PromptLayer is the go-to platform for managing assistant and tool/function messages.

You can test, analyze, deploy, and manage prompts with your whole team. Get started here.

What is a Tool or Function Prompt?

A tool, or function, prompt, also commonly known as tool calling or function calling, represents a different type of message generated by an LLM. Unlike a standard assistant message that directly provides information or text, a tool/function prompt instructs an external system or function to perform a specific action. This extends the capabilities of an LLM beyond text generation and allows it to interact with the real world or access external data sources.

Purpose:

  • Extending LLM capabilities: LLMs are primarily trained on vast amounts of text data. Tool/function messages enable them to access real-time information, interact with APIs, or execute code – tasks beyond their inherent textual abilities.
  • Enabling complex tasks: By integrating language understanding with external tools, LLMs can handle more intricate tasks requiring both reasoning and action.

Structure of a tool/function prompt:

A typical tool/function message includes:

  • Tool/function name: Identifies the specific tool or function to be invoked (e.g., `get_current_weather`, `send_email`, `search_wikipedia`).
  • Arguments/parameters: Specifies the necessary input values for the tool/function (e.g., `location="London"`, `recipient="user@example.com"`, `query="history of the internet"`).

Format:

While the format can vary depending on the LLM and implementation, a structured format like JSON is commonly used:

{

"tool_name": "get_current_weather",

"arguments": {

"location": "Tokyo",

"unit": "celsius"

}

}

Workflow:

User input: The user provides a request to the LLM.

LLM analysis: The LLM analyzes the input and determines if an external tool or function is necessary to fulfill the request.

Tool/function message generation: If a tool is needed, the LLM generates a structured message specifying the tool and its required arguments.

Tool execution: An external system or function receives the message, executes the specified tool with the provided arguments, and returns the result.

Assistant Message: The LLM receives the result from the executed tool and uses it to generate a final, informative response to the user.

Example:

User: What's the weather like in Berlin?

Tool/function message:

{

"tool_name": "get_current_weather",

"arguments": {

"location": "Berlin"

}

}

External system (executes the tool):

(Fetches weather data for Berlin and returns it to the LLM, e.g., {"temperature": 18, "condition": "Cloudy"})

Assistant message:

The current weather in Berlin is 18°C and cloudy.

Tool and function messages are a vital mechanism for empowering LLMs to interact with the world beyond text, unlocking a vast array of potential applications.

Assistant Prompt vs. Tool or Function Prompt: Key Differences

While both assistant prompts and tool/function prompts originate from the LLM, they serve distinct purposes:

FeatureAssistant Prompt (Message)Tool / Function Prompt (Message)
Primary GoalTo directly respond to the user, providing information or text.To instruct an external system to perform an action.
ContentTextual response, answers, suggestions, clarifying questions.Structured data specifying the tool and its arguments (e.g., JSON).
ActionDirectly addresses the user's request within the LLM's capabilities.Triggers an external action or data retrieval.
User InteractionDirectly perceived by the user as the AI's response.Typically happens in the background, facilitating the final response.
Example"The Eiffel Tower is located in Paris."{"tool_name": "send_email", "arguments": {"recipient": "..."}}

Final thoughts

Understanding the nuances between assistant prompts and tool/function prompts is crucial for anyone working with advanced AI models.

While assistant prompts represent the direct conversational output of the LLM, tool/function prompts unlock a powerful mechanism for extending the LLM's capabilities by integrating it with external systems.

By understanding these concepts, developers can design more sophisticated AI interactions, leveraging the power of LLMs to solve a wider range of complex problems.


About PromptLayer

PromptLayer is a prompt management system that helps you iterate on prompts faster — further speeding up the development cycle! Use their prompt CMS to update a prompt, run evaluations, and deploy it to production in minutes. Check them out here. 🍰

Read more