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
6db9155b
Commit
6db9155b
authored
Nov 28, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
f00b1ab2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
13 deletions
+25
-13
YHAIChatViewController.swift
...dules/AI/AI-Dialogue(AI对话)/C/YHAIChatViewController.swift
+15
-10
YHAIMessageModel.swift
...ses/Modules/AI/AI-Dialogue(AI对话)/M/YHAIMessageModel.swift
+10
-3
No files found.
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIChatViewController.swift
View file @
6db9155b
...
@@ -83,6 +83,8 @@ class YHAIChatViewController: YHBaseViewController {
...
@@ -83,6 +83,8 @@ class YHAIChatViewController: YHBaseViewController {
func
handleMessage
(
_
res
:
YHAIMessage
?,
_
done
:
Bool
)
{
func
handleMessage
(
_
res
:
YHAIMessage
?,
_
done
:
Bool
)
{
removeThinkingMessage
()
if
let
res
=
res
{
if
let
res
=
res
{
var
find
=
false
var
find
=
false
for
msg
in
messages
{
for
msg
in
messages
{
...
@@ -99,21 +101,24 @@ class YHAIChatViewController: YHBaseViewController {
...
@@ -99,21 +101,24 @@ class YHAIChatViewController: YHBaseViewController {
}
}
}
else
{
}
else
{
if
done
{
// 思考完成
if
done
{
// 思考完成
var
findIndex
=
-
1
for
(
index
,
msg
)
in
messages
.
enumerated
()
{
if
msg
.
getType
()
==
.
thinking
{
findIndex
=
index
}
}
if
findIndex
!=
-
1
{
messages
.
remove
(
at
:
findIndex
)
}
self
.
tableView
.
reloadData
()
}
}
}
}
self
.
scrollToBottom
()
self
.
scrollToBottom
()
}
}
func
removeThinkingMessage
()
{
var
findIndex
=
-
1
for
(
index
,
msg
)
in
messages
.
enumerated
()
{
if
msg
.
getType
()
==
.
thinking
{
findIndex
=
index
}
}
if
findIndex
!=
-
1
{
messages
.
remove
(
at
:
findIndex
)
}
}
func
scrollToBottom
()
{
func
scrollToBottom
()
{
self
.
tableView
.
reloadData
{
self
.
tableView
.
reloadData
{
let
indexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
let
indexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/M/YHAIMessageModel.swift
View file @
6db9155b
...
@@ -53,6 +53,7 @@ class YHAIMessage: CustomStringConvertible {
...
@@ -53,6 +53,7 @@ class YHAIMessage: CustomStringConvertible {
body
.
contentText
=
text
body
.
contentText
=
text
question
.
setFinished
()
question
.
setFinished
()
question
.
body
=
body
question
.
body
=
body
question
.
updateBodyToData
()
return
question
return
question
}
}
...
@@ -63,15 +64,21 @@ class YHAIMessage: CustomStringConvertible {
...
@@ -63,15 +64,21 @@ class YHAIMessage: CustomStringConvertible {
body
.
contentType
=
YHAIMessageType
.
thinking
.
rawValue
body
.
contentType
=
YHAIMessageType
.
thinking
.
rawValue
message
.
setFinished
()
message
.
setFinished
()
message
.
body
=
body
message
.
body
=
body
message
.
updateBodyToData
()
return
message
return
message
}
}
func
updateBodyToData
()
{
data
[
"contentType"
]
=
body
.
contentType
data
[
"contentText"
]
=
body
.
contentText
}
// 获取消息类型
// 获取消息类型
func
getType
()
->
YHAIMessageType
{
func
getType
()
->
YHAIMessageType
{
if
self
.
body
.
contentType
==
YHAIMessageType
.
thinking
.
rawValue
{
return
.
thinking
}
if
let
type
=
data
[
"contentType"
]
as?
Int
{
if
let
type
=
data
[
"contentType"
]
as?
Int
{
if
type
==
YHAIMessageType
.
thinking
.
rawValue
{
return
.
thinking
}
if
type
==
YHAIMessageType
.
text
.
rawValue
{
if
type
==
YHAIMessageType
.
text
.
rawValue
{
return
.
text
return
.
text
}
}
...
...
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