Chat Methods

A chat method is a named group of settings for managing a TrainMyAI chat. When a user starts a new chat via the TrainMyAI website, they can select which chat method to use.

TrainMyAI comes with the following built-in methods:

  • For ChatGPT remote language model: Faster (GPT-4o mini) uses 5 reference paragraphs per interaction, Deeper (GPT-4o mini) uses 10 references, Faster (GPT-4o) uses 5 refs and Deeper (GPT-4o) uses 10 refs.
  • For Llama 3 local language model: Faster chat (Llama 3) uses 5 refs and Deeper chat (Llama 3) uses 10 refs.

As well as specifying the language model and number of reference paragraphs for retrieval augmented generation (RAG), each method sets the prompts to use and the level of variation between answers to the same question.

Chat methods can easily be added, removed and customized by following these steps:

  • Log in to your server and use cd to navigate to the trainmyai directory.
  • Use mkdir settings to create a new settings directory alongside settings-default.
  • Use cp settings-default/methods.ini settings/methods.ini to make a copy of the methods file.
  • Use your favorite text editor to read the settings/methods.ini file and start editing.
If there is a methods.ini file in the settings directory, it will completely override methods.ini in settings-default.

Web Pages and Styles

Every web page generated by TrainMyAI can be easily customized in terms of HTML content and CSS styles.

In order to start modifying web pages, follow these steps:

  • Log in to your server and use cd to navigate to the trainmyai directory.
  • Use mkdir templates to create a new templates directory alongside templates-default.
  • To change the HTML/PHP template for a page, use ls templates-default to see a list of page templates and choose which <page> to start with (see explanation below). Use cp templates-default/<page>.php templates/<page>.php to make a copy of that page's template and then start editing the copied template in templates/<page>.php.
  • To change the CSS styles for your site, use cp -R templates-default/css templates to make a copy of the CSS directory and then start editing the copied CSS in templates/css/trainmyai.css.

Any file in the templates directory will completely override the file in templates-default with the same path.

In most cases, the HTML/PHP template file for a TrainMyAI web page is obvious from its name. Below are less obvious ones:

  • Files with a - hyphen in their name generate a page section which is dynamically loaded using JavaScript. For example, chat-meta.php is the template for the meta information panel in chat.php.
  • The standard.php template sets the overall structure for all HTML web pages except the chat iframe.
  • The history.php template is used to show the chat history for both users and knowledge bases.
  • The titles.php and messages.php files contain lists of strings and are not HTML templates. They allow the localization and customization of HTML web page titles and status messages respectively.

Content Preprocessing

Content that is added to TrainMyAI is preprocessed before being added to a knowledge base. For example, short paragraphs and question paragraphs are disabled, and long paragraphs can be split. Beginning in TrainMyAI version 1.3, the built-in preprocessors can be customized, and you can implement your own preprocessors using PHP.

In TrainMyAI 1.3+, the settings for the built-in preprocessors can be changed as follows:

  • Log in to your server and use cd to navigate to the trainmyai directory.
  • Use mkdir settings to create a new settings directory alongside settings-default.
  • Use cp settings-default/preprocessors.ini settings/preprocessors.ini to copy the settings file.
  • Use your favorite text editor to read the settings/preprocessors.ini file and start editing.

To create your own preprocessor in TrainMyAI 1.3+, some PHP programming is required:

  • First, follow the steps above to create a custom settings/preprocessors.ini file.
  • In the trainmyai directory, use mkdir preprocessors to create a directory for your preprocessor's code.
  • Create a new file preprocessors/pre_my_preprocessor.php containing this stub code.
  • Add a section to settings/preprocessors.ini with the heading [my_preprocessor] and the setting enabled = on.
  • Read the explanation within preprocessors/pre_my_preprocessor.php to implement your preprocessor.
  • The behavior of your preprocessor can be tested by adding content through the web interface or the API.
  • Any settings for your preprocessor can be set in its section of settings/preprocessors.ini, and are passed to its function in the $param variable. To disable your preprocessor, set enabled = off in its section.

These instructions are for a preprocessor named my_preprocessor. If you prefer to use a different <name>, rename its file to pre_<name>.php, its function to pre_<name>(...) and its section in preprocessors.ini to [<name>].

Content Optimization

If content optimization is turned on for a knowledge base, TrainMyAI will use a language model to automatically create additional paragraphs from that knowledge base's content. When answering a user's question in the AI chat, TrainMyAI uses the best reference paragraphs from both the original and optimized content.

The default optimization method breaks the original content into 500 word chunks (with 20% overlap) and then uses the (remote or local) language model to create question-answer pairs from those chunks. Many aspects of the content optimization can be customized by following these steps:

  • Log in to your server and use cd to navigate to the trainmyai directory.
  • Use mkdir settings to create a new settings directory alongside settings-default.
  • Use cp settings-default/optimization.ini settings/optimization.ini to make a copy of the optimization file.
  • Use your favorite text editor to read the settings/optimization.ini file and start editing.
TrainMyAI supports multiple optimization methods, each defined in its own [tagged section]. If there is an optimization.ini file in the settings directory, it will completely override optimization.ini in settings-default.

Other Settings

There are many additional settings available in TrainMyAI, e.g. to limit the size of content files or set the number of items displayed per page in each type of list. In order to view and modify these settings, follow these steps:

  • Log in to your server and use cd to navigate to the trainmyai directory.
  • Use cat settings-default/constants.ini to view the full list of settings.
  • Use mkdir settings to create a new settings directory alongside settings-default.
  • Use your favorite text editor to create and edit a file constants.ini in this settings directory.
  • Add a single line [constants] followed by the individual settings to modify.

Any setting in settings/constants.ini will override the corresponding default in settings-default/constants.ini. Your constants.ini file should only contain the settings you wish to modify.

Getting help

If you encounter any problems with customizing TrainMyAI, please contact us and we'll be happy to help.