Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
4db35fa3
Unverified
Commit
4db35fa3
authored
Aug 22, 2023
by
Joel
Committed by
GitHub
Aug 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: obsolete info api use new api (#954)
parent
e67a1413
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
28 deletions
+24
-28
index.tsx
web/app/components/app/configuration/index.tsx
+23
-23
common.ts
web/service/common.ts
+1
-5
No files found.
web/app/components/app/configuration/index.tsx
View file @
4db35fa3
...
@@ -16,22 +16,21 @@ import ConfigModel from '@/app/components/app/configuration/config-model'
...
@@ -16,22 +16,21 @@ import ConfigModel from '@/app/components/app/configuration/config-model'
import
Config
from
'@/app/components/app/configuration/config'
import
Config
from
'@/app/components/app/configuration/config'
import
Debug
from
'@/app/components/app/configuration/debug'
import
Debug
from
'@/app/components/app/configuration/debug'
import
Confirm
from
'@/app/components/base/confirm'
import
Confirm
from
'@/app/components/base/confirm'
import
{
Provider
Type
}
from
'@/types/app
'
import
{
Provider
Enum
}
from
'@/app/components/header/account-setting/model-page/declarations
'
import
type
{
AppDetailResponse
}
from
'@/models/app'
import
type
{
AppDetailResponse
}
from
'@/models/app'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
fetchTenantInfo
}
from
'@/service/common'
import
{
fetchAppDetail
,
updateAppModelConfig
}
from
'@/service/apps'
import
{
fetchAppDetail
,
updateAppModelConfig
}
from
'@/service/apps'
import
{
promptVariablesToUserInputsForm
,
userInputsFormToPromptVariables
}
from
'@/utils/model-config'
import
{
promptVariablesToUserInputsForm
,
userInputsFormToPromptVariables
}
from
'@/utils/model-config'
import
{
fetchDatasets
}
from
'@/service/datasets'
import
{
fetchDatasets
}
from
'@/service/datasets'
import
AccountSetting
from
'@/app/components/header/account-setting'
import
AccountSetting
from
'@/app/components/header/account-setting'
import
{
useProviderContext
}
from
'@/context/provider-context'
const
Configuration
:
FC
=
()
=>
{
const
Configuration
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
[
hasFetchedDetail
,
setHasFetchedDetail
]
=
useState
(
false
)
const
[
hasFetchedDetail
,
setHasFetchedDetail
]
=
useState
(
false
)
const
[
hasFetchedKey
,
setHasFetchedKey
]
=
useState
(
false
)
const
isLoading
=
!
hasFetchedDetail
const
isLoading
=
!
hasFetchedDetail
||
!
hasFetchedKey
const
pathname
=
usePathname
()
const
pathname
=
usePathname
()
const
matched
=
pathname
.
match
(
/
\/
app
\/([^/]
+
)
/
)
const
matched
=
pathname
.
match
(
/
\/
app
\/([^/]
+
)
/
)
const
appId
=
(
matched
?.
length
&&
matched
[
1
])
?
matched
[
1
]
:
''
const
appId
=
(
matched
?.
length
&&
matched
[
1
])
?
matched
[
1
]
:
''
...
@@ -68,7 +67,7 @@ const Configuration: FC = () => {
...
@@ -68,7 +67,7 @@ const Configuration: FC = () => {
frequency_penalty
:
1
,
// -2-2
frequency_penalty
:
1
,
// -2-2
})
})
const
[
modelConfig
,
doSetModelConfig
]
=
useState
<
ModelConfig
>
({
const
[
modelConfig
,
doSetModelConfig
]
=
useState
<
ModelConfig
>
({
provider
:
Provider
Type
.
openai
,
provider
:
Provider
Enum
.
openai
,
model_id
:
'gpt-3.5-turbo'
,
model_id
:
'gpt-3.5-turbo'
,
configs
:
{
configs
:
{
prompt_template
:
''
,
prompt_template
:
''
,
...
@@ -85,7 +84,7 @@ const Configuration: FC = () => {
...
@@ -85,7 +84,7 @@ const Configuration: FC = () => {
doSetModelConfig
(
newModelConfig
)
doSetModelConfig
(
newModelConfig
)
}
}
const
setModelId
=
(
modelId
:
string
,
provider
:
Provider
Type
)
=>
{
const
setModelId
=
(
modelId
:
string
,
provider
:
Provider
Enum
)
=>
{
const
newModelConfig
=
produce
(
modelConfig
,
(
draft
:
any
)
=>
{
const
newModelConfig
=
produce
(
modelConfig
,
(
draft
:
any
)
=>
{
draft
.
provider
=
provider
draft
.
provider
=
provider
draft
.
model_id
=
modelId
draft
.
model_id
=
modelId
...
@@ -113,24 +112,26 @@ const Configuration: FC = () => {
...
@@ -113,24 +112,26 @@ const Configuration: FC = () => {
})
})
}
}
const
[
hasSetCustomAPIKEY
,
setHasSetCustomerAPIKEY
]
=
useState
(
true
)
const
{
textGenerationModelList
}
=
useProviderContext
()
const
[
isTrailFinished
,
setIsTrailFinished
]
=
useState
(
false
)
const
hasSetCustomAPIKEY
=
!!
textGenerationModelList
?.
find
(({
model_provider
:
provider
})
=>
{
const
hasSetAPIKEY
=
hasSetCustomAPIKEY
||
!
isTrailFinished
if
(
provider
.
provider_type
===
'system'
&&
provider
.
quota_type
===
'paid'
)
return
true
const
[
isShowSetAPIKey
,
{
setTrue
:
showSetAPIKey
,
setFalse
:
hideSetAPIkey
}]
=
useBoolean
()
if
(
provider
.
provider_type
===
'custom'
)
return
true
const
checkAPIKey
=
async
()
=>
{
return
false
const
{
in_trail
,
trial_end_reason
}
=
await
fetchTenantInfo
({
url
:
'/info'
})
})
const
isTrailFinished
=
in_trail
&&
trial_end_reason
===
'trial_exceeded'
const
isTrailFinished
=
!
hasSetCustomAPIKEY
&&
textGenerationModelList
const
hasSetCustomAPIKEY
=
trial_end_reason
===
'using_custom'
.
filter
(({
model_provider
:
provider
})
=>
provider
.
quota_type
===
'trial'
)
setHasSetCustomerAPIKEY
(
hasSetCustomAPIKEY
)
.
every
(({
model_provider
:
provider
})
=>
{
setIsTrailFinished
(
isTrailFinished
)
const
{
quota_used
,
quota_limit
}
=
provider
setHasFetchedKey
(
true
)
return
quota_used
===
quota_limit
}
})
useEffect
(()
=>
{
const
hasSetAPIKEY
=
hasSetCustomAPIKEY
||
!
isTrailFinished
checkAPIKey
()
},
[]
)
const
[
isShowSetAPIKey
,
{
setTrue
:
showSetAPIKey
,
setFalse
:
hideSetAPIkey
}]
=
useBoolean
(
)
useEffect
(()
=>
{
useEffect
(()
=>
{
(
fetchAppDetail
({
url
:
'/apps'
,
id
:
appId
})
as
any
).
then
(
async
(
res
:
AppDetailResponse
)
=>
{
(
fetchAppDetail
({
url
:
'/apps'
,
id
:
appId
})
as
any
).
then
(
async
(
res
:
AppDetailResponse
)
=>
{
...
@@ -284,7 +285,7 @@ const Configuration: FC = () => {
...
@@ -284,7 +285,7 @@ const Configuration: FC = () => {
{
/* Model and Parameters */
}
{
/* Model and Parameters */
}
<
ConfigModel
<
ConfigModel
mode=
{
mode
}
mode=
{
mode
}
provider=
{
modelConfig
.
provider
as
Provider
Type
}
provider=
{
modelConfig
.
provider
as
Provider
Enum
}
completionParams=
{
completionParams
}
completionParams=
{
completionParams
}
modelId=
{
modelConfig
.
model_id
}
modelId=
{
modelConfig
.
model_id
}
setModelId=
{
setModelId
}
setModelId=
{
setModelId
}
...
@@ -338,7 +339,6 @@ const Configuration: FC = () => {
...
@@ -338,7 +339,6 @@ const Configuration: FC = () => {
)
)
}
}
{
isShowSetAPIKey
&&
<
AccountSetting
activeTab=
"provider"
onCancel=
{
async
()
=>
{
{
isShowSetAPIKey
&&
<
AccountSetting
activeTab=
"provider"
onCancel=
{
async
()
=>
{
await
checkAPIKey
()
hideSetAPIkey
()
hideSetAPIkey
()
}
}
/>
}
}
}
/>
}
</>
</>
...
...
web/service/common.ts
View file @
4db35fa3
...
@@ -6,7 +6,7 @@ import type {
...
@@ -6,7 +6,7 @@ import type {
ICurrentWorkspace
,
ICurrentWorkspace
,
IWorkspace
,
LangGeniusVersionResponse
,
Member
,
IWorkspace
,
LangGeniusVersionResponse
,
Member
,
OauthResponse
,
PluginProvider
,
Provider
,
ProviderAnthropicToken
,
ProviderAzureToken
,
OauthResponse
,
PluginProvider
,
Provider
,
ProviderAnthropicToken
,
ProviderAzureToken
,
SetupStatusResponse
,
TenantInfoResponse
,
UserProfileOriginResponse
,
SetupStatusResponse
,
UserProfileOriginResponse
,
}
from
'@/models/common'
}
from
'@/models/common'
import
type
{
import
type
{
UpdateOpenAIKeyResponse
,
UpdateOpenAIKeyResponse
,
...
@@ -34,10 +34,6 @@ export const updateUserProfile: Fetcher<CommonResponse, { url: string; body: Rec
...
@@ -34,10 +34,6 @@ export const updateUserProfile: Fetcher<CommonResponse, { url: string; body: Rec
return
post
(
url
,
{
body
})
as
Promise
<
CommonResponse
>
return
post
(
url
,
{
body
})
as
Promise
<
CommonResponse
>
}
}
export
const
fetchTenantInfo
:
Fetcher
<
TenantInfoResponse
,
{
url
:
string
}
>
=
({
url
})
=>
{
return
get
(
url
)
as
Promise
<
TenantInfoResponse
>
}
export
const
logout
:
Fetcher
<
CommonResponse
,
{
url
:
string
;
params
:
Record
<
string
,
any
>
}
>
=
({
url
,
params
})
=>
{
export
const
logout
:
Fetcher
<
CommonResponse
,
{
url
:
string
;
params
:
Record
<
string
,
any
>
}
>
=
({
url
,
params
})
=>
{
return
get
(
url
,
params
)
as
Promise
<
CommonResponse
>
return
get
(
url
,
params
)
as
Promise
<
CommonResponse
>
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment