-
Notifications
You must be signed in to change notification settings - Fork 0
11. Template Usage
Giannis Yfantidis edited this page Nov 15, 2023
·
3 revisions
This documentation provides essential information for creating and using templates in Gendox. Templates are a fundamental feature for generating dynamic content.
To create your own templates, follow these steps:
-
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.
- 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. |
To create your own templates, follow these steps:
-
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.
- 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. |
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.
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;
}