Skip to content

Commit

Permalink
feat(modulify-ui): library updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesha committed Dec 11, 2024
1 parent 7c3eb78 commit 0951cdc
Showing 1 changed file with 93 additions and 89 deletions.
182 changes: 93 additions & 89 deletions apps/chat/src/components/Chat/ChatSettings/ConversationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,92 +48,96 @@ export const SettingContainer = ({ children }: SettingContainerProps) => {
};

export const ConversationSettings = Inversify.register(
'ConversationSettings',
({
assistantModelId,
prompts,
prompt,
temperature,
selectedAddons,
conversation,
onSelectAssistantSubModel,
onChangePrompt,
onChangeTemperature,
onChangeAddon,
onApplyAddons,
}: Props) => {
const { t } = useTranslation(Translation.Chat);

const modelsMap = useAppSelector(ModelsSelectors.selectModelsMap);

const model = modelsMap[conversation.model.id];
const isPlayback = !!conversation.playback?.isPlayback;

const isNotAllowedModel = !modelsMap[conversation.model.id];

return (
<div className="flex w-full flex-col bg-layer-2" data-qa="entity-settings">
{!isNotAllowedModel ? (
<>
{model && model.type === EntityType.Application && (
<SettingContainer>
{t('There are no conversation settings for this agent ')}
</SettingContainer>
)}
{model && model.type === EntityType.Assistant && (
<SettingContainer>
<AssistantSubModelSelector
assistantModelId={
assistantModelId ??
DefaultsService.get(
'assistantSubmodelId',
FALLBACK_ASSISTANT_SUBMODEL_ID,
)
}
onSelectAssistantSubModel={onSelectAssistantSubModel}
disabled={isPlayback}
/>
</SettingContainer>
)}
{(!model ||
(model.type === EntityType.Model &&
model?.features?.systemPrompt)) && (
<SettingContainer>
<SystemPrompt
maxTokensLength={model?.limits?.maxRequestTokens ?? Infinity}
tokenizer={model?.tokenizer}
prompt={prompt}
prompts={prompts}
onChangePrompt={onChangePrompt}
disabled={isPlayback}
/>
</SettingContainer>
)}
{(!model || model.type !== EntityType.Application) && (
<SettingContainer>
<TemperatureSlider
label={t('Temperature') ?? ''}
onChangeTemperature={onChangeTemperature}
temperature={temperature}
disabled={isPlayback}
/>
</SettingContainer>
)}
{(!model || model.type !== EntityType.Application) && (
<SettingContainer>
<Addons
preselectedAddonsIds={model?.selectedAddons || []}
selectedAddonsIds={selectedAddons}
onChangeAddon={onChangeAddon}
onApplyAddons={onApplyAddons}
disabled={isPlayback}
/>
</SettingContainer>
)}
</>
) : (
<SettingContainer>{t('Agent is not available')}</SettingContainer>
)}
</div>
);
});
'ConversationSettings',
({
assistantModelId,
prompts,
prompt,
temperature,
selectedAddons,
conversation,
onSelectAssistantSubModel,
onChangePrompt,
onChangeTemperature,
onChangeAddon,
onApplyAddons,
}: Props) => {
const { t } = useTranslation(Translation.Chat);

const modelsMap = useAppSelector(ModelsSelectors.selectModelsMap);

const model = modelsMap[conversation.model.id];
const isPlayback = !!conversation.playback?.isPlayback;

const isNotAllowedModel = !modelsMap[conversation.model.id];

return (
<div
className="flex w-full flex-col bg-layer-2"
data-qa="entity-settings"
>
{!isNotAllowedModel ? (
<>
{model && model.type === EntityType.Application && (
<SettingContainer>
{t('There are no conversation settings for this agent ')}
</SettingContainer>
)}
{model && model.type === EntityType.Assistant && (
<SettingContainer>
<AssistantSubModelSelector
assistantModelId={
assistantModelId ??
DefaultsService.get(
'assistantSubmodelId',
FALLBACK_ASSISTANT_SUBMODEL_ID,
)
}
onSelectAssistantSubModel={onSelectAssistantSubModel}
disabled={isPlayback}
/>
</SettingContainer>
)}
{(!model ||
(model.type === EntityType.Model &&
model?.features?.systemPrompt)) && (
<SettingContainer>
<SystemPrompt
maxTokensLength={model?.limits?.maxRequestTokens ?? Infinity}
tokenizer={model?.tokenizer}
prompt={prompt}
prompts={prompts}
onChangePrompt={onChangePrompt}
disabled={isPlayback}
/>
</SettingContainer>
)}
{(!model || model.type !== EntityType.Application) && (
<SettingContainer>
<TemperatureSlider
label={t('Temperature') ?? ''}
onChangeTemperature={onChangeTemperature}
temperature={temperature}
disabled={isPlayback}
/>
</SettingContainer>
)}
{(!model || model.type !== EntityType.Application) && (
<SettingContainer>
<Addons
preselectedAddonsIds={model?.selectedAddons || []}
selectedAddonsIds={selectedAddons}
onChangeAddon={onChangeAddon}
onApplyAddons={onApplyAddons}
disabled={isPlayback}
/>
</SettingContainer>
)}
</>
) : (
<SettingContainer>{t('Agent is not available')}</SettingContainer>
)}
</div>
);
},
);

0 comments on commit 0951cdc

Please sign in to comment.