Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tock Studio] Refacto of Gen AI prompt settings #1833

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,80 +58,90 @@ <h1 class="flex-grow-1">Documents compressor settings</h1>
*ngIf="configurations?.length > 0"
>
<nb-card class="mt-1">
<nb-card-body [nbSpinner]="loading">
<h5 class="section-title">Compressor activation</h5>

<tock-form-control
name="enabled"
[controls]="enabled"
[showError]="isSubmitted"
[hasMargin]="false"
>
<nb-toggle
formControlName="enabled"
class="mt-1"
>
<span *ngIf="enabled.value">Compressor activated</span>
<span *ngIf="!enabled.value">Compressor deactivated</span>
</nb-toggle>
</tock-form-control>

<h5 class="section-title">Compressor provider</h5>

<tock-form-control
name="compressorProvider"
[controls]="compressorProvider"
[required]="true"
[showError]="isSubmitted"
>
<nb-radio-group
formControlName="compressorProvider"
name="compressorProvider"
class="d-flex"
>
<nb-radio
*ngFor="let provider of providersConfigurations"
[value]="provider.key"
<nb-card-body
[nbSpinner]="loading"
class="pb-0"
>
<nb-card class="mt-2">
<nb-card-header>Compressor activation</nb-card-header>
<nb-card-body>
<tock-form-control
name="enabled"
[controls]="enabled"
[showError]="isSubmitted"
[hasMargin]="false"
>
{{ provider.label }}
</nb-radio>
</nb-radio-group>
</tock-form-control>
<nb-toggle
formControlName="enabled"
class="mt-1"
>
<span *ngIf="enabled.value">Compressor activated</span>
<span *ngIf="!enabled.value">Compressor deactivated</span>
</nb-toggle>
</tock-form-control>
</nb-card-body>
</nb-card>

<div
*ngIf="currentCompressorProvider"
class="mt-2 mb-2"
>
<div class="row mb-1">
<ng-container *ngFor="let param of currentCompressorProvider.params">
<div
class="col-6 px-3"
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
<nb-card>
<nb-card-header>Compressor provider</nb-card-header>
<nb-card-body>
<tock-form-control
name="compressorProvider"
[controls]="compressorProvider"
[required]="true"
[showError]="isSubmitted"
>
<nb-radio-group
formControlName="compressorProvider"
name="compressorProvider"
class="d-flex"
>
<tock-ai-settings-engine-config-param-input
parentGroup="setting"
[configurationParam]="param"
[form]="form"
[isSubmitted]="isSubmitted"
></tock-ai-settings-engine-config-param-input>
</div>
</ng-container>
</div>
</div>
<nb-radio
*ngFor="let provider of providersConfigurations"
[value]="provider.key"
>
{{ provider.label }}
</nb-radio>
</nb-radio-group>
</tock-form-control>

<ng-container *ngIf="settingsBackup">
<h5 class="section-title mt-2">Settings deletion</h5>
<div
*ngIf="currentCompressorProvider"
class="mt-2 mb-2"
>
<div class="row mb-1">
<ng-container *ngFor="let param of currentCompressorProvider.params">
<div
class="col-6 px-3"
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
>
<tock-ai-settings-engine-config-param-input
parentGroup="setting"
[configurationParam]="param"
[form]="form"
[isSubmitted]="isSubmitted"
></tock-ai-settings-engine-config-param-input>
</div>
</ng-container>
</div>
</div>
</nb-card-body>
</nb-card>

<button
nbButton
status="danger"
nbTooltip="Delete settings"
(click)="confirmSettingsDeletion()"
>
<nb-icon icon="trash"></nb-icon>
DELETE SETTINGS
</button>
</ng-container>
<nb-card *ngIf="settingsBackup">
<nb-card-header>Settings deletion</nb-card-header>
<nb-card-body>
<button
nbButton
status="danger"
nbTooltip="Delete settings"
(click)="confirmSettingsDeletion()"
>
<nb-icon icon="trash"></nb-icon>
DELETE SETTINGS
</button>
</nb-card-body>
</nb-card>
</nb-card-body>
</nb-card>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,80 +58,90 @@ <h1 class="flex-grow-1">Observability settings</h1>
*ngIf="configurations?.length > 0"
>
<nb-card class="mt-1">
<nb-card-body [nbSpinner]="loading">
<h5 class="section-title">Observability activation</h5>

<tock-form-control
name="enabled"
[controls]="enabled"
[showError]="isSubmitted"
[hasMargin]="false"
>
<nb-toggle
formControlName="enabled"
class="mt-1"
>
<span *ngIf="enabled.value">Observability activated</span>
<span *ngIf="!enabled.value">Observability deactivated</span>
</nb-toggle>
</tock-form-control>

<h5 class="section-title">Observability provider</h5>

<tock-form-control
name="observabilityProvider"
[controls]="observabilityProvider"
[required]="true"
[showError]="isSubmitted"
>
<nb-radio-group
formControlName="observabilityProvider"
name="observabilityProvider"
class="d-flex"
>
<nb-radio
*ngFor="let provider of providersConfigurations"
[value]="provider.key"
<nb-card-body
[nbSpinner]="loading"
class="pb-0"
>
<nb-card class="mt-2">
<nb-card-header>Observability activation</nb-card-header>
<nb-card-body>
<tock-form-control
name="enabled"
[controls]="enabled"
[showError]="isSubmitted"
[hasMargin]="false"
>
{{ provider.label }}
</nb-radio>
</nb-radio-group>
</tock-form-control>
<nb-toggle
formControlName="enabled"
class="mt-1"
>
<span *ngIf="enabled.value">Observability activated</span>
<span *ngIf="!enabled.value">Observability deactivated</span>
</nb-toggle>
</tock-form-control>
</nb-card-body>
</nb-card>

