Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
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
mobile-group
galaxy-iOS
Commits
47a4f7b9
Commit
47a4f7b9
authored
Dec 09, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
fef975de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
34 deletions
+28
-34
YHAIMainChatViewController.swift
...s/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
+16
-20
YHAIRobotChatViewController.swift
.../AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
+12
-14
No files found.
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
View file @
47a4f7b9
...
@@ -111,19 +111,21 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -111,19 +111,21 @@ class YHAIMainChatViewController: YHBaseViewController {
self
.
bottomInputView
.
showKeyBoard
(
false
)
self
.
bottomInputView
.
showKeyBoard
(
false
)
}
}
func
s
crollToBottom
()
{
func
reloadAndS
crollToBottom
()
{
self
.
tableView
.
reloadData
()
if
!
canTriggerProgrammaticScroll
()
{
if
!
canTriggerProgrammaticScroll
()
{
return
return
}
}
self
.
tableView
.
reloadData
{
if
self
.
messages
.
count
>
0
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
self
.
tableView
.
setContentOffset
(
.
zero
,
animated
:
true
)
self
.
tableView
.
setContentOffset
(
.
zero
,
animated
:
true
)
self
.
tableView
.
setContentOffset
(
CGPointMake
(
0
,
90000
),
animated
:
true
)
self
.
tableView
.
setContentOffset
(
CGPointMake
(
0
,
90000
),
animated
:
true
)
// 使用 performBatchUpdates 来确保所有布局更新完成后再滚动
// 使用 performBatchUpdates 来确保所有布局更新完成后再滚动
self
.
tableView
.
performBatchUpdates
(
nil
)
{
_
in
self
.
tableView
.
performBatchUpdates
(
nil
)
{
_
in
// 在布局更新完成后执行滚动
// 在布局更新完成后执行滚动
if
self
.
messages
.
count
>
0
{
let
lastIndexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
let
lastIndexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
self
.
tableView
.
scrollToRow
(
at
:
lastIndexPath
,
at
:
.
bottom
,
animated
:
true
)
self
.
tableView
.
scrollToRow
(
at
:
lastIndexPath
,
at
:
.
bottom
,
animated
:
true
)
}
}
...
@@ -139,7 +141,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -139,7 +141,7 @@ class YHAIMainChatViewController: YHBaseViewController {
let
question
=
YHAIChatMessage
.
createQuestionMessage
(
text
)
let
question
=
YHAIChatMessage
.
createQuestionMessage
(
text
)
self
.
messages
.
append
(
question
)
self
.
messages
.
append
(
question
)
self
.
messages
.
append
(
self
.
thinkingMessage
)
self
.
messages
.
append
(
self
.
thinkingMessage
)
self
.
s
crollToBottom
()
self
.
reloadAndS
crollToBottom
()
self
.
bottomInputView
.
status
=
.
loading
self
.
bottomInputView
.
status
=
.
loading
self
.
chatConfig
.
disableHandleMessage
=
false
self
.
chatConfig
.
disableHandleMessage
=
false
self
.
manager
.
requestAI
(
botId
:
self
.
robotId
,
conversationId
:
self
.
conversationId
,
question
:
text
)
{
self
.
manager
.
requestAI
(
botId
:
self
.
robotId
,
conversationId
:
self
.
conversationId
,
question
:
text
)
{
...
@@ -150,7 +152,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -150,7 +152,7 @@ class YHAIMainChatViewController: YHBaseViewController {
print
(
"RESPONSE-DONE"
)
print
(
"RESPONSE-DONE"
)
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
}
}
self
.
s
crollToBottom
()
self
.
reloadAndS
crollToBottom
()
}
}
}
}
}
}
...
@@ -178,9 +180,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -178,9 +180,7 @@ class YHAIMainChatViewController: YHBaseViewController {
return
!
uuids
.
contains
(
$0
.
messageId
)
return
!
uuids
.
contains
(
$0
.
messageId
)
}
}
messages
.
insert
(
contentsOf
:
results
,
at
:
0
)
messages
.
insert
(
contentsOf
:
results
,
at
:
0
)
self
.
tableView
.
reloadData
{
self
.
reloadAndScrollToBottom
()
self
.
scrollToBottom
()
}
}
}
}
}
...
@@ -190,9 +190,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -190,9 +190,7 @@ class YHAIMainChatViewController: YHBaseViewController {
let
previewUrl
=
"https://prod-cdn-pub.galaxy-immi.com/5000000/chats/mask_group.jpg"
let
previewUrl
=
"https://prod-cdn-pub.galaxy-immi.com/5000000/chats/mask_group.jpg"
let
msg
=
self
.
chatConfig
.
createRobotResponseLocalPictureMessage
(
"ai_auto_chat_img"
,
previewUrl
:
previewUrl
)
let
msg
=
self
.
chatConfig
.
createRobotResponseLocalPictureMessage
(
"ai_auto_chat_img"
,
previewUrl
:
previewUrl
)
messages
.
append
(
msg
)
messages
.
append
(
msg
)
self
.
tableView
.
reloadData
{
self
.
reloadAndScrollToBottom
()
self
.
scrollToBottom
()
}
}
}
}
}
...
@@ -201,7 +199,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -201,7 +199,7 @@ class YHAIMainChatViewController: YHBaseViewController {
self
.
manager
.
stopChat
(
chatId
:
self
.
manager
.
chatId
,
conversationId
:
self
.
conversationId
)
{
success
,
error
in
self
.
manager
.
stopChat
(
chatId
:
self
.
manager
.
chatId
,
conversationId
:
self
.
conversationId
)
{
success
,
error
in
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
if
success
{
if
success
{
self
.
s
crollToBottom
()
self
.
reloadAndS
crollToBottom
()
self
.
manager
.
request
?
.
cancel
()
self
.
manager
.
request
?
.
cancel
()
self
.
chatConfig
.
disableHandleMessage
=
true
self
.
chatConfig
.
disableHandleMessage
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
...
@@ -320,9 +318,7 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -320,9 +318,7 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
if
arr
.
count
>
0
{
if
arr
.
count
>
0
{
messages
.
append
(
contentsOf
:
arr
)
messages
.
append
(
contentsOf
:
arr
)
self
.
tableView
.
reloadData
{
self
.
reloadAndScrollToBottom
()
self
.
scrollToBottom
()
}
}
}
}
}
cell
.
updateBlock
=
{
cell
.
updateBlock
=
{
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
View file @
47a4f7b9
...
@@ -186,23 +186,25 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -186,23 +186,25 @@ class YHAIRobotChatViewController: YHBaseViewController {
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
}
func
s
crollToBottom
()
{
func
reloadAndS
crollToBottom
()
{
self
.
tableView
.
reloadData
()
if
!
canTriggerProgrammaticScroll
()
{
if
!
canTriggerProgrammaticScroll
()
{
return
return
}
}
self
.
tableView
.
reloadData
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
self
.
tableView
.
setContentOffset
(
.
zero
,
animated
:
true
)
self
.
tableView
.
setContentOffset
(
.
zero
,
animated
:
true
)
self
.
tableView
.
setContentOffset
(
CGPointMake
(
0
,
90000
),
animated
:
true
)
self
.
tableView
.
setContentOffset
(
CGPointMake
(
0
,
90000
),
animated
:
true
)
// 使用 performBatchUpdates 来确保所有布局更新完成后再滚动
// 使用 performBatchUpdates 来确保所有布局更新完成后再滚动
self
.
tableView
.
performBatchUpdates
(
nil
)
{
_
in
self
.
tableView
.
performBatchUpdates
(
nil
)
{
_
in
// 在布局更新完成后执行滚动
// 在布局更新完成后执行滚动
if
self
.
messages
.
count
>
0
{
if
self
.
messages
.
count
>
0
{
let
lastIndexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
let
lastIndexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
self
.
tableView
.
scrollToRow
(
at
:
lastIndexPath
,
at
:
.
bottom
,
animated
:
true
)
self
.
tableView
.
scrollToRow
(
at
:
lastIndexPath
,
at
:
.
bottom
,
animated
:
true
)
}
}
}
}
}
}
}
}
...
@@ -214,7 +216,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -214,7 +216,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
messages
.
append
(
thinkingMessage
)
messages
.
append
(
thinkingMessage
)
self
.
bottomInputView
.
status
=
.
loading
self
.
bottomInputView
.
status
=
.
loading
self
.
chatConfig
.
disableHandleMessage
=
false
self
.
chatConfig
.
disableHandleMessage
=
false
self
.
s
crollToBottom
()
self
.
reloadAndS
crollToBottom
()
self
.
manager
.
requestAI
(
botId
:
self
.
robotId
,
conversationId
:
self
.
conversationId
,
question
:
text
)
{
self
.
manager
.
requestAI
(
botId
:
self
.
robotId
,
conversationId
:
self
.
conversationId
,
question
:
text
)
{
[
weak
self
]
res
,
done
in
[
weak
self
]
res
,
done
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
...
@@ -223,7 +225,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -223,7 +225,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
print
(
"RESPONSE-DONE"
)
print
(
"RESPONSE-DONE"
)
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
}
}
self
.
s
crollToBottom
()
self
.
reloadAndS
crollToBottom
()
}
}
}
}
...
@@ -262,9 +264,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -262,9 +264,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
}
}
}
self
.
tableView
.
reloadData
{
self
.
reloadAndScrollToBottom
()
self
.
scrollToBottom
()
}
}
}
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
...
@@ -279,7 +279,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -279,7 +279,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
self
.
manager
.
stopChat
(
chatId
:
self
.
manager
.
chatId
,
conversationId
:
self
.
conversationId
)
{
success
,
error
in
self
.
manager
.
stopChat
(
chatId
:
self
.
manager
.
chatId
,
conversationId
:
self
.
conversationId
)
{
success
,
error
in
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
self
.
bottomInputView
.
status
=
self
.
bottomInputView
.
textView
.
text
.
isEmpty
?
.
disableSend
:
.
enableSend
if
success
{
if
success
{
self
.
s
crollToBottom
()
self
.
reloadAndS
crollToBottom
()
self
.
manager
.
request
?
.
cancel
()
self
.
manager
.
request
?
.
cancel
()
self
.
chatConfig
.
disableHandleMessage
=
true
self
.
chatConfig
.
disableHandleMessage
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
...
@@ -452,9 +452,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -452,9 +452,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
if
arr
.
count
>
0
{
if
arr
.
count
>
0
{
messages
.
append
(
contentsOf
:
arr
)
messages
.
append
(
contentsOf
:
arr
)
self
.
tableView
.
reloadData
{
self
.
reloadAndScrollToBottom
()
self
.
scrollToBottom
()
}
}
}
}
}
cell
.
updateBlock
=
{
cell
.
updateBlock
=
{
...
...
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