cookies
Excel integration: QUERIFAI_ASK_DOCS

The querifai Excel add-in allows access to the querifai Chat-with-Documents feature via Microsoft Excel. With this, you can create structured analyses of your documents within Microsoft Excel.

The plugin is essentially a custom VBA function, that adds the method QUERIFAI_ASK_DOCS() to all of your spreadsheets. You can either download the plugin here or find the code below together with instructions how to add it to your Excel.

Syntax

Excel
=QUERIFAI_ASK_DOCS("message", "actionId", "token", "systemMessage", "languageModel", "temperature")

              

Arguments

Argument Description
message (required)

The query that should be answered based on the information in your dataset.

actionId (required)

The action ID parameter is necessary to send your request to the correct dataset and embedding settings. You can find the action id in the small menu on the top-left of your dataset chat room.

token (required)

Your personal authenticated Excel webservice access token for your document embeddings. To protect your data, please generate a fresh token for each application. For increased data protection, we only allow a token to be maximally valid for 7 days. After your token is expired, you can generate token from account security

systemMessage (optional)

The system message serves as a guideline that shapes the responses of the model. It defines how the model should interact with users and handle their queries. For instance, a system message might instruct the model to adopt a formal tone, avoid certain topics, or prioritize specific types of information. It can also be used to instruct the model how context information should be treated by the model.

You can keep this parameter empty - we have already placed a well working default message that powers the chat-with-documents feature.

languageModel (optional)

querifai offers numerous language models that power different apps across the website. For the chat with documents feature you can choose from the following models: gpt-4, gpt-4o, querifai-gpt-35-turbo, cohere, chat-bison@001

Temperature (optional)

Temperature (0-1) controls the randomness of the model's output during text generation.

Low Temperature (close to 0): A lower temperature value makes the model's output more deterministic and focused. It reduces the likelihood of less probable words, resulting in more predictable and coherent responses.

High Temperature (close to 1): A higher temperature value increases randomness, allowing the model to explore a wider range of possible words. This can make the responses more creative and diverse but also increases the risk of generating less coherent or relevant text.

Microsoft Excel limits the length of string values in formulas to 255 characters. This means that together with your security token, the action id, the maximum length of a query inside this formula is very limited

To come arround this limitation, you can put all the inputs in seperate cells. For instance, you can structure the table as follows:

Example configuration of an Excel file.

And then you can form the request by entering the following formula in any cell.

Excel
=QUERIFAI_ASK_DOCS(B1, B2, B3, B4, B5, B6)

              

The Excel Add-in

You can install the add-in in two different ways:

You can either add the code manually to your Excel workbook, by opening the VBA-Editor (Press ALT+F11 when Excel is open), then in the menu on the left-hand-side of your screen right-click on your workbook and then select INSERT -> MODULE. Then place the following code into the editor:

VBA
Function QUERIFAI_ASK_DOCS(message As String, action_id As String, token As String, Optional systemMessage As String = "", Optional languageModel As String = "", Optional temperature As Double = 0) As String
    Dim http As Object
    Set http = CreateObject("MSXML2.ServerXMLHTTP")
    http.SetTimeouts 10000, 10000, 10000, 3600000
    Dim url As String
    url = "https://querifai.ai/chat-in-excel/" & action_id
    Dim data As String
    data = "message=" & message & "&system_message=" & systemMessage & "&model=" & languageModel & "&temperature=" & temperature & "&token=" & token
    http.Open "POST", url, False
    http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    http.setRequestHeader "Token", "Bearer " & token
    http.send (data)
    QUERIFAI_ASK_DOCS = http.responseText
End Function
            
                

Alternatively, you can download the add-in here and install it as an Excel plugin. Instructions can be found on the Microsoft Support website.

Common Problems

The following error messages may occur when you use the Excel add in:
Error message Description

Authentication Token is missing!

Make sure you are passing a token. If you don't have any token then you can create new token here

Authentication Token is invalid!

Make sure your token is not expired. You can create new token here

Invalid Temperature value. It must be in between 0 to 1

Pass temperature value between 0 to 1 like 0.5, 0.2 etc

Best practices

Do this Description

Use Cell references instead of direct content

When using Excel functions, be aware that there is a 255-character limit for direct content. To avoid issues, use cell references instead. This also makes formulas easier to read and update.

Use lower temperature value for consistent result

Temperature value decides how the LLM will write the response. For consistent result, the temperature value should be lower near to 0.