Function calling in Experiments

Using function calling within the Orq.ai Experiments

Tools let you use function calling abilities available on models that support it.

Function calling is a way for a model to output structured text automatically. The structured text follows a set of user-defined variables and is formatted in JSON. It can then be used to call any other function or system.

Function calling is a safe way to integrate a model with any external service, with common use-cases like:

  • Answering user queries via external API calls.
  • Converting natural language to a structured function call.
  • Extracting structured data from any text.

Adding a tool to an Experiment

πŸ“˜

To add a tool to an Experiment, it must first be available through your resources. To learn how to create a Tool through your resources see Tools in Resources.

To add a tool to your experiment by heading to the Configuration tab, scrolling down to the Tools panel and pressing the Add Tool button.

To select which tool you want to add, simply click on the name of the tool.

Once a tool is added, it will be available in the context of your Experiment, for all compatible language models.

Using a tool in an Experiment

You can use a tool within an experiment just like in any other context. Once your tool has been added to your configuration you can invoke function calling through your model prompt like you would do normally.

In the following example, I have the get_local_weather tool configured in my Experiment, it defines the following payload:

{
  "name": "get_local_weather",
  "description": "",
  "parameters": {
    "type": "object",
    "properties": {
      "unit": {
        "type": "string",
        "description": "The weather unit"
      },
      "location": {
        "type": "string",
        "description": "The city and state, e.g. San Francisco, CA"
      }
    },
    "required": [
      "location",
      "unit"
    ]
  }
}
Adding the tool `get_local_weather` to my Experiment configuration.

Adding the tool get_local_weather to my Experiment configuration.

Adding the following prompt in my Dataset configuration:

Prompting the model to query a structured output through function calling.

Prompting the model to query a structured output through function calling.

And then generate the following results visible in my Reports:

You can easily compare Experiment results using the **Comparison mode**.

You can easily compare Experiment results using the Comparison mode.