Function Calling: Integrating External Tools
Function calling in rtrvr.ai allows you to integrate with external tools and services, extending the functionality of the AI agent. Using the @
notation, you can embed function calls directly in your prompts, seamlessly incorporating the results into your workflow. This allows you to automate complex tasks by leveraging APIs and other external functionalities.
Core Concepts
Function calling allows rtrvr.ai to invoke external functions to perform tasks or gather information, expanding its capabilities. Here are the core concepts:
- →The
@
Notation: Use the@
symbol followed by the function name (e.g.,@queryDatabase()
,@sendSlackMessage()
). - →Direct Function Calls: You can directly call pre-defined functions using this notation in your prompt.
- →LLM-Driven Calls: rtrvr.ai can also use the LLM to decide which functions to call and what parameters to pass based on your natural language request.
- →Integration: The output of these function calls is fed back into the AI model, allowing it to take actions or provide you with richer responses.
Examples of Function Calling
Direct Function Calls
- →
"Get the latest stock price for AAPL using @getStockPrice(symbol='AAPL')"
Calls thegetStockPrice
function to fetch the real time stock price and integrates into the workflow. - →
"Query my database for sales data with @queryDatabase(query='SELECT * FROM sales WHERE date > last_month')"
Calls thequeryDatabase
function to retrieve information from the database using given SQL query. - →
"Send a Slack message with summary of this page: @sendSlackMessage(channel='#general', message='summary')"
Calls thesendSlackMessage
function to send the summary of the page to the given slack channel.
LLM-Driven Function Calls
- →
"Send a Slack message with the summary of this page"
The LLM can decide to call the@sendSlackMessage()
function and use page summary as context. - →
"Get today's weather for New York and send it to me on Slack"
The LLM can decide to use a@getWeather()
function to get weather info, and@sendSlackMessage()
function to share the weather to the user.
How to Use Function Calls
- →Identify the Function: Decide which function you need to use to perform your task.
- →Include in the Prompt: Include the function call in your prompt using the
@
notation. - →Specify Parameters: If needed, provide the necessary parameters for the function (e.g.,
@function(param1='value1', param2='value2')
)