The Linkup integration allows you to search the web and include the results in your prompts. This is useful for providing up-to-date information to your models without having to manually search and paste content.

Check out the LinkUp website for more information.

1. Add Linkup Parameters to Your Request

Include linkup_params in your API payload:

{
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Please summarize the information about Microsoft's 2024 revenue: {% if linkup_search_response %}{{ linkup_search_response.answer }}{% endif %}"}
  ],
  "linkup_params": {
      "q": "What is Microsoft's 2024 revenue?",
      "depth": "deep",
      "outputType": "sourcedAnswer",
      "includeImages": false
    }
}

2. Use Template Variables in Your Messages

The Linkup response will be available as a variable named linkup_search_response in your templates. You can access it using Jinja2 syntax:

{% if linkup_search_response %}
  {{ linkup_search_response.answer }}
  
  Sources:
  {% for source in linkup_search_response.sources %}
    - {{ source.name }}: {{ source.url }}
      {{ source.snippet }}
  {% endfor %}
{% endif %}

3. Using with Prompts

If you’re using the Prompts feature, you can include the Linkup template variables in your prompt templates. When you make a request with linkup_params, the variables will be populated and rendered in your prompt.

How It Works

  1. When a request with linkup_params is received, the system:

    • Extracts the Linkup parameters from the request
    • Calls the Linkup API to retrieve search results
    • Adds the results to the template variables as linkup_search_response
    • Renders the prompt templates with these variables
  2. If you’re using stored prompts, the system:

    • Loads the prompt without rendering variables
    • Merges variables from the prompt and the request
    • Processes Linkup parameters and adds results to variables
    • Renders the prompt with all variables, including Linkup results

Parameters

The linkup_params object supports the following parameters:

ParameterTypeDescriptionDefault
qstringThe search queryRequired
depthstringThe depth of the search ("shallow" or "deep")"deep"
outputTypestringThe type of output ("sourcedAnswer" or "raw")"sourcedAnswer"
structuredOutputSchemastringSchema for structured outputnull
includeImagesbooleanWhether to include images in the responsefalse

Response Structure

The linkup_search_response variable will contain:

{
  "answer": "The answer text",
  "sources": [
    {
      "name": "Source name",
      "url": "Source URL",
      "snippet": "Text snippet from the source"
    },
    //...
  ]
}

Example

Here’s a complete example of using the Linkup integration:

{
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Please provide information about Microsoft's 2024 revenue and cite your sources."}
  ],
    "linkup_params": {
      "q": "What is Microsoft's 2024 revenue?",
      "depth": "deep",
      "outputType": "sourcedAnswer",
      "includeImages": false
    },
  "variables": {
    "company_name": "Microsoft"
  },
  "model": "openai/gpt-4"
}

With a prompt template like:

Please provide information about {{ company_name }}'s 2024 revenue and cite your sources.

{% if linkup_search_response %}
Here's what I found:
{{ linkup_search_response.answer }}

Sources:
{% for source in linkup_search_response.sources %}
- {{ source.name }}: {{ source.url }}
{% endfor %}
{% endif %}

Error Handling

If there’s an error with the Linkup API call, it will be added to the warnings_dict in the response with the key LINKUP_SEARCH_ERROR.