Skip to main content

Function AskAI()

Execute any custom prompt to process and analyze your data

Written by Erik

Use AskAI() to analyze your text data and, optionally, an array of images, with OpenAI's ChatGPT. Mapsly supports any OpenAI latest models.

Contact us in chat or at [email protected], and our solution engineers will help you implement AI analysis of your data and generate efficient AI prompts.

How to use

Use the function by passing the prompt as the first argument (required) and an array of image IDs (optional):

  • AskAI(prompt)

  • AskAI(prompt, [fileIds], [openAIApiKey = null], [model = null], [assistantId = null], [threadId = null], [storageId = null])

    Note. To skip parameters in the middle, delimit with null and a coma (unless it's the last parameter). If more than a single fileId is submitted, the square brackets are required and the fileIds shall be delimited with coma.

    Note. Fields can be either submitted as a 2nd parameter or be a part of the prompt.

Input

  • prompt: your prompt that may include instructions for the AI, questions, and text input to be analyzed

    If you need to submit records' field values in the prompt, use "~" symbol to concatinate the prompt. Example: {{ AskAI("I'll provide you the address in coordinates, try to return me an address in text form. Here they are: " ~ record.mapsly_geo_lat ~ "," ~ record.mapsly_geo_lng) }}

    Note. Contact us in chat or at [email protected], and our solution engineers will help you create prompts for your particular use scenarios.

  • fileIds (optional): an array of file IDs, each containing an image that you would like the AI to analyze

    Note. Both the File field on a Form, and the Files data field in Mapsly objects like Check-in and Route activity, contain an array of file IDs, so their values can be passed to AskAI() as the fileIds parameter

  • openAIApiKey (optional): use your own OpenAI API key to supply your custom instructions, use vector storage and manage threads. In this case your Mapsly AI credits are not consumed

  • model: overrides the default model by name. Only takes effect when openAIApiKey is also provided (otherwise ignored)

  • assistantId: a specific prompt ID from https://platform.openai.com/chat with custom instructions

  • threadId: the conversation ID from a previous chat. After execution we write the resulting thread ID back to the context as aiResult.threadId, so you can reuse it in subsequent calls

  • storageId: the ID of a specific vector store from https://platform.openai.com/storage/vector_stores. Only takes effect when openAIApiKey is also provided

Output

A response message from the OpenAI model. To reuse the response further in the context, assign the function to a variable

The results will be available in the execution context

Did this answer your question?