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
e061d6a6
Commit
e061d6a6
authored
Jul 27, 2023
by
Joel
Browse files
Options
Browse Files
Download
Plain Diff
mrege
parents
54999264
a3638d4b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
10 deletions
+54
-10
conversation.py
api/controllers/console/app/conversation.py
+6
-0
model.py
api/models/model.py
+3
-1
index.tsx
web/app/components/app/chat/thought/index.tsx
+6
-2
list.tsx
web/app/components/app/log/list.tsx
+1
-1
index.tsx
web/app/components/explore/universal-chat/index.tsx
+33
-4
explore.en.ts
web/i18n/lang/explore.en.ts
+2
-1
explore.zh.ts
web/i18n/lang/explore.zh.ts
+2
-1
log.ts
web/models/log.ts
+1
-0
No files found.
api/controllers/console/app/conversation.py
View file @
e061d6a6
...
...
@@ -95,6 +95,7 @@ class CompletionConversationApi(Resource):
'status'
:
fields
.
String
,
'from_source'
:
fields
.
String
,
'from_end_user_id'
:
fields
.
String
,
'from_end_user_session_id'
:
fields
.
String
(
attribute
=
'end_user.session_id'
),
'from_account_id'
:
fields
.
String
,
'read_at'
:
TimestampField
,
'created_at'
:
TimestampField
,
...
...
@@ -135,6 +136,8 @@ class CompletionConversationApi(Resource):
query
=
db
.
select
(
Conversation
)
.
where
(
Conversation
.
app_id
==
app
.
id
,
Conversation
.
mode
==
'completion'
)
query
=
query
.
options
(
joinedload
(
Conversation
.
end_user
))
if
args
[
'keyword'
]:
query
=
query
.
join
(
Message
,
Message
.
conversation_id
==
Conversation
.
id
...
...
@@ -246,6 +249,7 @@ class ChatConversationApi(Resource):
'status'
:
fields
.
String
,
'from_source'
:
fields
.
String
,
'from_end_user_id'
:
fields
.
String
,
'from_end_user_session_id'
:
fields
.
String
(
attribute
=
'end_user.session_id'
),
'from_account_id'
:
fields
.
String
,
'summary'
:
fields
.
String
(
attribute
=
'summary_or_query'
),
'read_at'
:
TimestampField
,
...
...
@@ -288,6 +292,8 @@ class ChatConversationApi(Resource):
query
=
db
.
select
(
Conversation
)
.
where
(
Conversation
.
app_id
==
app
.
id
,
Conversation
.
mode
==
'chat'
)
query
=
query
.
options
(
joinedload
(
Conversation
.
end_user
))
if
args
[
'keyword'
]:
query
=
query
.
join
(
Message
,
Message
.
conversation_id
==
Conversation
.
id
...
...
api/models/model.py
View file @
e061d6a6
...
...
@@ -226,7 +226,7 @@ class Conversation(db.Model):
system_instruction_tokens
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
server_default
=
db
.
text
(
'0'
))
status
=
db
.
Column
(
db
.
String
(
255
),
nullable
=
False
)
from_source
=
db
.
Column
(
db
.
String
(
255
),
nullable
=
False
)
from_end_user_id
=
db
.
Column
(
UUID
)
from_end_user_id
=
db
.
Column
(
UUID
,
db
.
ForeignKey
(
'end_users.id'
)
)
from_account_id
=
db
.
Column
(
UUID
)
read_at
=
db
.
Column
(
db
.
DateTime
)
read_account_id
=
db
.
Column
(
UUID
)
...
...
@@ -236,6 +236,8 @@ class Conversation(db.Model):
messages
=
db
.
relationship
(
"Message"
,
backref
=
"conversation"
,
lazy
=
'select'
,
passive_deletes
=
"all"
)
message_annotations
=
db
.
relationship
(
"MessageAnnotation"
,
backref
=
"conversation"
,
lazy
=
'select'
,
passive_deletes
=
"all"
)
end_user
=
db
.
relationship
(
"EndUser"
,
backref
=
"conversations"
)
is_deleted
=
db
.
Column
(
db
.
Boolean
,
nullable
=
False
,
server_default
=
db
.
text
(
'false'
))
@
property
...
...
web/app/components/app/chat/thought/index.tsx
View file @
e061d6a6
...
...
@@ -45,8 +45,12 @@ const Thought: FC<IThoughtProps> = ({
return
t
(
'explore.universalChat.thought.res.dataset'
).
replace
(
'{datasetName}'
,
`<span class="text-gray-700">
${
datasetName
}
</span>`
)
case
'web_reader'
:
return
t
(
`explore.universalChat.thought.res.webReader.
${
!
input
.
cursor
?
'normal'
:
'hasPageInfo'
}
`
).
replace
(
'{url}'
,
`<a href="
${
input
.
url
}
" class="text-[#155EEF]">
${
input
.
url
}
</a>`
)
default
:
// google, wikipedia
return
t
(
'explore.universalChat.thought.res.search'
,
{
query
:
input
.
query
})
case
'google_search'
:
return
t
(
'explore.universalChat.thought.res.google'
,
{
query
:
input
.
query
})
case
'wikipedia'
:
return
t
(
'explore.universalChat.thought.res.wikipedia'
,
{
query
:
input
.
query
})
default
:
return
`Unknown tool:
${
item
.
tool
}
`
}
}
catch
(
error
)
{
...
...
web/app/components/app/log/list.tsx
View file @
e061d6a6
...
...
@@ -412,7 +412,7 @@ const ConversationList: FC<IConversationList> = ({ logs, appDetail, onRefresh })
</
thead
>
<
tbody
className=
"text-gray-500"
>
{
logs
.
data
.
map
((
log
)
=>
{
const
endUser
=
log
.
from_end_user_
id
?.
slice
(
0
,
8
)
const
endUser
=
log
.
from_end_user_
session_id
const
leftValue
=
get
(
log
,
isChatMode
?
'summary'
:
'message.query'
)
const
rightValue
=
get
(
log
,
isChatMode
?
'message_count'
:
'message.answer'
)
return
<
tr
...
...
web/app/components/explore/universal-chat/index.tsx
View file @
e061d6a6
...
...
@@ -47,6 +47,28 @@ const DEFAULT_PLUGIN = {
web_reader
:
true
,
wikipedia
:
true
,
}
const
CONFIG_KEY
=
'universal-chat-config'
type
CONFIG
=
{
modelId
:
string
plugin
:
{
google_search
:
boolean
web_reader
:
boolean
wikipedia
:
boolean
}
}
let
prevConfig
:
null
|
CONFIG
=
localStorage
.
getItem
(
CONFIG_KEY
)
?
JSON
.
parse
(
localStorage
.
getItem
(
CONFIG_KEY
)
as
string
)
as
CONFIG
:
null
const
setPrevConfig
=
(
config
:
CONFIG
)
=>
{
prevConfig
=
config
localStorage
.
setItem
(
CONFIG_KEY
,
JSON
.
stringify
(
prevConfig
))
}
const
getInitConfig
=
(
type
:
'model'
|
'plugin'
)
=>
{
if
(
type
===
'model'
)
return
prevConfig
?.
modelId
||
DEFAULT_MODEL_ID
if
(
type
===
'plugin'
)
return
prevConfig
?.
plugin
||
DEFAULT_PLUGIN
}
export
type
IMainProps
=
{}
const
Main
:
FC
<
IMainProps
>
=
()
=>
{
...
...
@@ -415,6 +437,13 @@ const Main: FC<IMainProps> = () => {
const
[
errorHappened
,
setErrorHappened
]
=
useState
(
false
)
const
[
isResponsingConIsCurrCon
,
setIsResponsingConCurrCon
,
getIsResponsingConIsCurrCon
]
=
useGetState
(
true
)
const
handleSend
=
async
(
message
:
string
)
=>
{
if
(
isNewConversation
)
{
setPrevConfig
({
modelId
,
plugin
:
plugins
as
any
,
})
}
if
(
isResponsing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
...
...
@@ -598,10 +627,10 @@ const Main: FC<IMainProps> = () => {
)
}
const
[
modelId
,
setModeId
]
=
useState
(
DEFAULT_MODEL_ID
)
const
[
modelId
,
setModeId
]
=
useState
<
string
>
(
getInitConfig
(
'model'
)
as
string
)
// const currModel = MODEL_LIST.find(item => item.id === modelId)
const
[
plugins
,
setPlugins
]
=
useState
<
Record
<
string
,
boolean
>>
(
DEFAULT_PLUGIN
)
const
[
plugins
,
setPlugins
]
=
useState
<
Record
<
string
,
boolean
>>
(
getInitConfig
(
'plugin'
)
as
Record
<
string
,
boolean
>
)
const
handlePluginsChange
=
(
key
:
string
,
value
:
boolean
)
=>
{
setPlugins
({
...
plugins
,
...
...
@@ -610,8 +639,8 @@ const Main: FC<IMainProps> = () => {
}
const
[
dataSets
,
setDateSets
]
=
useState
<
DataSet
[]
>
([])
const
configSetDefaultValue
=
()
=>
{
setModeId
(
DEFAULT_MODEL_ID
)
setPlugins
(
DEFAULT_PLUGIN
)
setModeId
(
getInitConfig
(
'model'
)
as
string
)
setPlugins
(
getInitConfig
(
'plugin'
)
as
any
)
setDateSets
([])
}
const
isCurrConversationPinned
=
!!
pinnedConversationList
.
find
(
item
=>
item
.
id
===
currConversationId
)
...
...
web/i18n/lang/explore.en.ts
View file @
e061d6a6
...
...
@@ -66,7 +66,8 @@ const translation = {
normal
:
'Reading {url}'
,
hasPageInfo
:
'Reading next page of {url}'
,
},
search
:
'Searching {{query}}'
,
google
:
'Searching Google {{query}}'
,
wikipedia
:
'Searching Wikipedia {{query}}'
,
dataset
:
'Retrieving dataset {datasetName}'
,
},
},
...
...
web/i18n/lang/explore.zh.ts
View file @
e061d6a6
...
...
@@ -66,7 +66,8 @@ const translation = {
normal
:
'解析链接 {url}'
,
hasPageInfo
:
'解析链接 {url} 的下一页'
,
},
search
:
'搜索 {{query}}'
,
google
:
'搜索谷歌 {{query}}'
,
wikipedia
:
'搜索维基百科 {{query}}'
,
dataset
:
'检索数据集 {datasetName}'
,
},
},
...
...
web/models/log.ts
View file @
e061d6a6
...
...
@@ -79,6 +79,7 @@ export type CompletionConversationGeneralDetail = {
status
:
'normal'
|
'finished'
from_source
:
'api'
|
'console'
from_end_user_id
:
string
from_end_user_session_id
:
string
from_account_id
:
string
read_at
:
Date
created_at
:
number
...
...
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