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

frontend for model runtime #1861

Merged
merged 53 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a65b1a5
feat: new model provider
zxhlyh Dec 7, 2023
bf7c83e
feat: new model provider
zxhlyh Dec 11, 2023
e41c404
Merge branch 'main' into feat/model-provider-based-on-runtime
zxhlyh Dec 19, 2023
e629262
feat: model-provider
zxhlyh Dec 20, 2023
4588c66
feat: model provider
zxhlyh Dec 20, 2023
79ec497
Merge branch 'main' into feat/model-provider-based-on-runtime
zxhlyh Dec 20, 2023
41fdb9c
feat: model provider
zxhlyh Dec 20, 2023
b68bcc2
feat: model provider
zxhlyh Dec 21, 2023
1c154e0
feat: model provider
zxhlyh Dec 22, 2023
ee76c83
Merge branch 'main' into feat/model-provider-based-on-runtime
zxhlyh Dec 22, 2023
2299cfa
feat: model provider
zxhlyh Dec 22, 2023
5e5c308
feat: model provider
zxhlyh Dec 22, 2023
8480759
fix model-modal
zxhlyh Dec 24, 2023
0c2a6d4
fix: i18n
zxhlyh Dec 25, 2023
5f7dfc1
feat: add model-parameter-rule
zxhlyh Dec 25, 2023
bc51d7a
Merge branch 'main' into feat/model-provider-based-on-runtime
zxhlyh Dec 25, 2023
8abd39b
fix: slider style
zxhlyh Dec 25, 2023
4f0821f
remove moderation
zxhlyh Dec 26, 2023
410dddd
fix: model parameter model
zxhlyh Dec 26, 2023
926f31b
fix: content moderation
zxhlyh Dec 26, 2023
0249633
model selector
zxhlyh Dec 26, 2023
b333189
hooks
zxhlyh Dec 26, 2023
5f7a55d
fix: default provider model icon
zxhlyh Dec 27, 2023
db96302
fix: model icon name
zxhlyh Dec 27, 2023
41696e3
fix: provider context
zxhlyh Dec 27, 2023
9b1363d
fix: provider context
zxhlyh Dec 27, 2023
6dd914f
fix quota
zxhlyh Dec 27, 2023
13c9794
change priority
zxhlyh Dec 27, 2023
c23f37c
fix: universal chat
zxhlyh Dec 28, 2023
643845c
temp
iamjoel Dec 26, 2023
b78d12e
chore: retriever_resources to new struct
iamjoel Dec 28, 2023
3440bec
Merge branch 'main' into feat/model-provider-based-on-runtime
iamjoel Dec 28, 2023
cf8f708
fix: some
zxhlyh Dec 28, 2023
ef63077
fix: some
zxhlyh Dec 28, 2023
0f31f5f
fix: tooltip in model-item
zxhlyh Dec 28, 2023
66253f4
fix: model parameter rule
zxhlyh Dec 28, 2023
58b8495
fix: model modal style
zxhlyh Dec 28, 2023
0a43db8
fix: model-selector style
zxhlyh Dec 28, 2023
e064d8e
fix: model parameter
zxhlyh Jan 2, 2024
691b46b
fix: update model list
zxhlyh Jan 2, 2024
117eb06
fix: model-parameter
zxhlyh Jan 2, 2024
e7446b8
fix: model-parameter
zxhlyh Jan 2, 2024
7a29aaf
fix: dataset create two button
zxhlyh Jan 2, 2024
f9440a3
Merge branch 'main' into feat/model-provider-based-on-runtime
zxhlyh Jan 2, 2024
0b4a0ee
fix: annotation reply api struct
iamjoel Jan 2, 2024
3c108ce
fix: opening statement not show annotation
iamjoel Jan 2, 2024
3990559
fix: model-parameter
zxhlyh Jan 2, 2024
ed6e99b
fix: free quota
zxhlyh Jan 2, 2024
569251a
fix: edit custom model provider
zxhlyh Jan 2, 2024
460238c
fix: model-parameter inital value
zxhlyh Jan 2, 2024
9e9f910
fix: quota tip
zxhlyh Jan 2, 2024
a0823ea
fix: model selector default model
zxhlyh Jan 2, 2024
a07a39f
merge main
zxhlyh Jan 2, 2024
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
2 changes: 1 addition & 1 deletion web/app/components/app/chat/answer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const Answer: FC<IAnswerProps> = ({
className={cn(s.copyBtn, 'mr-1')}
/>
)}
{supportAnnotation && (
{(supportAnnotation && !item.isOpeningStatement) && (
<AnnotationCtrlBtn
appId={appId!}
messageId={id}
Expand Down
22 changes: 0 additions & 22 deletions web/app/components/app/configuration/debug/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ const Debug: FC<IDebug> = ({
}
},
onMessageEnd: (messageEnd) => {
// TODO
if (messageEnd.metadata?.annotation_reply) {
responseItem.id = messageEnd.id
responseItem.annotation = ({
Expand Down Expand Up @@ -382,27 +381,6 @@ const Debug: FC<IDebug> = ({
onMessageReplace: (messageReplace) => {
responseItem.content = messageReplace.answer
},
onAnnotationReply: (annotationReply) => {
// TODO: temp debug
responseItem.id = annotationReply.id
responseItem.content = annotationReply.answer
responseItem.annotation = ({
id: annotationReply.annotation_id,
authorName: annotationReply.annotation_author_name,
} as AnnotationType)
const newListWithAnswer = produce(
getChatList().filter(item => item.id !== responseItem.id && item.id !== placeholderAnswerId),
(draft) => {
if (!draft.find(item => item.id === questionId))
draft.push({ ...questionItem })

draft.push({
...responseItem,
id: annotationReply.id,
})
})
setChatList(newListWithAnswer)
},
onError() {
setResponsingFalse()
// role back placeholder answer
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/app/configuration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ const Configuration: FC = () => {
...visionConfig,
enabled: supportVision,
}, true)
setCompletionParams({})
}

const isShowVisionConfig = !!currModel?.features?.includes(ModelFeatureEnum.vision)
Expand Down Expand Up @@ -656,7 +657,6 @@ const Configuration: FC = () => {
onCompletionParamsChange={(newParams: FormValue) => {
setCompletionParams(newParams)
}}
disabled={!hasSettedApiKey}
/>
<div className='w-[1px] h-[14px] bg-gray-200'></div>
<Button onClick={() => setShowConfirm(true)} className='shrink-0 mr-2 w-[70px] !h-8 !text-[13px] font-medium'>{t('appDebug.operation.resetConfig')}</Button>
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/datasets/create/step-two/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ const StepTwo = ({
</div>
</div>
<div className={s.formFooter}>
<Button type="primary" className={cn(s.button, '!h-8 text-primary-600')} onClick={confirmChangeCustomConfig}>{t('datasetCreation.stepTwo.preview')}</Button>
<Button type="primary" className={cn(s.button, '!h-8')} onClick={confirmChangeCustomConfig}>{t('datasetCreation.stepTwo.preview')}</Button>
<Button className={cn(s.button, 'ml-2 !h-8')} onClick={resetRules}>{t('datasetCreation.stepTwo.reset')}</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ export enum ModelStatusEnum {
noPermission = 'no-permission',
}

export const MODEL_STATUS_TEXT = {
[ModelStatusEnum.noConfigure]: {
export const MODEL_STATUS_TEXT: { [k: string]: TypeWithI18N } = {
'no-configure': {
en_US: 'No Configure',
zh_Hans: '未配置凭据',
},
[ModelStatusEnum.quotaExceeded]: {
'quota-exceeded': {
en_US: 'Quota Exceeded',
zh_Hans: '额度不足',
},
[ModelStatusEnum.noPermission]: {
'no-permission': {
en_US: 'No Permission',
zh_Hans: '无使用权限',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import SystemModelSelector from './system-model-selector'
import ProviderAddedCard, { UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST } from './provider-added-card'
import ProviderCard from './provider-card'
import type {
ConfigurateMethodEnum,
CustomConfigrationModelFixedFields,
ModelProvider,
} from './declarations'
import { CustomConfigurationStatusEnum } from './declarations'
import {
ConfigurateMethodEnum,
CustomConfigurationStatusEnum,
} from './declarations'
import {
useDefaultModel,
useUpdateModelProvidersAndModelList,
Expand Down Expand Up @@ -57,7 +59,7 @@ const ModelProviderPage = () => {
onSaveCallback: () => {
updateModelProvidersAndModelList()

if (customConfigrationModelFixedFields && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
if (configurateMethod === ConfigurateMethodEnum.customizableModel && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
eventEmitter?.emit({
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
payload: provider.provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type FormProps = {
validating: boolean
validatedSuccess?: boolean
showOnVariableMap: Record<string, string[]>
isEditMode: boolean
}

const Form: FC<FormProps> = ({
Expand All @@ -30,11 +31,15 @@ const Form: FC<FormProps> = ({
validating,
validatedSuccess,
showOnVariableMap,
isEditMode,
}) => {
const language = useLanguage()
const [changeKey, setChangeKey] = useState('')

const handleFormChange = (key: string, val: string) => {
if (isEditMode && (key === '__model_type' || key === '__model_name'))
return

setChangeKey(key)
const shouldClearVariable: Record<string, string | undefined> = {}
if (showOnVariableMap[key]?.length) {
Expand All @@ -58,6 +63,8 @@ const Form: FC<FormProps> = ({
if (show_on.length && !show_on.every(showOnItem => value[showOnItem.variable] === showOnItem.value))
return null

const disabed = isEditMode && (variable === '__model_type' || variable === '__model_name')

return (
<div key={variable} className='py-3'>
<div className='py-2 text-sm text-gray-900'>
Expand All @@ -69,10 +76,12 @@ const Form: FC<FormProps> = ({
}
</div>
<Input
className={`${disabed && 'cursor-not-allowed opacity-60'}`}
value={value[variable] as string}
onChange={val => handleFormChange(variable, val)}
validated={validatedSuccess}
placeholder={placeholder?.[language]}
disabled={disabed}
/>
{validating && changeKey === variable && <ValidatingTip />}
</div>
Expand All @@ -91,6 +100,8 @@ const Form: FC<FormProps> = ({
if (show_on.length && !show_on.every(showOnItem => value[showOnItem.variable] === showOnItem.value))
return null

const disabed = isEditMode && (variable === '__model_type' || variable === '__model_name')

return (
<div key={variable} className='py-3'>
<div className='py-2 text-sm text-gray-900'>
Expand All @@ -113,6 +124,7 @@ const Form: FC<FormProps> = ({
className={`
flex items-center px-3 py-2 rounded-lg border border-gray-100 bg-gray-25 cursor-pointer
${value[variable] === option.value && 'bg-white border-[1.5px] border-primary-400 shadow-sm'}
${disabed && '!cursor-not-allowed opacity-60'}
`}
onClick={() => handleFormChange(variable, option.value)}
key={`${variable}-${option.value}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ type InputProps = {
onFocus?: () => void
placeholder?: string
validated?: boolean
className?: string
disabled?: boolean
}
const Input: FC<InputProps> = ({
value,
onChange,
onFocus,
placeholder,
validated,
className,
disabled,
}) => {
return (
<div className='relative'>
Expand All @@ -26,11 +30,13 @@ const Input: FC<InputProps> = ({
focus:bg-white focus:border-gray-300 focus:shadow-xs
placeholder:text-sm placeholder:text-gray-400
${validated && 'pr-[30px]'}
${className}
`}
placeholder={placeholder || ''}
onChange={e => onChange(e.target.value)}
onFocus={onFocus}
value={value || ''}
disabled={disabled}
/>
{
validated && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const ModelModal: FC<ModelModalProps> = ({
validating={validating}
validatedSuccess={validatedStatusState.status === ValidatedStatus.Success}
showOnVariableMap={showOnVariableMap}
isEditMode={isEditMode}
/>
<div className='sticky bottom-0 flex justify-between items-center py-6 flex-wrap gap-y-2 bg-white'>
{
Expand Down Expand Up @@ -313,7 +314,7 @@ const ModelModal: FC<ModelModalProps> = ({
{
showConfirm && (
<ConfirmCommon
title='Are you sure?'
title={t('common.modelProvider.confirmDelete')}
isShow={showConfirm}
onCancel={() => setShowConfirm(false)}
onConfirm={handleRemove}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ const ModelName: FC<ModelNameProps> = ({
`}
>
<div
className='mr-2 truncate'
className='mr-1 truncate'
title={modelItem.label[language]}
>
{modelItem.label[language]}
</div>
{
showModelType && (
showModelType && modelItem.model_type && (
<ModelBadge className={`mr-0.5 ${modelTypeClassName}`}>
{modelTypeFormat(modelItem.model_type)}
</ModelBadge>
Expand Down
Loading
Loading