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
2374af61
Commit
2374af61
authored
Jul 19, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support select model
parent
1373ed06
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
123 additions
and
43 deletions
+123
-43
index.tsx
web/app/components/app/configuration/config-model/index.tsx
+3
-39
model-icon.tsx
.../components/app/configuration/config-model/model-icon.tsx
+32
-0
index.tsx
web/app/components/explore/universal-chat/config/index.tsx
+13
-4
index.tsx
...ents/explore/universal-chat/config/model-config/index.tsx
+52
-0
index.tsx
...ts/explore/universal-chat/config/plugins-config/index.tsx
+0
-0
item.module.css
...lore/universal-chat/config/plugins-config/item.module.css
+0
-0
item.tsx
...nts/explore/universal-chat/config/plugins-config/item.tsx
+0
-0
index.tsx
web/app/components/explore/universal-chat/index.tsx
+6
-0
index.ts
web/config/index.ts
+17
-0
No files found.
web/app/components/app/configuration/config-model/index.tsx
View file @
2374af61
...
@@ -6,15 +6,15 @@ import { useTranslation } from 'react-i18next'
...
@@ -6,15 +6,15 @@ import { useTranslation } from 'react-i18next'
import
{
useBoolean
,
useClickAway
}
from
'ahooks'
import
{
useBoolean
,
useClickAway
}
from
'ahooks'
import
{
ChevronDownIcon
,
Cog8ToothIcon
,
InformationCircleIcon
}
from
'@heroicons/react/24/outline'
import
{
ChevronDownIcon
,
Cog8ToothIcon
,
InformationCircleIcon
}
from
'@heroicons/react/24/outline'
import
ParamItem
from
'./param-item'
import
ParamItem
from
'./param-item'
import
ModelIcon
from
'./model-icon'
import
Radio
from
'@/app/components/base/radio'
import
Radio
from
'@/app/components/base/radio'
import
Panel
from
'@/app/components/base/panel'
import
Panel
from
'@/app/components/base/panel'
import
type
{
CompletionParams
}
from
'@/models/debug'
import
type
{
CompletionParams
}
from
'@/models/debug'
import
{
AppType
,
ProviderType
}
from
'@/types/app'
import
{
AppType
,
ProviderType
}
from
'@/types/app'
import
{
TONE_LIST
}
from
'@/config'
import
{
MODEL_LIST
,
TONE_LIST
}
from
'@/config'
import
Toast
from
'@/app/components/base/toast'
import
Toast
from
'@/app/components/base/toast'
import
{
AlertTriangle
}
from
'@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
import
{
AlertTriangle
}
from
'@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
import
{
formatNumber
}
from
'@/utils/format'
import
{
formatNumber
}
from
'@/utils/format'
export
type
IConifgModelProps
=
{
export
type
IConifgModelProps
=
{
mode
:
string
mode
:
string
modelId
:
string
modelId
:
string
...
@@ -26,19 +26,7 @@ export type IConifgModelProps = {
...
@@ -26,19 +26,7 @@ export type IConifgModelProps = {
onShowUseGPT4Confirm
:
()
=>
void
onShowUseGPT4Confirm
:
()
=>
void
}
}
const
options
=
[
const
options
=
MODEL_LIST
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
chat
},
// 8k version
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
chat
,
provider
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
chat
,
provider
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
completion
},
{
id
:
'text-davinci-003'
,
name
:
'text-davinci-003'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
completion
},
// 8k version
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
completion
,
provider
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
completion
,
provider
:
ProviderType
.
anthropic
},
// set 30k
]
const
getMaxToken
=
(
modelId
:
string
)
=>
{
const
getMaxToken
=
(
modelId
:
string
)
=>
{
if
([
'claude-instant-1'
,
'claude-2'
].
includes
(
modelId
))
if
([
'claude-instant-1'
,
'claude-2'
].
includes
(
modelId
))
...
@@ -50,30 +38,6 @@ const getMaxToken = (modelId: string) => {
...
@@ -50,30 +38,6 @@ const getMaxToken = (modelId: string) => {
return
4000
return
4000
}
}
const
ModelIcon
=
({
provider
,
className
}:
{
provider
?:
ProviderType
;
className
?:
string
})
=>
{
if
(
provider
===
ProviderType
.
anthropic
)
{
return
(
<
svg
className=
{
`w-4 h-4 ${className}`
}
width=
"24"
height=
"24"
viewBox=
"0 0 24 24"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<
rect
width=
"24"
height=
"24"
rx=
"6"
fill=
"#CA9F7B"
/>
<
g
clip
-
path=
"url(#clip0_3907_39360)"
>
<
path
d=
"M14.9613 7.13043H12.8476L16.7022 16.8696H18.8159L14.9613 7.13043ZM8.85457 7.13043L5 16.8696H7.15539L7.94365 14.8243H11.9763L12.7645 16.8696H14.9199L11.0653 7.13043H8.85457ZM8.64091 13.0156L9.95996 9.59291L11.279 13.0156H8.64091Z"
fill=
"#191918"
/>
</
g
>
<
defs
>
<
clipPath
id=
"clip0_3907_39360"
>
<
rect
width=
"14"
height=
"9.73913"
fill=
"white"
transform=
"translate(5 7.13043)"
/>
</
clipPath
>
</
defs
>
</
svg
>
)
}
return
(
<
svg
className=
{
`w-4 h-4 ${className}`
}
width=
"20"
height=
"20"
viewBox=
"0 0 20 20"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<
rect
width=
"20"
height=
"20"
rx=
"6"
fill=
"black"
/>
<
path
d=
"M16.5963 9.65729C16.748 9.99569 16.8443 10.3574 16.8836 10.7265C16.9216 11.0955 16.9026 11.4689 16.8238 11.8321C16.7465 12.1953 16.6123 12.5439 16.4256 12.8648C16.3031 13.0793 16.1587 13.2805 15.9924 13.4658C15.8276 13.6496 15.6438 13.8159 15.444 13.9617C15.2427 14.1076 15.0283 14.2301 14.8007 14.3308C14.5746 14.4299 14.3383 14.5058 14.0962 14.5554C13.9824 14.9084 13.8132 15.2424 13.5944 15.5429C13.3771 15.8434 13.1131 16.1074 12.8126 16.3247C12.5121 16.5435 12.1795 16.7127 11.8266 16.8265C11.4736 16.9417 11.1045 16.9986 10.7326 16.9986C10.4861 17.0001 10.2381 16.9738 9.99596 16.9242C9.75529 16.8732 9.51899 16.7959 9.2929 16.6952C9.06681 16.5946 8.85239 16.4691 8.65256 16.3233C8.45418 16.1774 8.2704 16.0097 8.10703 15.8244C7.74237 15.9032 7.36896 15.9221 6.99992 15.8842C6.63089 15.8448 6.26914 15.7486 5.92928 15.5969C5.59088 15.4466 5.27727 15.2424 5.00159 14.993C4.72591 14.7436 4.49107 14.4518 4.30582 14.1309C4.18184 13.9165 4.07973 13.6904 4.00242 13.4556C3.92511 13.2207 3.87406 12.9786 3.84781 12.7321C3.82155 12.487 3.82301 12.2391 3.84927 11.9926C3.87552 11.7475 3.92949 11.5054 4.0068 11.2705C3.75883 10.9949 3.55462 10.6813 3.40292 10.3428C3.25268 10.003 3.15495 9.6427 3.11703 9.27367C3.07765 8.90463 3.09807 8.53122 3.17538 8.16802C3.25268 7.80482 3.38688 7.4562 3.57358 7.1353C3.69611 6.92088 3.84051 6.71813 4.00534 6.53434C4.17017 6.35056 4.35541 6.18427 4.55525 6.03841C4.75508 5.89254 4.97096 5.76856 5.19705 5.66937C5.42459 5.56873 5.66089 5.49434 5.90303 5.44474C6.0168 5.09029 6.186 4.75772 6.40334 4.45725C6.62213 4.15677 6.88615 3.89275 7.18663 3.67396C7.48711 3.45662 7.81968 3.28742 8.17267 3.17219C8.52566 3.05841 8.89469 3.00007 9.26664 3.00153C9.51315 3.00007 9.76112 3.02486 10.0033 3.07592C10.2454 3.12697 10.4817 3.20282 10.7078 3.30346C10.9339 3.40557 11.1483 3.52955 11.3481 3.67542C11.548 3.82274 11.7317 3.98902 11.8951 4.17427C12.2583 4.09696 12.6317 4.078 13.0008 4.11592C13.3698 4.15385 13.7301 4.25158 14.0699 4.40182C14.4083 4.55352 14.7219 4.75627 14.9976 5.00569C15.2733 5.25366 15.5082 5.54393 15.6934 5.86629C15.8174 6.07925 15.9195 6.30534 15.9968 6.54164C16.0741 6.77648 16.1266 7.01861 16.1514 7.26512C16.1777 7.51163 16.1777 7.7596 16.15 8.00611C16.1237 8.25262 16.0697 8.49475 15.9924 8.72959C16.2418 9.00528 16.4446 9.31742 16.5963 9.65729ZM11.7361 15.8842C12.0541 15.7529 12.3429 15.5589 12.5865 15.3153C12.8301 15.0717 13.0241 14.7829 13.1554 14.4635C13.2866 14.1455 13.3552 13.8042 13.3552 13.46V10.2072C13.3542 10.2043 13.3533 10.2009 13.3523 10.197C13.3513 10.1941 13.3499 10.1911 13.3479 10.1882C13.346 10.1853 13.3435 10.1829 13.3406 10.1809C13.3377 10.178 13.3348 10.1761 13.3319 10.1751L12.1547 9.49538V13.4249C12.1547 13.4643 12.1489 13.5052 12.1387 13.5431C12.1285 13.5825 12.1139 13.6189 12.0935 13.654C12.0731 13.689 12.0497 13.7211 12.0206 13.7488C11.9922 13.777 11.9603 13.8015 11.9257 13.8217L9.13828 15.4306C9.11495 15.4452 9.07556 15.4656 9.05514 15.4772C9.17037 15.575 9.29582 15.661 9.42709 15.7369C9.55983 15.8127 9.69694 15.8769 9.83989 15.9294C9.98284 15.9805 10.1302 16.0199 10.2789 16.0461C10.4292 16.0724 10.5809 16.0855 10.7326 16.0855C11.0768 16.0855 11.4181 16.0169 11.7361 15.8842ZM5.09786 13.6758C5.27144 13.9749 5.50044 14.2345 5.77321 14.4445C6.04743 14.6546 6.35812 14.8077 6.69069 14.8967C7.02326 14.9857 7.37042 15.009 7.71174 14.9638C8.05306 14.9186 8.38125 14.8077 8.68027 14.6356L11.4984 13.0092L11.5057 13.0019C11.5076 13 11.5091 12.9971 11.51 12.9932C11.512 12.9903 11.5134 12.9874 11.5144 12.9844V11.6133L8.11286 13.581C8.07786 13.6014 8.04139 13.616 8.00346 13.6277C7.96408 13.6379 7.9247 13.6423 7.88386 13.6423C7.84447 13.6423 7.80509 13.6379 7.76571 13.6277C7.72778 13.616 7.68986 13.6014 7.65485 13.581L4.86739 11.9707C4.8426 11.9561 4.80613 11.9342 4.78571 11.9211C4.75946 12.0713 4.74633 12.223 4.74633 12.3747C4.74633 12.5264 4.76091 12.6781 4.78717 12.8284C4.81342 12.9771 4.85427 13.1245 4.90532 13.2674C4.95783 13.4104 5.02201 13.5475 5.09786 13.6788V13.6758ZM4.36562 7.59332C4.1935 7.89234 4.08265 8.22199 4.03743 8.56331C3.99221 8.90463 4.01555 9.25033 4.10453 9.58436C4.1935 9.91692 4.34666 10.2276 4.5567 10.5018C4.76675 10.7746 5.02784 11.0036 5.32541 11.1757L8.14204 12.8036C8.14495 12.8045 8.14836 12.8055 8.15225 12.8065H8.16246C8.16635 12.8065 8.16975 12.8055 8.17267 12.8036C8.17558 12.8026 8.1785 12.8011 8.18142 12.7992L9.36291 12.1165L5.96137 10.1532C5.92782 10.1328 5.89573 10.108 5.86656 10.0803C5.8383 10.0519 5.81379 10.0201 5.79363 9.98548C5.77467 9.95047 5.75862 9.91401 5.74841 9.87462C5.7382 9.8367 5.73237 9.79732 5.73383 9.75647V6.44391C5.59088 6.49642 5.45231 6.5606 5.32103 6.63645C5.18975 6.71376 5.06577 6.80128 4.94908 6.899C4.83385 6.99673 4.72591 7.10467 4.62818 7.22136C4.53045 7.3366 4.44439 7.46204 4.36854 7.59332H4.36562ZM14.0408 9.84545C14.0758 9.86587 14.1079 9.88921 14.137 9.91838C14.1647 9.9461 14.1895 9.97819 14.21 10.0132C14.2289 10.0482 14.245 10.0861 14.2552 10.1241C14.2639 10.1634 14.2698 10.2028 14.2683 10.2437V13.5562C14.7365 13.3841 15.145 13.0822 15.4469 12.6854C15.7503 12.2887 15.9326 11.8146 15.9749 11.3187C16.0172 10.8227 15.918 10.3239 15.6876 9.88192C15.4571 9.43995 15.1056 9.07237 14.6738 8.82441L11.8572 7.19657C11.8543 7.19559 11.8509 7.19462 11.847 7.19365H11.8368C11.8338 7.19462 11.8304 7.19559 11.8266 7.19657C11.8236 7.19754 11.8207 7.199 11.8178 7.20094L10.6421 7.88067L14.0437 9.84545H14.0408ZM15.215 8.0805H15.2135V8.08196L15.215 8.0805ZM15.2135 8.07904C15.2981 7.58894 15.2412 7.08425 15.0487 6.62478C14.8576 6.16531 14.5382 5.77002 14.1297 5.48413C13.7213 5.19969 13.24 5.03632 12.7426 5.01445C12.2437 4.99402 11.7507 5.11509 11.3189 5.36306L8.50232 6.98944C8.4994 6.99138 8.49697 6.99382 8.49503 6.99673L8.48919 7.00549C8.48822 7.0084 8.48725 7.01181 8.48627 7.0157C8.4853 7.01861 8.48482 7.02202 8.48482 7.02591V8.38536L11.8864 6.42057C11.9214 6.40015 11.9593 6.38556 11.9972 6.37389C12.0366 6.36368 12.076 6.35931 12.1154 6.35931C12.1562 6.35931 12.1956 6.36368 12.235 6.37389C12.2729 6.38556 12.3094 6.40015 12.3444 6.42057L15.1318 8.03091C15.1566 8.04549 15.1931 8.06591 15.2135 8.07904ZM7.84301 6.57373C7.84301 6.53434 7.84885 6.49496 7.85906 6.45558C7.86927 6.41765 7.88386 6.37973 7.90428 6.34472C7.9247 6.31117 7.94804 6.27908 7.97721 6.24991C8.00492 6.2222 8.03701 6.1974 8.07202 6.17844L10.8595 4.56956C10.8857 4.55352 10.9222 4.53309 10.9426 4.52288C10.5605 4.20344 10.0937 3.99923 9.59921 3.93651C9.10474 3.87233 8.60296 3.9511 8.15225 4.1626C7.70007 4.3741 7.3179 4.71105 7.05097 5.13114C6.78404 5.55268 6.64256 6.03987 6.64256 6.53872V9.79148C6.64353 9.79537 6.6445 9.79878 6.64547 9.80169C6.64645 9.80461 6.6479 9.80753 6.64985 9.81044C6.65179 9.81336 6.65422 9.81628 6.65714 9.8192C6.65909 9.82114 6.662 9.82309 6.66589 9.82503L7.84301 10.5048V6.57373ZM8.4819 10.8723L9.99742 11.7475L11.5129 10.8723V9.12343L9.99888 8.24824L8.48336 9.12343L8.4819 10.8723Z"
fill=
"white"
/>
</
svg
>
)
}
const
ConifgModel
:
FC
<
IConifgModelProps
>
=
({
const
ConifgModel
:
FC
<
IConifgModelProps
>
=
({
mode
,
mode
,
modelId
,
modelId
,
...
...
web/app/components/app/configuration/config-model/model-icon.tsx
0 → 100644
View file @
2374af61
'use client'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
{
ProviderType
}
from
'@/types/app'
export
type
IModelIconProps
=
{
provider
?:
ProviderType
;
className
?:
string
}
const
ModelIcon
:
FC
<
IModelIconProps
>
=
({
provider
,
className
})
=>
{
if
(
provider
===
ProviderType
.
anthropic
)
{
return
(
<
svg
className=
{
`w-4 h-4 ${className}`
}
width=
"24"
height=
"24"
viewBox=
"0 0 24 24"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<
rect
width=
"24"
height=
"24"
rx=
"6"
fill=
"#CA9F7B"
/>
<
g
clip
-
path=
"url(#clip0_3907_39360)"
>
<
path
d=
"M14.9613 7.13043H12.8476L16.7022 16.8696H18.8159L14.9613 7.13043ZM8.85457 7.13043L5 16.8696H7.15539L7.94365 14.8243H11.9763L12.7645 16.8696H14.9199L11.0653 7.13043H8.85457ZM8.64091 13.0156L9.95996 9.59291L11.279 13.0156H8.64091Z"
fill=
"#191918"
/>
</
g
>
<
defs
>
<
clipPath
id=
"clip0_3907_39360"
>
<
rect
width=
"14"
height=
"9.73913"
fill=
"white"
transform=
"translate(5 7.13043)"
/>
</
clipPath
>
</
defs
>
</
svg
>
)
}
return
(
<
svg
className=
{
`w-4 h-4 ${className}`
}
width=
"20"
height=
"20"
viewBox=
"0 0 20 20"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<
rect
width=
"20"
height=
"20"
rx=
"6"
fill=
"black"
/>
<
path
d=
"M16.5963 9.65729C16.748 9.99569 16.8443 10.3574 16.8836 10.7265C16.9216 11.0955 16.9026 11.4689 16.8238 11.8321C16.7465 12.1953 16.6123 12.5439 16.4256 12.8648C16.3031 13.0793 16.1587 13.2805 15.9924 13.4658C15.8276 13.6496 15.6438 13.8159 15.444 13.9617C15.2427 14.1076 15.0283 14.2301 14.8007 14.3308C14.5746 14.4299 14.3383 14.5058 14.0962 14.5554C13.9824 14.9084 13.8132 15.2424 13.5944 15.5429C13.3771 15.8434 13.1131 16.1074 12.8126 16.3247C12.5121 16.5435 12.1795 16.7127 11.8266 16.8265C11.4736 16.9417 11.1045 16.9986 10.7326 16.9986C10.4861 17.0001 10.2381 16.9738 9.99596 16.9242C9.75529 16.8732 9.51899 16.7959 9.2929 16.6952C9.06681 16.5946 8.85239 16.4691 8.65256 16.3233C8.45418 16.1774 8.2704 16.0097 8.10703 15.8244C7.74237 15.9032 7.36896 15.9221 6.99992 15.8842C6.63089 15.8448 6.26914 15.7486 5.92928 15.5969C5.59088 15.4466 5.27727 15.2424 5.00159 14.993C4.72591 14.7436 4.49107 14.4518 4.30582 14.1309C4.18184 13.9165 4.07973 13.6904 4.00242 13.4556C3.92511 13.2207 3.87406 12.9786 3.84781 12.7321C3.82155 12.487 3.82301 12.2391 3.84927 11.9926C3.87552 11.7475 3.92949 11.5054 4.0068 11.2705C3.75883 10.9949 3.55462 10.6813 3.40292 10.3428C3.25268 10.003 3.15495 9.6427 3.11703 9.27367C3.07765 8.90463 3.09807 8.53122 3.17538 8.16802C3.25268 7.80482 3.38688 7.4562 3.57358 7.1353C3.69611 6.92088 3.84051 6.71813 4.00534 6.53434C4.17017 6.35056 4.35541 6.18427 4.55525 6.03841C4.75508 5.89254 4.97096 5.76856 5.19705 5.66937C5.42459 5.56873 5.66089 5.49434 5.90303 5.44474C6.0168 5.09029 6.186 4.75772 6.40334 4.45725C6.62213 4.15677 6.88615 3.89275 7.18663 3.67396C7.48711 3.45662 7.81968 3.28742 8.17267 3.17219C8.52566 3.05841 8.89469 3.00007 9.26664 3.00153C9.51315 3.00007 9.76112 3.02486 10.0033 3.07592C10.2454 3.12697 10.4817 3.20282 10.7078 3.30346C10.9339 3.40557 11.1483 3.52955 11.3481 3.67542C11.548 3.82274 11.7317 3.98902 11.8951 4.17427C12.2583 4.09696 12.6317 4.078 13.0008 4.11592C13.3698 4.15385 13.7301 4.25158 14.0699 4.40182C14.4083 4.55352 14.7219 4.75627 14.9976 5.00569C15.2733 5.25366 15.5082 5.54393 15.6934 5.86629C15.8174 6.07925 15.9195 6.30534 15.9968 6.54164C16.0741 6.77648 16.1266 7.01861 16.1514 7.26512C16.1777 7.51163 16.1777 7.7596 16.15 8.00611C16.1237 8.25262 16.0697 8.49475 15.9924 8.72959C16.2418 9.00528 16.4446 9.31742 16.5963 9.65729ZM11.7361 15.8842C12.0541 15.7529 12.3429 15.5589 12.5865 15.3153C12.8301 15.0717 13.0241 14.7829 13.1554 14.4635C13.2866 14.1455 13.3552 13.8042 13.3552 13.46V10.2072C13.3542 10.2043 13.3533 10.2009 13.3523 10.197C13.3513 10.1941 13.3499 10.1911 13.3479 10.1882C13.346 10.1853 13.3435 10.1829 13.3406 10.1809C13.3377 10.178 13.3348 10.1761 13.3319 10.1751L12.1547 9.49538V13.4249C12.1547 13.4643 12.1489 13.5052 12.1387 13.5431C12.1285 13.5825 12.1139 13.6189 12.0935 13.654C12.0731 13.689 12.0497 13.7211 12.0206 13.7488C11.9922 13.777 11.9603 13.8015 11.9257 13.8217L9.13828 15.4306C9.11495 15.4452 9.07556 15.4656 9.05514 15.4772C9.17037 15.575 9.29582 15.661 9.42709 15.7369C9.55983 15.8127 9.69694 15.8769 9.83989 15.9294C9.98284 15.9805 10.1302 16.0199 10.2789 16.0461C10.4292 16.0724 10.5809 16.0855 10.7326 16.0855C11.0768 16.0855 11.4181 16.0169 11.7361 15.8842ZM5.09786 13.6758C5.27144 13.9749 5.50044 14.2345 5.77321 14.4445C6.04743 14.6546 6.35812 14.8077 6.69069 14.8967C7.02326 14.9857 7.37042 15.009 7.71174 14.9638C8.05306 14.9186 8.38125 14.8077 8.68027 14.6356L11.4984 13.0092L11.5057 13.0019C11.5076 13 11.5091 12.9971 11.51 12.9932C11.512 12.9903 11.5134 12.9874 11.5144 12.9844V11.6133L8.11286 13.581C8.07786 13.6014 8.04139 13.616 8.00346 13.6277C7.96408 13.6379 7.9247 13.6423 7.88386 13.6423C7.84447 13.6423 7.80509 13.6379 7.76571 13.6277C7.72778 13.616 7.68986 13.6014 7.65485 13.581L4.86739 11.9707C4.8426 11.9561 4.80613 11.9342 4.78571 11.9211C4.75946 12.0713 4.74633 12.223 4.74633 12.3747C4.74633 12.5264 4.76091 12.6781 4.78717 12.8284C4.81342 12.9771 4.85427 13.1245 4.90532 13.2674C4.95783 13.4104 5.02201 13.5475 5.09786 13.6788V13.6758ZM4.36562 7.59332C4.1935 7.89234 4.08265 8.22199 4.03743 8.56331C3.99221 8.90463 4.01555 9.25033 4.10453 9.58436C4.1935 9.91692 4.34666 10.2276 4.5567 10.5018C4.76675 10.7746 5.02784 11.0036 5.32541 11.1757L8.14204 12.8036C8.14495 12.8045 8.14836 12.8055 8.15225 12.8065H8.16246C8.16635 12.8065 8.16975 12.8055 8.17267 12.8036C8.17558 12.8026 8.1785 12.8011 8.18142 12.7992L9.36291 12.1165L5.96137 10.1532C5.92782 10.1328 5.89573 10.108 5.86656 10.0803C5.8383 10.0519 5.81379 10.0201 5.79363 9.98548C5.77467 9.95047 5.75862 9.91401 5.74841 9.87462C5.7382 9.8367 5.73237 9.79732 5.73383 9.75647V6.44391C5.59088 6.49642 5.45231 6.5606 5.32103 6.63645C5.18975 6.71376 5.06577 6.80128 4.94908 6.899C4.83385 6.99673 4.72591 7.10467 4.62818 7.22136C4.53045 7.3366 4.44439 7.46204 4.36854 7.59332H4.36562ZM14.0408 9.84545C14.0758 9.86587 14.1079 9.88921 14.137 9.91838C14.1647 9.9461 14.1895 9.97819 14.21 10.0132C14.2289 10.0482 14.245 10.0861 14.2552 10.1241C14.2639 10.1634 14.2698 10.2028 14.2683 10.2437V13.5562C14.7365 13.3841 15.145 13.0822 15.4469 12.6854C15.7503 12.2887 15.9326 11.8146 15.9749 11.3187C16.0172 10.8227 15.918 10.3239 15.6876 9.88192C15.4571 9.43995 15.1056 9.07237 14.6738 8.82441L11.8572 7.19657C11.8543 7.19559 11.8509 7.19462 11.847 7.19365H11.8368C11.8338 7.19462 11.8304 7.19559 11.8266 7.19657C11.8236 7.19754 11.8207 7.199 11.8178 7.20094L10.6421 7.88067L14.0437 9.84545H14.0408ZM15.215 8.0805H15.2135V8.08196L15.215 8.0805ZM15.2135 8.07904C15.2981 7.58894 15.2412 7.08425 15.0487 6.62478C14.8576 6.16531 14.5382 5.77002 14.1297 5.48413C13.7213 5.19969 13.24 5.03632 12.7426 5.01445C12.2437 4.99402 11.7507 5.11509 11.3189 5.36306L8.50232 6.98944C8.4994 6.99138 8.49697 6.99382 8.49503 6.99673L8.48919 7.00549C8.48822 7.0084 8.48725 7.01181 8.48627 7.0157C8.4853 7.01861 8.48482 7.02202 8.48482 7.02591V8.38536L11.8864 6.42057C11.9214 6.40015 11.9593 6.38556 11.9972 6.37389C12.0366 6.36368 12.076 6.35931 12.1154 6.35931C12.1562 6.35931 12.1956 6.36368 12.235 6.37389C12.2729 6.38556 12.3094 6.40015 12.3444 6.42057L15.1318 8.03091C15.1566 8.04549 15.1931 8.06591 15.2135 8.07904ZM7.84301 6.57373C7.84301 6.53434 7.84885 6.49496 7.85906 6.45558C7.86927 6.41765 7.88386 6.37973 7.90428 6.34472C7.9247 6.31117 7.94804 6.27908 7.97721 6.24991C8.00492 6.2222 8.03701 6.1974 8.07202 6.17844L10.8595 4.56956C10.8857 4.55352 10.9222 4.53309 10.9426 4.52288C10.5605 4.20344 10.0937 3.99923 9.59921 3.93651C9.10474 3.87233 8.60296 3.9511 8.15225 4.1626C7.70007 4.3741 7.3179 4.71105 7.05097 5.13114C6.78404 5.55268 6.64256 6.03987 6.64256 6.53872V9.79148C6.64353 9.79537 6.6445 9.79878 6.64547 9.80169C6.64645 9.80461 6.6479 9.80753 6.64985 9.81044C6.65179 9.81336 6.65422 9.81628 6.65714 9.8192C6.65909 9.82114 6.662 9.82309 6.66589 9.82503L7.84301 10.5048V6.57373ZM8.4819 10.8723L9.99742 11.7475L11.5129 10.8723V9.12343L9.99888 8.24824L8.48336 9.12343L8.4819 10.8723Z"
fill=
"white"
/>
</
svg
>
)
}
export
default
React
.
memo
(
ModelIcon
)
web/app/components/explore/universal-chat/config/index.tsx
View file @
2374af61
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
React
from
'react'
import
ModelConfig
from
'./model-config'
import
DataConfig
from
'./data-config'
import
DataConfig
from
'./data-config'
import
PluginConfig
from
'./plug-config'
import
PluginConfig
from
'./plug
ins
-config'
export
type
IConfigProps
=
{
export
type
IConfigProps
=
{
className
?:
string
className
?:
string
readonly
?:
boolean
modelId
:
string
onModelChange
:
(
modelId
:
string
)
=>
void
plugins
:
Record
<
string
,
boolean
>
plugins
:
Record
<
string
,
boolean
>
onPluginChange
:
(
key
:
string
,
value
:
boolean
)
=>
void
onPluginChange
:
(
key
:
string
,
value
:
boolean
)
=>
void
dataSets
:
any
[]
dataSets
:
any
[]
...
@@ -14,6 +18,9 @@ export type IConfigProps = {
...
@@ -14,6 +18,9 @@ export type IConfigProps = {
const
Config
:
FC
<
IConfigProps
>
=
({
const
Config
:
FC
<
IConfigProps
>
=
({
className
,
className
,
readonly
,
modelId
,
onModelChange
,
plugins
,
plugins
,
onPluginChange
,
onPluginChange
,
dataSets
,
dataSets
,
...
@@ -21,9 +28,11 @@ const Config: FC<IConfigProps> = ({
...
@@ -21,9 +28,11 @@ const Config: FC<IConfigProps> = ({
})
=>
{
})
=>
{
return
(
return
(
<
div
className=
{
className
}
>
<
div
className=
{
className
}
>
<
div
>
<
ModelConfig
readonly=
{
readonly
}
</
div
>
modelId=
{
modelId
}
onChange=
{
onModelChange
}
/>
<
PluginConfig
<
PluginConfig
config=
{
plugins
}
config=
{
plugins
}
onChange=
{
onPluginChange
}
onChange=
{
onPluginChange
}
...
...
web/app/components/explore/universal-chat/config/model-config/index.tsx
0 → 100644
View file @
2374af61
'use client'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
cn
from
'classnames'
import
{
useBoolean
,
useClickAway
}
from
'ahooks'
import
{
ChevronDownIcon
}
from
'@heroicons/react/24/outline'
import
ModelIcon
from
'@/app/components/app/configuration/config-model/model-icon'
import
{
UNIVERSAL_CHAT_MODEL_LIST
as
MODEL_LIST
}
from
'@/config'
console
.
log
(
MODEL_LIST
)
export
type
IModelConfigProps
=
{
modelId
:
string
onChange
:
(
model
:
string
)
=>
void
readonly
?:
boolean
}
const
ModelConfig
:
FC
<
IModelConfigProps
>
=
({
modelId
,
onChange
,
readonly
,
})
=>
{
const
currModel
=
MODEL_LIST
.
find
(
item
=>
item
.
id
===
modelId
)
const
[
isShowOption
,
{
setFalse
:
hideOption
,
toggle
:
toogleOption
}]
=
useBoolean
(
false
)
const
triggerRef
=
React
.
useRef
(
null
)
useClickAway
(()
=>
{
hideOption
()
},
triggerRef
)
return
(
<
div
className=
'flex items-center justify-between h-[52px] px-3 rounded-xl bg-gray-50'
>
<
div
className=
'text-sm font-semibold text-gray-800'
>
Model
</
div
>
<
div
className=
"relative"
style=
{
{
zIndex
:
30
}
}
>
<
div
ref=
{
triggerRef
}
onClick=
{
()
=>
!
readonly
&&
toogleOption
()
}
className=
{
cn
(
readonly
?
'cursor-not-allowed'
:
'cursor-pointer'
,
'flex items-center h-9 px-3 space-x-2 rounded-lg bg-gray-50 '
)
}
>
<
ModelIcon
provider=
{
currModel
?.
provider
}
/>
<
div
className=
"text-sm gray-900"
>
{
currModel
?.
name
}
</
div
>
{
!
readonly
&&
<
ChevronDownIcon
className=
{
cn
(
isShowOption
&&
'rotate-180'
,
'w-[14px] h-[14px] text-gray-500'
)
}
/>
}
</
div
>
{
isShowOption
&&
(
<
div
className=
{
cn
(
'min-w-[159px] absolute right-0 bg-gray-50 rounded-lg shadow'
)
}
>
{
MODEL_LIST
.
map
(
item
=>
(
<
div
key=
{
item
.
id
}
onClick=
{
()
=>
onChange
(
item
.
id
)
}
className=
"flex items-center h-9 px-3 rounded-lg cursor-pointer hover:bg-gray-100"
>
<
ModelIcon
className=
'shrink-0 mr-2'
provider=
{
item
?.
provider
}
/>
<
div
className=
"text-sm gray-900 whitespace-nowrap"
>
{
item
.
name
}
</
div
>
</
div
>
))
}
</
div
>
)
}
</
div
>
</
div
>
)
}
export
default
React
.
memo
(
ModelConfig
)
web/app/components/explore/universal-chat/config/plug-config/index.tsx
→
web/app/components/explore/universal-chat/config/plug
ins
-config/index.tsx
View file @
2374af61
File moved
web/app/components/explore/universal-chat/config/plug-config/item.module.css
→
web/app/components/explore/universal-chat/config/plug
ins
-config/item.module.css
View file @
2374af61
File moved
web/app/components/explore/universal-chat/config/plug-config/item.tsx
→
web/app/components/explore/universal-chat/config/plug
ins
-config/item.tsx
View file @
2374af61
File moved
web/app/components/explore/universal-chat/index.tsx
View file @
2374af61
...
@@ -35,6 +35,7 @@ import { replaceStringWithValues } from '@/app/components/app/configuration/prom
...
@@ -35,6 +35,7 @@ import { replaceStringWithValues } from '@/app/components/app/configuration/prom
import
{
userInputsFormToPromptVariables
}
from
'@/utils/model-config'
import
{
userInputsFormToPromptVariables
}
from
'@/utils/model-config'
import
Confirm
from
'@/app/components/base/confirm'
import
Confirm
from
'@/app/components/base/confirm'
import
type
{
DataSet
}
from
'@/models/datasets'
import
type
{
DataSet
}
from
'@/models/datasets'
import
{
UNIVERSAL_CHAT_MODEL_LIST
as
MODEL_LIST
}
from
'@/config'
const
APP_ID
=
'universal-chat'
const
APP_ID
=
'universal-chat'
const
isUniversalChat
=
true
const
isUniversalChat
=
true
...
@@ -513,6 +514,9 @@ const Main: FC<IMainProps> = () => {
...
@@ -513,6 +514,9 @@ const Main: FC<IMainProps> = () => {
)
)
}
}
const
[
modelId
,
setModeId
]
=
useState
(
'gpt-3.5-turbo'
)
const
currModel
=
MODEL_LIST
.
find
(
item
=>
item
.
id
===
modelId
)
const
[
plugins
,
setPlugins
]
=
useState
<
Record
<
string
,
boolean
>>
({
const
[
plugins
,
setPlugins
]
=
useState
<
Record
<
string
,
boolean
>>
({
google_search
:
false
,
google_search
:
false
,
web_reader
:
true
,
web_reader
:
true
,
...
@@ -564,6 +568,8 @@ const Main: FC<IMainProps> = () => {
...
@@ -564,6 +568,8 @@ const Main: FC<IMainProps> = () => {
<
div
className=
'h-full overflow-y-auto'
ref=
{
chatListDomRef
}
>
<
div
className=
'h-full overflow-y-auto'
ref=
{
chatListDomRef
}
>
<
Chat
<
Chat
configElem=
{
<
Init
configElem=
{
<
Init
modelId=
{
modelId
}
onModelChange=
{
setModeId
}
plugins=
{
plugins
}
plugins=
{
plugins
}
onPluginChange=
{
handlePluginsChange
}
onPluginChange=
{
handlePluginsChange
}
dataSets=
{
dataSets
}
dataSets=
{
dataSets
}
...
...
web/config/index.ts
View file @
2374af61
/* eslint-disable import/no-mutable-exports */
/* eslint-disable import/no-mutable-exports */
import
{
AppType
,
ProviderType
}
from
'@/types/app'
const
isDevelopment
=
process
.
env
.
NODE_ENV
===
'development'
const
isDevelopment
=
process
.
env
.
NODE_ENV
===
'development'
export
let
apiPrefix
=
''
export
let
apiPrefix
=
''
...
@@ -37,6 +39,21 @@ export const PUBLIC_API_PREFIX: string = publicApiPrefix
...
@@ -37,6 +39,21 @@ export const PUBLIC_API_PREFIX: string = publicApiPrefix
const
EDITION
=
process
.
env
.
NEXT_PUBLIC_EDITION
||
globalThis
.
document
?.
body
?.
getAttribute
(
'data-public-edition'
)
const
EDITION
=
process
.
env
.
NEXT_PUBLIC_EDITION
||
globalThis
.
document
?.
body
?.
getAttribute
(
'data-public-edition'
)
export
const
IS_CE_EDITION
=
EDITION
===
'SELF_HOSTED'
export
const
IS_CE_EDITION
=
EDITION
===
'SELF_HOSTED'
export
const
MODEL_LIST
=
[
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
chat
},
// 8k version
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
chat
,
provider
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
chat
,
provider
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
completion
},
{
id
:
'text-davinci-003'
,
name
:
'text-davinci-003'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
completion
},
// 8k version
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
completion
,
provider
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
completion
,
provider
:
ProviderType
.
anthropic
},
// set 30k
]
const
UNIVERSAL_CHAT_MODEL_ID_LIST
=
[
'gpt-3.5-turbo'
,
'gpt-3.5-turbo-16k'
,
'gpt-4'
,
'claude-2'
]
export
const
UNIVERSAL_CHAT_MODEL_LIST
=
MODEL_LIST
.
filter
(({
id
,
type
})
=>
UNIVERSAL_CHAT_MODEL_ID_LIST
.
includes
(
id
)
&&
(
type
===
AppType
.
chat
))
export
const
TONE_LIST
=
[
export
const
TONE_LIST
=
[
{
{
id
:
1
,
id
:
1
,
...
...
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