Goals
- Use tool calling to build your own AI agent with Friendli Model APIs
- Feel free to make your own custom tools!
Getting Started
- Go to Friendli Suite, and create an account.
- Grab a Personal API key to use Friendli Model APIs within an agent.
Step 1. Playground UI
Experience tool calling on the Playground!- On your left sidebar, click the Model APIs option to access the playground page.
- You will see the models available as Model APIs. Select the one you want and click the endpoint.
- Click the Tools button, select the Search tool, and enter a query to see the response. 😀
Step 2. Build a Custom Tool
Build your own creative tool. This section shows you how to make a custom tool that retrieves temperature information. (The completed code snippet is at the bottom.)- Define a function for using as a custom tool
-
Send a function calling inference request
- Add your input as a
userrole message. - The information about the custom function (e.g.,
get_temperature) goes into the tools option. JSON schema describes the function’s parameters. - The response includes the
argumentsfield, which contains values extracted from the user’s input that can be used as parameters of the custom function.
- Add your input as a
-
Generate the final response using the tool calling results
- Add the
tool_callsresponse as anassistantrole message. - Add the result obtained by calling the
get_temperaturefunction as atoolmessage to the Chat API again.
- Add the
-
Complete Code Snippet