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
9206d6d4
Commit
9206d6d4
authored
Dec 09, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
7582e78c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
YHAIMainChatViewController.swift
...s/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
+8
-8
YHAIRobotChatViewController.swift
.../AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
+14
-14
No files found.
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
View file @
9206d6d4
...
@@ -20,7 +20,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -20,7 +20,7 @@ class YHAIMainChatViewController: YHBaseViewController {
var
isUserScrolling
:
Bool
=
false
var
isUserScrolling
:
Bool
=
false
var
lastUserScrollTime
:
CFTimeInterval
=
0.0
var
lastUserScrollTime
:
CFTimeInterval
=
0.0
let
minimumScrollInterval
:
CFTimeInterval
=
3
.0
let
minimumScrollInterval
:
CFTimeInterval
=
2
.0
let
manager
=
YHAIRequestManager
()
let
manager
=
YHAIRequestManager
()
let
viewModel
=
YHAIViewModel
()
let
viewModel
=
YHAIViewModel
()
...
@@ -111,10 +111,10 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -111,10 +111,10 @@ class YHAIMainChatViewController: YHBaseViewController {
self
.
bottomInputView
.
showKeyBoard
(
false
)
self
.
bottomInputView
.
showKeyBoard
(
false
)
}
}
func
reloadAndScrollToBottom
()
{
func
reloadAndScrollToBottom
(
_
forceScrollToBottom
:
Bool
=
false
)
{
self
.
tableView
.
reloadData
()
self
.
tableView
.
reloadData
()
if
!
canTriggerProgrammaticScroll
()
{
if
!
forceScrollToBottom
&&
!
canTriggerProgrammaticScroll
()
{
return
return
}
}
...
@@ -133,7 +133,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -133,7 +133,7 @@ class YHAIMainChatViewController: YHBaseViewController {
}
}
}
}
func
sendMessage
(
_
text
:
String
)
{
func
sendMessage
(
_
text
:
String
,
_
forceScrollToBottom
:
Bool
=
false
)
{
self
.
manager
.
getMainChatConversationId
{
self
.
manager
.
getMainChatConversationId
{
sesseionId
in
sesseionId
in
self
.
conversationId
=
sesseionId
self
.
conversationId
=
sesseionId
...
@@ -141,7 +141,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -141,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
.
reloadAndScrollToBottom
()
self
.
reloadAndScrollToBottom
(
forceScrollToBottom
)
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
)
{
...
@@ -152,7 +152,7 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -152,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
.
reloadAndScrollToBottom
()
self
.
reloadAndScrollToBottom
(
forceScrollToBottom
)
}
}
}
}
}
}
...
@@ -383,9 +383,9 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -383,9 +383,9 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
}
}
// 检查是否可以执行代码触发的滚动
// 检查是否可以执行代码触发的滚动
private
func
canTriggerProgrammaticScroll
()
->
Bool
{
func
canTriggerProgrammaticScroll
()
->
Bool
{
let
currentTime
=
CACurrentMediaTime
()
let
currentTime
=
CACurrentMediaTime
()
return
!
self
.
tableView
.
isDragging
&&
(
currentTime
-
lastUserScrollTime
)
>=
minimumScrollInterval
return
(
currentTime
-
lastUserScrollTime
)
>=
minimumScrollInterval
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
View file @
9206d6d4
...
@@ -95,11 +95,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -95,11 +95,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
if
self
.
isNeedStopResonse
()
{
if
self
.
isNeedStopResonse
()
{
self
.
stopAutoResponse
{
success
in
self
.
stopAutoResponse
{
success
in
if
success
{
if
success
{
self
.
sendMessage
(
text
)
self
.
sendMessage
(
text
,
true
)
}
}
}
}
}
else
{
}
else
{
self
.
sendMessage
(
text
)
self
.
sendMessage
(
text
,
true
)
}
}
}
}
view
.
selectBannerItemBlock
=
{
view
.
selectBannerItemBlock
=
{
...
@@ -116,11 +116,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -116,11 +116,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
if
self
.
isNeedStopResonse
()
{
if
self
.
isNeedStopResonse
()
{
self
.
stopAutoResponse
{
success
in
self
.
stopAutoResponse
{
success
in
if
success
{
if
success
{
self
.
sendMessage
(
text
)
self
.
sendMessage
(
text
,
true
)
}
}
}
}
}
else
{
}
else
{
self
.
sendMessage
(
text
)
self
.
sendMessage
(
text
,
true
)
}
}
}
}
return
view
return
view
...
@@ -186,10 +186,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -186,10 +186,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
}
func
reloadAndScrollToBottom
()
{
func
reloadAndScrollToBottom
(
_
forceScrollToBottom
:
Bool
=
false
)
{
self
.
tableView
.
reloadData
()
self
.
tableView
.
reloadData
()
if
!
canTriggerProgrammaticScroll
()
{
if
!
forceScrollToBottom
&&
!
canTriggerProgrammaticScroll
()
{
return
return
}
}
...
@@ -208,7 +208,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -208,7 +208,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
}
}
}
func
sendMessage
(
_
text
:
String
)
{
func
sendMessage
(
_
text
:
String
,
_
forceScrollToBottom
:
Bool
=
false
)
{
self
.
chatConfig
.
removeThinkingMessageFromChatList
(
&
messages
)
self
.
chatConfig
.
removeThinkingMessageFromChatList
(
&
messages
)
let
question
=
YHAIChatMessage
.
createQuestionMessage
(
text
)
let
question
=
YHAIChatMessage
.
createQuestionMessage
(
text
)
...
@@ -216,7 +216,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -216,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
.
reloadAndScrollToBottom
()
self
.
reloadAndScrollToBottom
(
forceScrollToBottom
)
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
}
...
@@ -225,7 +225,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -225,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
.
reloadAndScrollToBottom
()
self
.
reloadAndScrollToBottom
(
forceScrollToBottom
)
}
}
}
}
...
@@ -264,7 +264,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -264,7 +264,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
}
}
}
self
.
reloadAndScrollToBottom
()
self
.
reloadAndScrollToBottom
(
true
)
}
}
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
...
@@ -402,11 +402,11 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -402,11 +402,11 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
if
self
.
isNeedStopResonse
()
{
if
self
.
isNeedStopResonse
()
{
self
.
stopAutoResponse
{
success
in
self
.
stopAutoResponse
{
success
in
if
success
{
if
success
{
self
.
sendMessage
(
text
)
self
.
sendMessage
(
text
,
true
)
}
}
}
}
}
else
{
}
else
{
self
.
sendMessage
(
text
)
self
.
sendMessage
(
text
,
true
)
}
}
}
}
return
cell
return
cell
...
@@ -522,9 +522,9 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -522,9 +522,9 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
}
}
// 检查是否可以执行代码触发的滚动
// 检查是否可以执行代码触发的滚动
private
func
canTriggerProgrammaticScroll
()
->
Bool
{
func
canTriggerProgrammaticScroll
()
->
Bool
{
let
currentTime
=
CACurrentMediaTime
()
let
currentTime
=
CACurrentMediaTime
()
return
!
self
.
tableView
.
isDragging
&&
(
currentTime
-
lastUserScrollTime
)
>=
minimumScrollInterval
return
(
currentTime
-
lastUserScrollTime
)
>=
minimumScrollInterval
}
}
}
}
...
...
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