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

Block model config UI when using Azure OpenAI to eliminate ambiguity #2

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 30 additions & 3 deletions app/components/mask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,29 @@ import EyeIcon from "../icons/eye.svg";
import CopyIcon from "../icons/copy.svg";

import { DEFAULT_MASK_AVATAR, Mask, useMaskStore } from "../store/mask";
import { ChatMessage, ModelConfig, useAppConfig, useChatStore } from "../store";
import {
ChatMessage,
ModelConfig,
useAccessStore,
useAppConfig,
useChatStore,
} from "../store";
import { ROLES } from "../client/api";
import { Input, List, ListItem, Modal, Popover, Select } from "./ui-lib";
import {
Input,
List,
ListItem,
Modal,
Popover,
Select,
TextInput,
} from "./ui-lib";
import { Avatar, AvatarPicker } from "./emoji";
import Locale, { AllLangs, ALL_LANG_OPTIONS, Lang } from "../locales";
import { useNavigate } from "react-router-dom";

import chatStyle from "./chat.module.scss";
import { useEffect, useState } from "react";
import { useState } from "react";
import { downloadAs, readFromFile } from "../utils";
import { Updater } from "../typing";
import { ModelConfigList } from "./model-config";
Expand Down Expand Up @@ -59,6 +73,8 @@ export function MaskConfig(props: {

const globalConfig = useAppConfig();

const accessStore = useAccessStore();

return (
<>
<ContextPrompts
Expand Down Expand Up @@ -141,6 +157,17 @@ export function MaskConfig(props: {
) : null}
</List>

{accessStore.enableAOAI ? (
<List>
<ListItem
title={Locale.Settings.AzureDeploymentName.Title}
subTitle={Locale.Settings.AzureDeploymentName.SubTitle}
>
<TextInput value={accessStore.azureDeployName} />
</ListItem>
</List>
) : null}

<List>
<ModelConfigList
modelConfig={{ ...props.mask.modelConfig }}
Expand Down
52 changes: 31 additions & 21 deletions app/components/model-config.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
import { ALL_MODELS, ModalConfigValidator, ModelConfig } from "../store";
import {
ALL_MODELS,
ModalConfigValidator,
ModelConfig,
useAccessStore,
} from "../store";

import Locale from "../locales";
import { InputRange } from "./input-range";
import { List, ListItem, Select } from "./ui-lib";
import { ListItem, Select } from "./ui-lib";

export function ModelConfigList(props: {
modelConfig: ModelConfig;
updateConfig: (updater: (config: ModelConfig) => void) => void;
}) {
const accessStore = useAccessStore();

return (
<>
<ListItem title={Locale.Settings.Model}>
<Select
value={props.modelConfig.model}
onChange={(e) => {
props.updateConfig(
(config) =>
(config.model = ModalConfigValidator.model(
e.currentTarget.value,
)),
);
}}
>
{ALL_MODELS.map((v) => (
<option value={v.name} key={v.name} disabled={!v.available}>
{v.name}
</option>
))}
</Select>
</ListItem>
{accessStore.enableAOAI ? null : (
<ListItem title={Locale.Settings.Model}>
<Select
value={props.modelConfig.model}
onChange={(e) => {
props.updateConfig(
(config) =>
(config.model = ModalConfigValidator.model(
e.currentTarget.value,
)),
);
}}
>
{ALL_MODELS.map((v) => (
<option value={v.name} key={v.name} disabled={!v.available}>
{v.name}
</option>
))}
</Select>
</ListItem>
)}

<ListItem
title={Locale.Settings.Temperature.Title}
subTitle={Locale.Settings.Temperature.SubTitle}
Expand Down