Переглянути джерело

fix: provider token validate (#195)

tags/0.2.2
zxhlyh 2 роки тому
джерело
коміт
99f7e4f277
Аккаунт користувача з таким Email не знайдено

+ 0
- 3
web/app/components/header/account-setting/provider-page/openai-provider/index.tsx Переглянути файл

if (validating) { if (validating) {
return <ValidatingTip /> return <ValidatingTip />
} }
if (validatedStatus?.status === ValidatedStatus.Success) {
return <ValidatedExceedOnOpenaiTip />
}
if (validatedStatus?.status === ValidatedStatus.Error) { if (validatedStatus?.status === ValidatedStatus.Error) {
return <ValidatedErrorOnOpenaiTip errorMessage={validatedStatus.message ?? ''} /> return <ValidatedErrorOnOpenaiTip errorMessage={validatedStatus.message ?? ''} />
} }

+ 3
- 3
web/app/components/header/account-setting/provider-page/provider-item/index.tsx Переглянути файл

import { ProviderName } from '@/models/common' import { ProviderName } from '@/models/common'
import OpenaiProvider from '../openai-provider' import OpenaiProvider from '../openai-provider'
import AzureProvider from '../azure-provider' import AzureProvider from '../azure-provider'
import { ValidatedStatus } from '../provider-input/useValidateToken'
import { ValidatedStatus, ValidatedStatusState } from '../provider-input/useValidateToken'
import { updateProviderAIKey } from '@/service/common' import { updateProviderAIKey } from '@/service/common'
import { ToastContext } from '@/app/components/base/toast' import { ToastContext } from '@/app/components/base/toast'


onSave onSave
}: IProviderItemProps) => { }: IProviderItemProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const [validatedStatus, setValidatedStatus] = useState<ValidatedStatus>()
const [validatedStatus, setValidatedStatus] = useState<ValidatedStatusState>()
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const [token, setToken] = useState<ProviderAzureToken | string>( const [token, setToken] = useState<ProviderAzureToken | string>(
} }
const handleUpdateToken = async () => { const handleUpdateToken = async () => {
if (loading) return if (loading) return
if (validatedStatus === ValidatedStatus.Success) {
if (validatedStatus?.status === ValidatedStatus.Success) {
try { try {
setLoading(true) setLoading(true)
await updateProviderAIKey({ url: `/workspaces/current/providers/${provider.provider_name}/token`, body: { token } }) await updateProviderAIKey({ url: `/workspaces/current/providers/${provider.provider_name}/token`, body: { token } })

Завантаження…
Відмінити
Зберегти