Custom Provider
Allowing easy integration with your existing LLM Provider with custom request and response format mappings.
Last updated
Allowing easy integration with your existing LLM Provider with custom request and response format mappings.
Last updated
With the Custom LLM Assisted Labeling Provider, users can provide custom request and response format mappings. These mappings will be used to construct HTTP Request Payloads (Body and Header) following the specified JSON structure. This feature will allow for easy integration with any existing LLM Provider.
The mapping system is based on the Open API Specification, with additional rules customized by Datasaur for processing.
Once you enable the ML Assisted Labeling in your project and choose LLM Assisted Labeling, you can access several fields under the extension. These fields include:
LLM Provider (select, required): “Custom LLM Provider” must be selected.
Target Text (multiple select, required): Define your text column(s) that is going to be treated as input and prompt context.
Target Question (select, required): Select your question to be answered.
System Prompt (text, optional): Sets the behavior and context for the language model.
User Prompt (text area, required): User definition of a task to be completed in a specific labeling workflow.
API Version (text, optional): The API Version from your Azure OpenAI.
API URL (text, required): The URL for your LLM provider API.
Model ID (text, optional): The name or ID of the model.
Top P (number, optional): Limits predictions to the smallest set with a cumulative probability of P.
Temperature (number, optional): Controls randomness; lower values make responses more predictable.
Additional Input (textarea, optional) – JSON format
The attribute of the JSON will be used in the process of transforming HTTP Request Body.
Request Headers (secret textarea, optional) – JSON format
The attributes of the JSON will be used as HTTP Request Headers when Datasaur calls the LLM Provider API.
For example, Datasaur will create an HTTP Request with header “Authorization” based on the value below.
{ "Authorization": "Bearer <access token>" }
Request Format Mapping Schema (textarea, required) – JSON Format.
Response Format Mapping Schema (textarea, required) – JSON Format.
This section defines the JSON mapping for constructing the HTTP request payload before sending it to the LLM Provider. The HTTP request payload is generated by following the schema and interpolating variables from the Form Input Fields based on the mapping.
The schema follows the OpenAPI Specification, with some adjustments. It supports string, integer, number, object, and array.
The value must contain a variable that allows Datasaur to retrieve the actual value when constructing the payload, e.g., "input.row", "input.model_id", etc. See the illustration:
Sample Payload
Sample Mapping Schema
Populate the "items" field with the variable containing the information to be represented as an array. Typically, "input.row" is used for this purpose. The field can accept either an actual array or a single object. If the data source is a single object, the resulting payload will be an array containing that single object, i.e. [ { … } ]. If the data source is an array, the payload will be an array of mapped items.
"items_mapping": Must be filled with instructions on how to map the data. Within "items_mapping", use the "item." variable to access individual items.
Sample Payload
Sample Mapping Schema
"input": Represents the Form Input Fields above. The mapping process interpolates the value of this variable.
“input.row”: Represent the row from the document with the following properties.
"row_id": The row number.
“user_prompt”: The combined User Prompt and Content from Target Text and Target Question.
"additional_input": Used for any additional values that need to be included. Use dot notation to access the custom attributes.
"item”: Arrays can be mapped by implementing mapping for each item within the array. This attribute can map an array or a single object. Datasaur automatically infers the actual value from the variable provided in the "items" attribute above. Built-in attributes are available to access the data.
“item.user_prompt”: Refers to the user_prompt for each object stored in the input.row variable.
Here is the OpenAPI Specification for "input" and "additional_input" variables:
This document contains three examples: Datasaur Custom API, OpenAI, and Gemini. For easier reference and understanding, below data will be used across all the examples.
User Prompt: "Text: {targetText}\n What is the sentiment for the text above? Choose one from the options below\n {targetOptions}\n Answer:"
targetText (part of the user prompt): "I feel good".
targetOptions (part of the user prompt, inferred from options in selected Target Question, separated by new line for each option): "positive\n negative\n".
Each example consists of:
The expected HTTP request body of a specific LLM provider.
The request format mapping example that will process the data and transform to the expected HTTP request body format above.
Any additional input that may be needed for a specific LLM provider to transform the data as expected.
Expected HTTP Request Body
Request Format Mapping Schema
Expected HTTP Request Body
Additional Input
Use the "additional_input.role" to provide the value of the required attribute of "user".
Request Format Mapping Schema
Expected HTTP Request Body
Request Format Mapping Schema
This section is dedicated to the JSON mapping for transforming the LLM Provider's response to match Datasaur's Expected Response Format, ensuring proper label ingestion and applying the label correctly.
The mapping utilizes keyword "response" with dot notation to access attributes.
The whole HTTP response body will be referenced as the "response" variable.
Here is the OpenAPI specification:
In short, create the mapping using the below placeholder by filling out the variables.
Essentially, the examples below will explain how to define a response format mapping for a specific API response so that it will be compatible for ingestion in Datasaur.
Original HTTP Response Body Format
Response Format Mapping Schema
Need to map the "id" from the above response as "row_id".
Original HTTP Response Body Format
Response Format Mapping Schema
The mapping below will use the “response.choices” as the array of LLM Response. The “item_mapping” will also be used to get the message and the index.
Original HTTP Response Body Format
Response Format Mapping Schema
Ignore the inline image and use the response to select the label like the following:
\