Skip to content

Commit b1e3a8d

Browse files
authored
[Tock Studio] Refacto of Gen AI prompt settings (theopenconversationkit#1833)
* Wip * Wip * Wip * Gen AI prompt settings refacto * Misc * Misc improvements
1 parent 02dd9e7 commit b1e3a8d

21 files changed

+1359
-689
lines changed

bot/admin/web/src/app/configuration/compressor-settings/compressor-settings.component.html

+79-69
Original file line numberDiff line numberDiff line change
@@ -58,80 +58,90 @@ <h1 class="flex-grow-1">Documents compressor settings</h1>
5858
*ngIf="configurations?.length > 0"
5959
>
6060
<nb-card class="mt-1">
61-
<nb-card-body [nbSpinner]="loading">
62-
<h5 class="section-title">Compressor activation</h5>
63-
64-
<tock-form-control
65-
name="enabled"
66-
[controls]="enabled"
67-
[showError]="isSubmitted"
68-
[hasMargin]="false"
69-
>
70-
<nb-toggle
71-
formControlName="enabled"
72-
class="mt-1"
73-
>
74-
<span *ngIf="enabled.value">Compressor activated</span>
75-
<span *ngIf="!enabled.value">Compressor deactivated</span>
76-
</nb-toggle>
77-
</tock-form-control>
78-
79-
<h5 class="section-title">Compressor provider</h5>
80-
81-
<tock-form-control
82-
name="compressorProvider"
83-
[controls]="compressorProvider"
84-
[required]="true"
85-
[showError]="isSubmitted"
86-
>
87-
<nb-radio-group
88-
formControlName="compressorProvider"
89-
name="compressorProvider"
90-
class="d-flex"
91-
>
92-
<nb-radio
93-
*ngFor="let provider of providersConfigurations"
94-
[value]="provider.key"
61+
<nb-card-body
62+
[nbSpinner]="loading"
63+
class="pb-0"
64+
>
65+
<nb-card class="mt-2">
66+
<nb-card-header>Compressor activation</nb-card-header>
67+
<nb-card-body>
68+
<tock-form-control
69+
name="enabled"
70+
[controls]="enabled"
71+
[showError]="isSubmitted"
72+
[hasMargin]="false"
9573
>
96-
{{ provider.label }}
97-
</nb-radio>
98-
</nb-radio-group>
99-
</tock-form-control>
74+
<nb-toggle
75+
formControlName="enabled"
76+
class="mt-1"
77+
>
78+
<span *ngIf="enabled.value">Compressor activated</span>
79+
<span *ngIf="!enabled.value">Compressor deactivated</span>
80+
</nb-toggle>
81+
</tock-form-control>
82+
</nb-card-body>
83+
</nb-card>
10084

101-
<div
102-
*ngIf="currentCompressorProvider"
103-
class="mt-2 mb-2"
104-
>
105-
<div class="row mb-1">
106-
<ng-container *ngFor="let param of currentCompressorProvider.params">
107-
<div
108-
class="col-6 px-3"
109-
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
85+
<nb-card>
86+
<nb-card-header>Compressor provider</nb-card-header>
87+
<nb-card-body>
88+
<tock-form-control
89+
name="compressorProvider"
90+
[controls]="compressorProvider"
91+
[required]="true"
92+
[showError]="isSubmitted"
93+
>
94+
<nb-radio-group
95+
formControlName="compressorProvider"
96+
name="compressorProvider"
97+
class="d-flex"
11098
>
111-
<tock-ai-settings-engine-config-param-input
112-
parentGroup="setting"
113-
[configurationParam]="param"
114-
[form]="form"
115-
[isSubmitted]="isSubmitted"
116-
></tock-ai-settings-engine-config-param-input>
117-
</div>
118-
</ng-container>
119-
</div>
120-
</div>
99+
<nb-radio
100+
*ngFor="let provider of providersConfigurations"
101+
[value]="provider.key"
102+
>
103+
{{ provider.label }}
104+
</nb-radio>
105+
</nb-radio-group>
106+
</tock-form-control>
121107

122-
<ng-container *ngIf="settingsBackup">
123-
<h5 class="section-title mt-2">Settings deletion</h5>
108+
<div
109+
*ngIf="currentCompressorProvider"
110+
class="mt-2 mb-2"
111+
>
112+
<div class="row mb-1">
113+
<ng-container *ngFor="let param of currentCompressorProvider.params">
114+
<div
115+
class="col-6 px-3"
116+
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
117+
>
118+
<tock-ai-settings-engine-config-param-input
119+
parentGroup="setting"
120+
[configurationParam]="param"
121+
[form]="form"
122+
[isSubmitted]="isSubmitted"
123+
></tock-ai-settings-engine-config-param-input>
124+
</div>
125+
</ng-container>
126+
</div>
127+
</div>
128+
</nb-card-body>
129+
</nb-card>
124130

125-
<button
126-
nbButton
127-
status="danger"
128-
nbTooltip="Delete settings"
129-
(click)="confirmSettingsDeletion()"
130-
>
131-
<nb-icon icon="trash"></nb-icon>
132-
DELETE SETTINGS
133-
</button>
134-
</ng-container>
131+
<nb-card *ngIf="settingsBackup">
132+
<nb-card-header>Settings deletion</nb-card-header>
133+
<nb-card-body>
134+
<button
135+
nbButton
136+
status="danger"
137+
nbTooltip="Delete settings"
138+
(click)="confirmSettingsDeletion()"
139+
>
140+
<nb-icon icon="trash"></nb-icon>
141+
DELETE SETTINGS
142+
</button>
143+
</nb-card-body>
144+
</nb-card>
135145
</nb-card-body>
136146
</nb-card>
137147
</form>

bot/admin/web/src/app/configuration/observability-settings/observability-settings.component.html

+79-69
Original file line numberDiff line numberDiff line change
@@ -58,80 +58,90 @@ <h1 class="flex-grow-1">Observability settings</h1>
5858
*ngIf="configurations?.length > 0"
5959
>
6060
<nb-card class="mt-1">
61-
<nb-card-body [nbSpinner]="loading">
62-
<h5 class="section-title">Observability activation</h5>
63-
64-
<tock-form-control
65-
name="enabled"
66-
[controls]="enabled"
67-
[showError]="isSubmitted"
68-
[hasMargin]="false"
69-
>
70-
<nb-toggle
71-
formControlName="enabled"
72-
class="mt-1"
73-
>
74-
<span *ngIf="enabled.value">Observability activated</span>
75-
<span *ngIf="!enabled.value">Observability deactivated</span>
76-
</nb-toggle>
77-
</tock-form-control>
78-
79-
<h5 class="section-title">Observability provider</h5>
80-
81-
<tock-form-control
82-
name="observabilityProvider"
83-
[controls]="observabilityProvider"
84-
[required]="true"
85-
[showError]="isSubmitted"
86-
>
87-
<nb-radio-group
88-
formControlName="observabilityProvider"
89-
name="observabilityProvider"
90-
class="d-flex"
91-
>
92-
<nb-radio
93-
*ngFor="let provider of providersConfigurations"
94-
[value]="provider.key"
61+
<nb-card-body
62+
[nbSpinner]="loading"
63+
class="pb-0"
64+
>
65+
<nb-card class="mt-2">
66+
<nb-card-header>Observability activation</nb-card-header>
67+
<nb-card-body>
68+
<tock-form-control
69+
name="enabled"
70+
[controls]="enabled"
71+
[showError]="isSubmitted"
72+
[hasMargin]="false"
9573
>
96-
{{ provider.label }}
97-
</nb-radio>
98-
</nb-radio-group>
99-
</tock-form-control>
74+
<nb-toggle
75+
formControlName="enabled"
76+
class="mt-1"
77+
>
78+
<span *ngIf="enabled.value">Observability activated</span>
79+
<span *ngIf="!enabled.value">Observability deactivated</span>
80+
</nb-toggle>
81+
</tock-form-control>
82+
</nb-card-body>
83+
</nb-card>
10084

101-
<div
102-
*ngIf="currentObservabilityProvider"
103-
class="mt-2 mb-2"
104-
>
105-
<div class="row mb-1">
106-
<ng-container *ngFor="let param of currentObservabilityProvider.params">
107-
<div
108-
class="col-6 px-3"
109-
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
85+
<nb-card>
86+
<nb-card-header>Observability provider</nb-card-header>
87+
<nb-card-body>
88+
<tock-form-control
89+
name="observabilityProvider"
90+
[controls]="observabilityProvider"
91+
[required]="true"
92+
[showError]="isSubmitted"
93+
>
94+
<nb-radio-group
95+
formControlName="observabilityProvider"
96+
name="observabilityProvider"
97+
class="d-flex"
11098
>
111-
<tock-ai-settings-engine-config-param-input
112-
parentGroup="setting"
113-
[configurationParam]="param"
114-
[form]="form"
115-
[isSubmitted]="isSubmitted"
116-
></tock-ai-settings-engine-config-param-input>
117-
</div>
118-
</ng-container>
119-
</div>
120-
</div>
99+
<nb-radio
100+
*ngFor="let provider of providersConfigurations"
101+
[value]="provider.key"
102+
>
103+
{{ provider.label }}
104+
</nb-radio>
105+
</nb-radio-group>
106+
</tock-form-control>
121107

122-
<ng-container *ngIf="settingsBackup">
123-
<h5 class="section-title mt-2">Settings deletion</h5>
108+
<div
109+
*ngIf="currentObservabilityProvider"
110+
class="mt-2 mb-2"
111+
>
112+
<div class="row mb-1">
113+
<ng-container *ngFor="let param of currentObservabilityProvider.params">
114+
<div
115+
class="col-6 px-3"
116+
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
117+
>
118+
<tock-ai-settings-engine-config-param-input
119+
parentGroup="setting"
120+
[configurationParam]="param"
121+
[form]="form"
122+
[isSubmitted]="isSubmitted"
123+
></tock-ai-settings-engine-config-param-input>
124+
</div>
125+
</ng-container>
126+
</div>
127+
</div>
128+
</nb-card-body>
129+
</nb-card>
124130

125-
<button
126-
nbButton
127-
status="danger"
128-
nbTooltip="Delete settings"
129-
(click)="confirmSettingsDeletion()"
130-
>
131-
<nb-icon icon="trash"></nb-icon>
132-
DELETE SETTINGS
133-
</button>
134-
</ng-container>
131+
<nb-card *ngIf="settingsBackup">
132+
<nb-card-header>Settings deletion</nb-card-header>
133+
<nb-card-body>
134+
<button
135+
nbButton
136+
status="danger"
137+
nbTooltip="Delete settings"
138+
(click)="confirmSettingsDeletion()"
139+
>
140+
<nb-icon icon="trash"></nb-icon>
141+
DELETE SETTINGS
142+
</button>
143+
</nb-card-body>
144+
</nb-card>
135145
</nb-card-body>
136146
</nb-card>
137147
</form>

bot/admin/web/src/app/configuration/sentence-generation-settings/models/engines-configuration.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import {
33
EnginesConfiguration,
44
AiEngineProvider,
55
OllamaLlmModelsList,
6-
OpenAIModelsList
6+
OpenAIModelsList,
7+
ProvidersConfigurationParam,
8+
PromptDefinitionFormatter
79
} from '../../../shared/model/ai-settings';
810

911
export const DefaultPrompt: string = `# Sentences generation instructions
@@ -38,6 +40,25 @@ Answer in '{{locale}}' (language locale).
3840
## Generated sentences
3941
`;
4042

43+
export const SentenceGeneration_prompt: ProvidersConfigurationParam[] = [
44+
{
45+
key: 'formatter',
46+
label: 'Prompt template format',
47+
type: 'radio',
48+
source: [PromptDefinitionFormatter.jinja2, PromptDefinitionFormatter.fstring],
49+
defaultValue: PromptDefinitionFormatter.jinja2,
50+
inputScale: 'fullwidth'
51+
},
52+
{
53+
key: 'template',
54+
label: 'Prompt template',
55+
type: 'prompt',
56+
inputScale: 'fullwidth',
57+
defaultValue: DefaultPrompt,
58+
rows: 16
59+
}
60+
];
61+
4162
export const EngineConfigurations: EnginesConfiguration[] = [
4263
{
4364
label: 'OpenAi',
@@ -46,8 +67,7 @@ export const EngineConfigurations: EnginesConfiguration[] = [
4667
{ key: 'apiKey', label: 'Api key', type: 'obfuscated', confirmExport: true },
4768
{ key: 'baseUrl', label: 'Base url', type: 'text', defaultValue: 'https://api.openai.com/v1' },
4869
{ key: 'model', label: 'Model name', type: 'openlist', source: OpenAIModelsList },
49-
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 },
50-
{ key: 'prompt', label: 'Prompt', type: 'prompt', inputScale: 'fullwidth', defaultValue: DefaultPrompt }
70+
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 }
5171
]
5272
},
5373
{
@@ -59,8 +79,7 @@ export const EngineConfigurations: EnginesConfiguration[] = [
5979
{ key: 'deploymentName', label: 'Deployment name', type: 'text' },
6080
{ key: 'model', label: 'Model name', type: 'openlist', source: OpenAIModelsList },
6181
{ key: 'apiBase', label: 'Base url', type: 'obfuscated' },
62-
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 },
63-
{ key: 'prompt', label: 'Prompt', type: 'prompt', inputScale: 'fullwidth', defaultValue: DefaultPrompt }
82+
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 }
6483
]
6584
},
6685
{
@@ -69,8 +88,7 @@ export const EngineConfigurations: EnginesConfiguration[] = [
6988
params: [
7089
{ key: 'baseUrl', label: 'Base url', type: 'text', defaultValue: 'http://localhost:11434' },
7190
{ key: 'model', label: 'Model', type: 'openlist', source: OllamaLlmModelsList, defaultValue: 'llama2' },
72-
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05, defaultValue: 0.7 },
73-
{ key: 'prompt', label: 'Prompt', type: 'prompt', inputScale: 'fullwidth', defaultValue: DefaultPrompt }
91+
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05, defaultValue: 0.7 }
7492
]
7593
}
7694
];
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { llmSetting } from '../../../shared/model/ai-settings';
1+
import { PromptDefinition, llmSetting } from '../../../shared/model/ai-settings';
22

33
export interface SentenceGenerationSettings {
44
id: string;
@@ -7,4 +7,5 @@ export interface SentenceGenerationSettings {
77
enabled: boolean;
88

99
llmSetting: llmSetting;
10+
prompt: PromptDefinition;
1011
}

0 commit comments

Comments
 (0)