Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webapp-conversation
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
webapp-conversation
Commits
83695999
Commit
83695999
authored
Jan 29, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: conversation support show thought
parent
b62e34c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
route.ts
app/api/conversations/[conversationId]/name/route.ts
+0
-1
index.tsx
app/components/index.tsx
+5
-1
tools.ts
utils/tools.ts
+26
-0
No files found.
app/api/conversations/[conversationId]/name/route.ts
View file @
83695999
...
@@ -15,6 +15,5 @@ export async function POST(request: NextRequest, { params }: {
...
@@ -15,6 +15,5 @@ export async function POST(request: NextRequest, { params }: {
// auto generate name
// auto generate name
const
{
data
}
=
await
client
.
renameConversation
(
conversationId
,
name
,
user
,
auto_generate
)
const
{
data
}
=
await
client
.
renameConversation
(
conversationId
,
name
,
user
,
auto_generate
)
console
.
log
(
conversationId
,
name
,
user
,
auto_generate
)
return
NextResponse
.
json
(
data
)
return
NextResponse
.
json
(
data
)
}
}
app/components/index.tsx
View file @
83695999
...
@@ -21,6 +21,7 @@ import { replaceVarWithValues, userInputsFormToPromptVariables } from '@/utils/p
...
@@ -21,6 +21,7 @@ import { replaceVarWithValues, userInputsFormToPromptVariables } from '@/utils/p
import
AppUnavailable
from
'@/app/components/app-unavailable'
import
AppUnavailable
from
'@/app/components/app-unavailable'
import
{
API_KEY
,
APP_ID
,
APP_INFO
,
isShowPrompt
,
promptTemplate
}
from
'@/config'
import
{
API_KEY
,
APP_ID
,
APP_INFO
,
isShowPrompt
,
promptTemplate
}
from
'@/config'
import
type
{
Annotation
as
AnnotationType
}
from
'@/types/log'
import
type
{
Annotation
as
AnnotationType
}
from
'@/types/log'
import
{
addFileInfos
,
sortAgentSorts
}
from
'@/utils/tools'
const
Main
:
FC
=
()
=>
{
const
Main
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
...
@@ -130,13 +131,16 @@ const Main: FC = () => {
...
@@ -130,13 +131,16 @@ const Main: FC = () => {
id
:
`question-
${
item
.
id
}
`
,
id
:
`question-
${
item
.
id
}
`
,
content
:
item
.
query
,
content
:
item
.
query
,
isAnswer
:
false
,
isAnswer
:
false
,
message_files
:
item
.
message_files
,
message_files
:
item
.
message_files
?.
filter
((
file
:
any
)
=>
file
.
belongs_to
===
'user'
)
||
[],
})
})
newChatList
.
push
({
newChatList
.
push
({
id
:
item
.
id
,
id
:
item
.
id
,
content
:
item
.
answer
,
content
:
item
.
answer
,
agent_thoughts
:
addFileInfos
(
item
.
agent_thoughts
?
sortAgentSorts
(
item
.
agent_thoughts
)
:
item
.
agent_thoughts
,
item
.
message_files
),
feedback
:
item
.
feedback
,
feedback
:
item
.
feedback
,
isAnswer
:
true
,
isAnswer
:
true
,
message_files
:
item
.
message_files
?.
filter
((
file
:
any
)
=>
file
.
belongs_to
===
'assistant'
)
||
[],
})
})
})
})
setChatList
(
newChatList
)
setChatList
(
newChatList
)
...
...
utils/tools.ts
0 → 100644
View file @
83695999
import
type
{
ThoughtItem
}
from
'@/app/components/chat/type'
import
type
{
VisionFile
}
from
'@/types/app'
export
const
sortAgentSorts
=
(
list
:
ThoughtItem
[])
=>
{
if
(
!
list
)
return
list
if
(
list
.
some
(
item
=>
item
.
position
===
undefined
))
return
list
const
temp
=
[...
list
]
temp
.
sort
((
a
,
b
)
=>
a
.
position
-
b
.
position
)
return
temp
}
export
const
addFileInfos
=
(
list
:
ThoughtItem
[],
messageFiles
:
VisionFile
[])
=>
{
if
(
!
list
||
!
messageFiles
)
return
list
return
list
.
map
((
item
)
=>
{
if
(
item
.
files
&&
item
.
files
?.
length
>
0
)
{
return
{
...
item
,
message_files
:
item
.
files
.
map
(
fileId
=>
messageFiles
.
find
(
file
=>
file
.
id
===
fileId
))
as
VisionFile
[],
}
}
return
item
})
}
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