<div
*ngIf="currentObservabilityProvider"
class="mt-2 mb-2"
>
<div class="row mb-1">
<ng-container *ngFor="let param of currentObservabilityProvider.params">
<div
class="col-6 px-3"
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
<nb-card>
<nb-card-header>Observability provider</nb-card-header>
<nb-card-body>
<tock-form-control
name="observabilityProvider"
[controls]="observabilityProvider"
[required]="true"
[showError]="isSubmitted"
>
<nb-radio-group
formControlName="observabilityProvider"
name="observabilityProvider"
class="d-flex"
>
<tock-ai-settings-engine-config-param-input
parentGroup="setting"
[configurationParam]="param"
[form]="form"
[isSubmitted]="isSubmitted"
></tock-ai-settings-engine-config-param-input>
</div>
</ng-container>
</div>
</div>
<nb-radio
*ngFor="let provider of providersConfigurations"
[value]="provider.key"
>
{{ provider.label }}
</nb-radio>
</nb-radio-group>
</tock-form-control>

<ng-container *ngIf="settingsBackup">
<h5 class="section-title mt-2">Settings deletion</h5>
<div
*ngIf="currentObservabilityProvider"
class="mt-2 mb-2"
>
<div class="row mb-1">
<ng-container *ngFor="let param of currentObservabilityProvider.params">
<div
class="col-6 px-3"
[ngClass]="{ 'col-12': param.inputScale === 'fullwidth' }"
>
<tock-ai-settings-engine-config-param-input
parentGroup="setting"
[configurationParam]="param"
[form]="form"
[isSubmitted]="isSubmitted"
></tock-ai-settings-engine-config-param-input>
</div>
</ng-container>
</div>
</div>
</nb-card-body>
</nb-card>

<button
nbButton
status="danger"
nbTooltip="Delete settings"
(click)="confirmSettingsDeletion()"
>
<nb-icon icon="trash"></nb-icon>
DELETE SETTINGS
</button>
</ng-container>
<nb-card *ngIf="settingsBackup">
<nb-card-header>Settings deletion</nb-card-header>
<nb-card-body>
<button
nbButton
status="danger"
nbTooltip="Delete settings"
(click)="confirmSettingsDeletion()"
>
<nb-icon icon="trash"></nb-icon>
DELETE SETTINGS
</button>
</nb-card-body>
</nb-card>
</nb-card-body>
</nb-card>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
EnginesConfiguration,
AiEngineProvider,
OllamaLlmModelsList,
OpenAIModelsList
OpenAIModelsList,
ProvidersConfigurationParam,
PromptDefinitionFormatter
} from '../../../shared/model/ai-settings';

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

export const SentenceGeneration_prompt: ProvidersConfigurationParam[] = [
{
key: 'formatter',
label: 'Prompt template format',
type: 'radio',
source: [PromptDefinitionFormatter.jinja2, PromptDefinitionFormatter.fstring],
defaultValue: PromptDefinitionFormatter.jinja2,
inputScale: 'fullwidth'
},
{
key: 'template',
label: 'Prompt template',
type: 'prompt',
inputScale: 'fullwidth',
defaultValue: DefaultPrompt,
rows: 16
}
];

export const EngineConfigurations: EnginesConfiguration[] = [
{
label: 'OpenAi',
Expand All @@ -46,8 +67,7 @@ export const EngineConfigurations: EnginesConfiguration[] = [
{ key: 'apiKey', label: 'Api key', type: 'obfuscated', confirmExport: true },
{ key: 'baseUrl', label: 'Base url', type: 'text', defaultValue: 'https://api.openai.com/v1' },
{ key: 'model', label: 'Model name', type: 'openlist', source: OpenAIModelsList },
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 },
{ key: 'prompt', label: 'Prompt', type: 'prompt', inputScale: 'fullwidth', defaultValue: DefaultPrompt }
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 }
]
},
{
Expand All @@ -59,8 +79,7 @@ export const EngineConfigurations: EnginesConfiguration[] = [
{ key: 'deploymentName', label: 'Deployment name', type: 'text' },
{ key: 'model', label: 'Model name', type: 'openlist', source: OpenAIModelsList },
{ key: 'apiBase', label: 'Base url', type: 'obfuscated' },
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 },
{ key: 'prompt', label: 'Prompt', type: 'prompt', inputScale: 'fullwidth', defaultValue: DefaultPrompt }
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05 }
]
},
{
Expand All @@ -69,8 +88,7 @@ export const EngineConfigurations: EnginesConfiguration[] = [
params: [
{ key: 'baseUrl', label: 'Base url', type: 'text', defaultValue: 'http://localhost:11434' },
{ key: 'model', label: 'Model', type: 'openlist', source: OllamaLlmModelsList, defaultValue: 'llama2' },
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05, defaultValue: 0.7 },
{ key: 'prompt', label: 'Prompt', type: 'prompt', inputScale: 'fullwidth', defaultValue: DefaultPrompt }
{ key: 'temperature', label: 'Temperature', type: 'number', inputScale: 'fullwidth', min: 0, max: 1, step: 0.05, defaultValue: 0.7 }
]
}
];
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { llmSetting } from '../../../shared/model/ai-settings';
import { PromptDefinition, llmSetting } from '../../../shared/model/ai-settings';

export interface SentenceGenerationSettings {
id: string;
Expand All @@ -7,4 +7,5 @@ export interface SentenceGenerationSettings {
enabled: boolean;

llmSetting: llmSetting;
prompt: PromptDefinition;
}
Loading