Skip to content

11. Template Usage

Giannis Yfantidis edited this page Nov 15, 2023 · 3 revisions

11. Template Usage Documentation

This documentation provides essential information for creating and using templates in Gendox. Templates are a fundamental feature for generating dynamic content.

11.1 Section Template

Creating Your Own Templates

To create your own templates, follow these steps:

  1. Define a Template: Start by defining a template text with placeholders for dynamic data. Placeholders are enclosed in ${...} and will be replaced with actual data when generating documents or messages.

Example Teplate:

              Title: ${documentTitle} ${sectionText}
              Source: ${source}
              User: ${user}
              ----------------                

In this example, ${...} placeholders represent variables that will be replaced with specific values.

  1. Available Template Variables: You can use the following template variables in your custom templates. These variables will be replaced with relevant data:
Variable Description
${document.title} The title of the initial document.
${section.text} The text of the document section.
${source} Link to the document.
${user} The user who created the initial document.

11.2 Chat Template

Creating Your Own Templates

To create your own templates, follow these steps:

  1. Define a Template: Start by defining a template text with placeholders for dynamic data. Placeholders are enclosed in ${...} and will be replaced with actual data when generating documents or messages.

Example Teplate:

              Context:  ${context}
              Question: ${question}               

In this example, ${...} placeholders represent variables that will be replaced with specific values.

  1. Available Template Variables: You can use the following template variables in your custom templates. These variables will be replaced with relevant data:
Variable Description
${context} The sections template context.
${question} The users question.

11.3 Using Templates

After creating your template, you can use it with the Gendox system to generate documents or messages. The template will be processed, and placeholders will be replaced with actual data from the system.

Example Usage

Here's an example of how to use a template in Java code:

String customTemplate =
    "Hello ${user}! Here is the latest information:\n-
    Title: ${document.title}\n-
    Section Text: ${section.text}\n- Source: ${source}";

// Replace template variables with actual values
String processedTemplate = processTemplate(customTemplate, templateValues);

public String convertToGPTTextQuestion(Message message,
                                        List<DocumentInstanceSection>
                                        nearestSections, UUID projectId)
                                        throws GendoxException {
    // ...

    ProjectAgent agent = projectAgentRepository.findByProjectId(projectId);
    Template agentSectionTemplate = templateRepository.findByIdIs(agent.getSectionTemplateId);
    Template agentChatTemplate = templateRepository.findByIdIs(agent.getChatTemplateId);

    // ...

    return answer;
}



 




Clone this wiki locally