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
071e7800
Unverified
Commit
071e7800
authored
Aug 23, 2023
by
takatost
Committed by
GitHub
Aug 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add hf task field (#976)
Co-authored-by:
StyleZhang
<
jasonapring2015@outlook.com
>
parent
a76fde3d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
3 deletions
+58
-3
huggingface_hub.tsx
...er/account-setting/model-page/configs/huggingface_hub.tsx
+53
-0
declarations.ts
...ponents/header/account-setting/model-page/declarations.ts
+1
-0
index.tsx
...pp/components/header/account-setting/model-page/index.tsx
+3
-2
Form.tsx
...ts/header/account-setting/model-page/model-modal/Form.tsx
+1
-1
No files found.
web/app/components/header/account-setting/model-page/configs/huggingface_hub.tsx
View file @
071e7800
...
...
@@ -38,6 +38,7 @@ const config: ProviderConfig = {
defaultValue
:
{
model_type
:
'text-generation'
,
huggingfacehub_api_type
:
'hosted_inference_api'
,
task_type
:
'text-generation'
,
},
validateKeys
:
(
v
?:
FormValue
)
=>
{
if
(
v
?.
huggingfacehub_api_type
===
'hosted_inference_api'
)
{
...
...
@@ -51,10 +52,36 @@ const config: ProviderConfig = {
'huggingfacehub_api_token'
,
'model_name'
,
'huggingfacehub_endpoint_url'
,
'task_type'
,
]
}
return
[]
},
filterValue
:
(
v
?:
FormValue
)
=>
{
let
filteredKeys
:
string
[]
=
[]
if
(
v
?.
huggingfacehub_api_type
===
'hosted_inference_api'
)
{
filteredKeys
=
[
'huggingfacehub_api_type'
,
'huggingfacehub_api_token'
,
'model_name'
,
'model_type'
,
]
}
if
(
v
?.
huggingfacehub_api_type
===
'inference_endpoints'
)
{
filteredKeys
=
[
'huggingfacehub_api_type'
,
'huggingfacehub_api_token'
,
'model_name'
,
'huggingfacehub_endpoint_url'
,
'task_type'
,
'model_type'
,
]
}
return
filteredKeys
.
reduce
((
prev
:
FormValue
,
next
:
string
)
=>
{
prev
[
next
]
=
v
?.[
next
]
||
''
return
prev
},
{})
},
fields
:
[
{
type
:
'radio'
,
...
...
@@ -120,6 +147,32 @@ const config: ProviderConfig = {
'zh-Hans'
:
'在此输入您的端点 URL'
,
},
},
{
hidden
:
(
value
?:
FormValue
)
=>
value
?.
huggingfacehub_api_type
===
'hosted_inference_api'
,
type
:
'radio'
,
key
:
'task_type'
,
required
:
true
,
label
:
{
'en'
:
'Task'
,
'zh-Hans'
:
'Task'
,
},
options
:
[
{
key
:
'text2text-generation'
,
label
:
{
'en'
:
'Text-to-Text Generation'
,
'zh-Hans'
:
'Text-to-Text Generation'
,
},
},
{
key
:
'text-generation'
,
label
:
{
'en'
:
'Text Generation'
,
'zh-Hans'
:
'Text Generation'
,
},
},
],
},
],
},
}
...
...
web/app/components/header/account-setting/model-page/declarations.ts
View file @
071e7800
...
...
@@ -91,6 +91,7 @@ export type ProviderConfigModal = {
icon
:
ReactElement
defaultValue
?:
FormValue
validateKeys
?:
string
[]
|
((
v
?:
FormValue
)
=>
string
[])
filterValue
?:
(
v
?:
FormValue
)
=>
FormValue
fields
:
Field
[]
link
:
{
href
:
string
...
...
web/app/components/header/account-setting/model-page/index.tsx
View file @
071e7800
...
...
@@ -124,8 +124,9 @@ const ModelPage = () => {
updateModelList
(
ModelType
.
embeddings
)
mutateProviders
()
}
const
handleSave
=
async
(
v
?:
FormValue
)
=>
{
if
(
v
&&
modelModalConfig
)
{
const
handleSave
=
async
(
originValue
?:
FormValue
)
=>
{
if
(
originValue
&&
modelModalConfig
)
{
const
v
=
modelModalConfig
.
filterValue
?
modelModalConfig
.
filterValue
(
originValue
)
:
originValue
let
body
,
url
if
(
ConfigurableProviders
.
includes
(
modelModalConfig
.
key
))
{
const
{
model_name
,
model_type
,
...
config
}
=
v
...
...
web/app/components/header/account-setting/model-page/model-modal/Form.tsx
View file @
071e7800
...
...
@@ -68,7 +68,7 @@ const Form: FC<FormProps> = ({
return
true
},
run
:
()
=>
{
return
validateModelProviderFn
(
modelModal
!
.
key
,
v
)
return
validateModelProviderFn
(
modelModal
!
.
key
,
modelModal
?.
filterValue
?
modelModal
?.
filterValue
(
v
)
:
v
)
},
})
}
...
...
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