Web Search

Web search is a great way to use the entire web as a knowledge base for your AI. FreeToken supports web search proxy to third party providers. To enable web search, you will need to provide an API key from one of the supported providers. We store this API keys with 256-bit AES encryption on our servers and use it to make requests on your behalf.

How it Works

Essentially, web search is a function call that the model can use to make a search query. When the model decides to use web search, it will call the web_search function with a query string. FreeToken will then make a request to the third-party search provider and return the results to the model. The model will then interpret the results and provide a response to the user.

Enabling Web Search

This is a two step process. First, you need to provide an API key from one of the supported providers in your App's settings page. Then, you need to enable web search on your individual Agent(s).

To enable web search, you will need to provide an API key from one of the supported providers. To find the current list and add your key, sign in to the console and navigate to your app's settings page. From there, you can add your API key.

Then go to your the Agent and toggle on the "Enable Web Search" option. New device sessions will now have web search enabled.

Prompting

For agents that have web search enabled, we recommend that you prompt the model to use web search when appropriate and even provide a few examples that are relavant to your application. This will give the model a better chance of using web search when it is needed.

Here's a sample Agent instruction prompt:

You are a helpful assistant that can use web search to find information. When you need to find information that is not in your training use the `web_search` function call. 

Example of web_search usage:
USER: Who won the world series in 2020?
ASSISTANT: { "function": "web_search", "arguments": { "query": "2020 world series winner" } }

USER: What is the capital of Canada?
ASSISTANT: { "function": "web_search", "arguments": { "query": "capital of Canada" } }

Why Proxy?

We proxy the requests to third-party search providers for a few reasons:

  1. Security: By proxying the requests, we can ensure that your API keys are not exposed to the client. This is especially important for mobile and web applications where the client code can be easily inspected.
  2. Normalization: Different search providers have different APIs and response formats. By proxying the requests, we can normalize the responses and provide a consistent interface to the model.

I'm not comfortable with my search key being stored

No problem! You can always implement your own web search tool call that makes requests to your own backend server or directly to the search provider.