+
{parametersForm}
+
- {modelVendor === ModelVendor.OpenAI && (
- void
}
/>
- )}
-
-
-
- {modelVendor === ModelVendor.OpenAI && (
+ ) : (
({
);
}
-
-function ParameterSlider({
- key,
- toolTipText,
- labelText,
- min,
- max,
- step,
- value,
- setter,
-}: {
- key: string;
- labelText: string;
- max: number;
- min: number;
- setter: (value: number) => void;
- step: number;
- toolTipText: string;
- value: number;
-}) {
- return (
-
-
-
{
- setter(Number.parseFloat(value));
- })}
- className="range range-xs"
- data-testid={`create-prompt-config-dialog-model-parameter-range-${key}`}
- />
-
- );
-}
-
-export function OpenAIModelParametersForm({
- modelType,
- setParameters,
- existingParameters,
-}: {
- existingParameters?: ModelParameters
;
- modelType: OpenAIModelType;
- setParameters: (parameters: ModelParameters) => void;
-}) {
- const t = useTranslations('createConfigWizard');
-
- const [maxTokens, setMaxTokens] = useState(
- existingParameters?.maxTokens ?? DEFAULT_MAX_TOKENS,
- );
- const [frequencyPenalty, setFrequencyPenalty] = useState(
- existingParameters?.frequencyPenalty ?? 0,
- );
- const [presencePenalty, setPresencePenalty] = useState(
- existingParameters?.presencePenalty ?? 0,
- );
- const [temperature, setTemperature] = useState(
- existingParameters?.temperature ?? 1,
- );
- const [topP, setTopP] = useState(existingParameters?.topP ?? 1);
-
- const inputs: {
- key: string;
- labelText: string;
- max: number;
- min: number;
- setter: Dispatch>;
- step: number;
- toolTipText: string;
- value: number;
- }[] = [
- {
- key: 'maxTokens',
- labelText: t('openaiParametersMaxTokensLabel'),
- max: openAIModelsMaxTokensMap[modelType],
- min: 1,
- setter: setMaxTokens,
- step: 1,
- toolTipText: t('openaiParametersMaxTokensTooltip'),
- value: maxTokens,
- },
- {
- key: 'temperature',
- labelText: t('openaiParametersTemperatureLabel'),
- max: 2,
- min: 0,
- setter: setTemperature,
- step: 0.1,
- toolTipText: t('openaiParametersTemperatureTooltip'),
- value: temperature,
- },
- {
- key: 'topP',
- labelText: t('openaiParametersTopPLabel'),
- max: 1,
- min: 0,
- setter: setTopP,
- step: 0.1,
- toolTipText: t('openaiParametersTopPTooltip'),
- value: topP,
- },
- {
- key: 'frequencyPenalty',
- labelText: t('openaiParametersFrequencyPenaltyLabel'),
- max: 2,
- min: 0,
- setter: setFrequencyPenalty,
- step: 0.1,
- toolTipText: t('openaiParametersFrequencyPenaltyTooltip'),
- value: frequencyPenalty,
- },
- {
- key: 'presencePenalty',
- labelText: t('openaiParametersPresencePenaltyLabel'),
- max: 2,
- min: 0,
- setter: setPresencePenalty,
- step: 0.1,
- toolTipText: t('openaiParametersPresencePenaltyTooltip'),
- value: presencePenalty,
- },
- ];
-
- useEffect(() => {
- setParameters({
- frequencyPenalty,
- maxTokens,
- presencePenalty,
- temperature,
- topP,
- });
- }, [maxTokens, frequencyPenalty, presencePenalty, temperature, topP]);
-
- return (
-
-
{t('modelParameters')}
-
- {inputs.map(ParameterSlider)}
-
-
- );
-}
-
-const OPEN_AI_DRAFT_MESSAGE = {
- content: '',
- name: '',
- role: OpenAIPromptMessageRole.System,
-} satisfies OpenAIContentMessage;
-
-function MessageItem({
- name,
- role,
- dataTestId,
- className,
- handleClick,
-}: {
- className: string;
- dataTestId: string;
- handleClick: () => void;
- name?: string;
- role?: OpenAIMessageRole;
-}) {
- const t = useTranslations('createConfigWizard');
-
- return (
-
- );
-}
-
-export function OpenAIPromptTemplate({
- messages,
- setMessages,
-}: {
- messages: OpenAIContentMessage[];
- setMessages: (messages: OpenAIContentMessage[]) => void;
-}) {
- const t = useTranslations('createConfigWizard');
-
- const [activeMessageIndex, setActiveMessageIndex] = useState(
- messages.length,
- );
- const [draftMessage, setDraftMessage] = useState(
- structuredClone(OPEN_AI_DRAFT_MESSAGE),
- );
- const handleRoleChange = (role: OpenAIPromptMessageRole) => {
- setDraftMessage({ ...draftMessage, role });
- };
-
- const handleNameChange = (value: string) => {
- setDraftMessage({ ...draftMessage, name: value });
- };
-
- const handleMessageChange = (value: string) => {
- setDraftMessage({ ...draftMessage, content: value });
- };
-
- const handleDeleteMessage = () => {
- const copiedMessages = [...messages];
-
- copiedMessages.splice(activeMessageIndex, 1);
-
- setMessages(copiedMessages);
- setActiveMessageIndex(
- activeMessageIndex - 1 >= 0 ? activeMessageIndex - 1 : 0,
- );
- };
-
- const handleSaveMessage = () => {
- const copiedMessages = [...messages];
- draftMessage.templateVariables = extractTemplateVariables(
- draftMessage.content,
- );
- copiedMessages[activeMessageIndex] = draftMessage;
-
- setMessages(copiedMessages);
- setDraftMessage(structuredClone(OPEN_AI_DRAFT_MESSAGE));
- setActiveMessageIndex(copiedMessages.length);
- };
-
- return (
-
-
{t('promptMessages')}
-
-
- {messages.map((message, index) => (
- {
- setActiveMessageIndex(index);
- setDraftMessage(message);
- }}
- />
- ))}
- {
- setActiveMessageIndex(messages.length);
- setDraftMessage({
- content: '',
- name: '',
- role: OpenAIPromptMessageRole.System,
- });
- }}
- className={
- activeMessageIndex === messages.length
- ? 'btn-secondary'
- : 'btn-secondary text-neutral-content btn-outline hover:text-secondary-content'
- }
- />
-
-
-
-
-
-
-
-
-
- {
- return !messages
- .map((message) => message.name)
- .includes(value);
- }}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/frontend/src/components/projects/[projectId]/applications/[applicationId]/config-create-wizard/prompt-config-testing-form.tsx b/frontend/src/components/projects/[projectId]/applications/[applicationId]/config-create-wizard/prompt-config-testing-form.tsx
index 5eeba6f9..16d86abc 100644
--- a/frontend/src/components/projects/[projectId]/applications/[applicationId]/config-create-wizard/prompt-config-testing-form.tsx
+++ b/frontend/src/components/projects/[projectId]/applications/[applicationId]/config-create-wizard/prompt-config-testing-form.tsx
@@ -178,7 +178,7 @@ export function PromptConfigTestingForm({
{modelResponses
.map((message) => message.content)
- .join(' ')}
+ .join('')}