Data source transformer

The data source transformer allows you to add rules for transforming data from a source, as an alternative to modifying the original data source.

The data source transformer is a good sustainable alternative if you do not want to manually change specific documents or upload static files with information to the bot. By adding transformer rules to a source those rules will be applied for all future updates of the sources, no matter if it's a webscrape or API-source.

Note: The transformer is an advanced feature intended for users with coding experience. If you're not familiar with coding, we recommend starting with a pre-built template below.

Basics - Start here

Important: Your transformer code must include all the fields you want to import into Ebbot. include all the fields that you want imported into ebbot.

The image above shows an example CSV with three columns: id, question, and answer. To apply transformer code to this CSV, all of these columns must be included like in the code snippet below.

Use cases

Replace and/or remove text

Modifying text in sources can help both the embedder service and the GPT model more easily retrieve sources and provide specific answers to questions.

  • Add synonyms

  • Add example questions

  • Remove conflicting information

Below is an example of how to add the rule of replacing the word 'recycle' with 'recycle, throw away or discard' as a way of adding synonyms to sources giving instructions on how to recycle.

Add keywords in new field based on document ID

If you want to add keywords in a new field based on a document ID you can use the following logic. <field_to_look_at> in this case would be the ID-field, and <field_to_write_to> is the new field with the keywords. X should be replaced with the document's ID and Y with the keywords you want that document to have.

Below are all possible transformations

Templates to copy

Webscrape - replace text in content column

The code below will work for all web scrapes and is set up to replace text in the content column. All you need to to do is add text that should be removed and replaced in the replace section of the code.

Last updated

Was this helpful?