• Supported service: llm
  • Key: together
  • Built-in: Yes
  • Supported models:
    • meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo
    • meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo
    • meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo

Function Calling

Llama 3.1’s function calling documentation is located here. Llama doesn’t use OpenAI-style function calling; instead, you need to add to your system prompt to enable the LLM to use functions. If you use the following recommended format, Daily Bots will be able to detect function call responses from the LLM and allow you to follow the directions in the function calling tutorial.

First, define a weatherTool object, and/or any other functions you want to call:

const weatherTool = {
  name: "get_current_weather",
  description: "Get the current weather in a given location",
  parameters: {
    type: "object",
    properties: {
      location: {
        type: "string",
        description: "The city and state, e.g. San Francisco, CA",
      },
    },
    required: ["location"],
  },
};

Then, reference that weatherTool object in your system prompt:

export const defaultConfig = [
  {
    service: "llm",
    options: [
      { name: "model", value: "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" },
      {
        name: "initial_messages",
        value: [
          {
            role: "user",
            content: `
              You have access to the following functions:

              Use the function '${weatherTool["name"]}' to '${
              weatherTool["description"]
            }':
              ${json.stringify(weatherTool)}

              If you choose to call a function ONLY reply in the following format with no prefix or suffix:

              <function=example_function_name>{{\"example_name\": \"example_value\"}}</function>

              Reminder:
              - Function calls MUST follow the specified format, start with <function= and end with </function>
              - Required parameters MUST be specified
              - Only call one function at a time
              - Put the entire function call reply on one line
              - If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls

              You are a TV weatherman named Wally. Your job is to present the weather to me. You can call the 'get_weather' function to get weather information. Start by asking me for my location. Then, use 'get_weather' to give me a forecast. Then, answer any questions I have about the weather. Keep your introduction and responses very brief. You don't need to tell me if you're going to call a function; just do it directly. Keep your words to a minimum. When you're delivering the forecast, you can use more words and personality.`,
          },
        ],
      },
      { name: "run_on_config", value: true },
    ],
  },
];