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
155a35b4
Commit
155a35b4
authored
Dec 06, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
df5e593a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
132 additions
and
20 deletions
+132
-20
YHAIChatConfiguration.swift
...odules/AI/AI-Dialogue(AI对话)/C/YHAIChatConfiguration.swift
+31
-0
YHAIMainChatViewController.swift
...s/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
+15
-4
YHAIRobotChatViewController.swift
.../AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
+13
-3
YHAIServiceListViewController.swift
...I/AI-Dialogue(AI对话)/C/YHAIServiceListViewController.swift
+6
-2
YHAITabViewController.swift
...odules/AI/AI-Dialogue(AI对话)/C/YHAITabViewController.swift
+12
-2
YHAIMessageModel.swift
...ses/Modules/AI/AI-Dialogue(AI对话)/M/YHAIMessageModel.swift
+7
-1
YHAIPictureMessageCell.swift
...dules/AI/AI-Dialogue(AI对话)/V/YHAIPictureMessageCell.swift
+25
-7
YHCardMessageCell.swift
...es/Modules/AI/AI-Dialogue(AI对话)/V/YHCardMessageCell.swift
+1
-1
Contents.json
....xcassets/AI-Chat/ai_auto_chat_img.imageset/Contents.json
+22
-0
Mask group@2x.png
...ssets/AI-Chat/ai_auto_chat_img.imageset/Mask group@2x.png
+0
-0
Mask group@3x.png
...ssets/AI-Chat/ai_auto_chat_img.imageset/Mask group@3x.png
+0
-0
No files found.
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIChatConfiguration.swift
View file @
155a35b4
...
...
@@ -79,4 +79,35 @@ class YHAIChatConfiguration {
messages
.
remove
(
at
:
findIndex
)
}
}
func
createRobotResponseTextMessage
(
_
text
:
String
)
->
YHAIChatMessage
{
let
message
=
YHAIChatMessage
()
message
.
messageId
=
UUID
()
.
uuidString
+
NSDate
()
.
timeIntervalSince1970
.
description
message
.
isSelf
=
false
let
body
=
YHAIMessageBody
()
body
.
contentType
=
YHAIMessageType
.
text
.
rawValue
body
.
contentText
=
text
message
.
setDone
()
message
.
body
=
body
message
.
updateBodyToData
()
return
message
}
func
createRobotResponseLocalPictureMessage
(
_
imgName
:
String
)
->
YHAIChatMessage
{
let
message
=
YHAIChatMessage
()
message
.
messageId
=
UUID
()
.
uuidString
+
NSDate
()
.
timeIntervalSince1970
.
description
message
.
isSelf
=
false
let
body
=
YHAIMessageBody
()
body
.
contentType
=
YHAIMessageType
.
picture
.
rawValue
let
imgInfo
=
YHAIImageInfo
()
imgInfo
.
imageType
=
YHAIImageType
.
local
.
rawValue
imgInfo
.
localImageName
=
imgName
body
.
imageInfo
=
imgInfo
message
.
setDone
()
message
.
body
=
body
message
.
updateBodyToData
()
return
message
}
}
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
View file @
155a35b4
...
...
@@ -15,8 +15,7 @@ class YHAIMainChatViewController: YHBaseViewController {
var
robotId
:
String
=
""
var
conversationId
:
String
=
""
var
historyLastMessageId
:
String
=
""
var
isNeedAutoResponseImage
=
false
var
messages
:[
YHAIChatMessage
]
=
[]
let
manager
=
YHAIRequestManager
()
...
...
@@ -111,6 +110,11 @@ class YHAIMainChatViewController: YHBaseViewController {
}
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
autoResponseLocalPictureMessage
()
}
func
scrollToBottom
()
{
self
.
tableView
.
reloadData
{
if
self
.
messages
.
count
>
0
{
...
...
@@ -149,11 +153,10 @@ class YHAIMainChatViewController: YHBaseViewController {
if
!
isPull
{
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
}
viewModel
.
getHistoryChatMessages
(
botId
:
robotId
,
conversationId
:
conversationId
,
messageId
:
historyLastMessageId
)
{
viewModel
.
getHistoryChatMessages
(
botId
:
robotId
,
conversationId
:
conversationId
,
messageId
:
""
)
{
[
weak
self
]
success
,
error
in
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
self
.
historyLastMessageId
=
self
.
viewModel
.
lastHistroyMsgId
self
.
tableView
.
es
.
stopPullToRefresh
()
var
results
=
self
.
viewModel
.
historyMessages
.
map
{
...
...
@@ -172,6 +175,14 @@ class YHAIMainChatViewController: YHBaseViewController {
}
}
func
autoResponseLocalPictureMessage
()
{
if
isNeedAutoResponseImage
{
let
msg
=
self
.
chatConfig
.
createRobotResponseLocalPictureMessage
(
"ai_auto_chat_img"
)
messages
.
append
(
msg
)
self
.
tableView
.
reloadData
()
}
}
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
viewModel
.
createMessage
(
conversationId
:
conversationId
,
role
:
"assistant"
,
msg
:
msg
)
{
[
weak
self
]
success
,
error
in
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
View file @
155a35b4
...
...
@@ -17,7 +17,6 @@ class YHAIRobotChatViewController: YHBaseViewController {
var
listItemId
:
Int
=
0
var
conversationId
:
String
=
""
var
messages
:[
YHAIChatMessage
]
=
[]
var
historyLastMessageId
:
String
=
""
var
isNeedShowBannerHeader
:
Bool
=
false
var
robotType
:
String
=
""
let
manager
=
YHAIRequestManager
()
...
...
@@ -169,11 +168,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
printLog
(
"PULL MESSAGE HISTORY"
)
}
viewModel
.
getHistoryChatMessages
(
botId
:
robotId
,
conversationId
:
conversationId
,
messageId
:
historyLastMessageId
)
{
viewModel
.
getHistoryChatMessages
(
botId
:
robotId
,
conversationId
:
conversationId
,
messageId
:
""
)
{
[
weak
self
]
success
,
error
in
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
self
.
historyLastMessageId
=
self
.
viewModel
.
lastHistroyMsgId
self
.
tableView
.
es
.
stopPullToRefresh
()
var
results
=
self
.
viewModel
.
historyMessages
.
map
{
...
...
@@ -189,9 +187,21 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
messages
.
insert
(
contentsOf
:
results
,
at
:
0
)
self
.
tableView
.
reloadData
()
autoResponseLocalTextMessage
()
}
}
func
autoResponseLocalTextMessage
()
{
if
messages
.
count
<=
0
{
if
robotType
==
YHAIRobotType
.
sale
.
rawValue
{
let
text
=
"银河集团能够为您提供全方位、一站式的香港身份规划及本地生活服务。
\n
在身份规划方面,我们专注于香港优才、专才、留学等身份产品服务,根据您的个人情况和需求,量身定制最合适的身份规划方案,助您轻松获取香港身份,享受香港的各项福利和优势。
\n
同时,我们还提供丰富的香港本地生活服务,包括教育咨询、商务支持、个人账户开设、港宝(即香港宝宝)相关服务、保险规划以及房产购置等。我们的专业团队对香港市场有着深入的了解,能够为您提供精准、高效的服务,让您在香港的生活更加便捷、舒适。
\n
银河集团凭借多年的行业经验和丰富的成功案例,以及专业、敬业的团队,致力于为客户提供最优质、最贴心的服务。选择银河集团,您将享受到专业、高效、便捷的服务体验,让我们携手共创美好未来。"
let
msg
=
self
.
chatConfig
.
createRobotResponseTextMessage
(
text
)
messages
.
append
(
msg
)
self
.
tableView
.
reloadData
()
}
}
}
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
viewModel
.
createMessage
(
conversationId
:
conversationId
,
role
:
"assistant"
,
msg
:
msg
)
{
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIServiceListViewController.swift
View file @
155a35b4
...
...
@@ -10,6 +10,8 @@ import UIKit
import
JXSegmentedView
import
IQKeyboardManagerSwift
let
isNeedShowAutoPictureMsg
=
"isNeedShowAutoPictureMsg"
class
YHAIServiceListViewController
:
YHBaseViewController
{
var
serviceArr
:
[
YHEntranceconfigModel
]
=
[]
...
...
@@ -79,7 +81,8 @@ class YHAIServiceListViewController: YHBaseViewController {
}()
@objc
func
didInputButtonClicked
()
{
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didSwitchToAIChatNotification
,
object
:
nil
)
let
dict
:[
String
:
Any
]
=
[
isNeedShowAutoPictureMsg
:
false
]
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didSwitchToAIChatNotification
,
object
:
dict
)
}
override
func
viewDidLoad
()
{
...
...
@@ -173,7 +176,8 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
if
model
.
businessType
==
YHAIRobotType
.
main
.
rawValue
{
// 切到主Robot
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didSwitchToAIChatNotification
,
object
:
nil
)
let
dict
:[
String
:
Any
]
=
[
isNeedShowAutoPictureMsg
:
true
]
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didSwitchToAIChatNotification
,
object
:
dict
)
}
else
{
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAITabViewController.swift
View file @
155a35b4
...
...
@@ -112,7 +112,7 @@ class YHAITabViewController: YHBaseViewController {
IQKeyboardManager
.
shared
.
isEnabled
=
false
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didJumoToAIChat
)
,
name
:
YhConstant
.
YhNotification
.
didSwitchToAIChatNotification
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didJumoToAIChat
(_:)
)
,
name
:
YhConstant
.
YhNotification
.
didSwitchToAIChatNotification
,
object
:
nil
)
view
.
addSubview
(
bgImgView
)
view
.
addSubview
(
headerImgView
)
...
...
@@ -202,9 +202,19 @@ class YHAITabViewController: YHBaseViewController {
self
.
segmentedView
.
selectItemAt
(
index
:
itemIndex
)
}
@objc
func
didJumoToAIChat
()
{
@objc
func
didJumoToAIChat
(
_
notify
:
Notification
)
{
var
showImg
=
false
if
let
dict
=
notify
.
object
as?
[
String
:
Any
]
{
if
let
isShowImg
=
dict
[
isNeedShowAutoPictureMsg
]
as?
Bool
{
showImg
=
isShowImg
}
}
printLog
(
"SHOW_IMG:
\(
showImg
)
"
)
mainChatVC
.
isNeedAutoResponseImage
=
showImg
jumpToItemIndex
(
itemIndex
:
1
)
mainChatVC
.
bottomInputView
.
showKeyBoard
()
}
@objc
func
didCleanButtonClicked
()
{
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/M/YHAIMessageModel.swift
View file @
155a35b4
...
...
@@ -285,11 +285,17 @@ class YHProductTag: SmartCodable {
}
}
enum
YHAIImageType
:
Int
{
case
url
=
1
case
local
=
2
}
class
YHAIImageInfo
:
SmartCodable
{
var
imageType
:
Int
=
0
var
imageType
:
Int
=
0
// 0 url图片 1本地图片
var
imageUrl
:
String
=
""
var
imageDownloadUrl
:
String
=
""
var
localImageName
:
String
=
""
required
init
()
{
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/V/YHAIPictureMessageCell.swift
View file @
155a35b4
...
...
@@ -15,15 +15,33 @@ class YHAIPictureMessageCell: UITableViewCell {
var
imgInfo
=
YHAIImageInfo
()
{
didSet
{
imgView
.
sd_setImage
(
with
:
URL
(
string
:
imgInfo
.
imageUrl
),
placeholderImage
:
UIImage
(
named
:
"global_default_image"
),
options
:
[],
completed
:
{
(
image
,
error
,
cacheType
,
url
)
in
if
imgInfo
.
imageType
==
YHAIImageType
.
url
.
rawValue
{
imgView
.
sd_setImage
(
with
:
URL
(
string
:
imgInfo
.
imageUrl
),
placeholderImage
:
UIImage
(
named
:
"global_default_image"
),
options
:
[],
completed
:
{
(
image
,
error
,
cacheType
,
url
)
in
let
size
=
self
.
getShowSize
(
image
:
image
!
)
self
.
imgView
.
snp
.
updateConstraints
{
make
in
make
.
width
.
equalTo
(
size
.
width
)
make
.
height
.
equalTo
(
size
.
height
)
}
})
let
size
=
self
.
getShowSize
(
image
:
image
!
)
self
.
imgView
.
snp
.
updateConstraints
{
make
in
make
.
width
.
equalTo
(
size
.
width
)
make
.
height
.
equalTo
(
size
.
height
)
}
else
if
imgInfo
.
imageType
==
YHAIImageType
.
local
.
rawValue
{
if
let
img
=
UIImage
(
named
:
imgInfo
.
localImageName
)
{
imgView
.
image
=
img
self
.
imgView
.
snp
.
updateConstraints
{
make
in
make
.
width
.
equalTo
(
img
.
size
.
width
)
make
.
height
.
equalTo
(
img
.
size
.
height
)
}
}
else
{
imgView
.
image
=
UIImage
(
named
:
"global_default_image"
)
self
.
imgView
.
snp
.
updateConstraints
{
make
in
make
.
width
.
equalTo
(
200
)
make
.
height
.
equalTo
(
200
)
}
}
self
.
setNeedsLayout
()
})
}
self
.
setNeedsLayout
()
}
}
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/V/YHCardMessageCell.swift
View file @
155a35b4
...
...
@@ -72,7 +72,7 @@ class YHCardMessageCell: UITableViewCell {
iconImgView
.
sd_setImage
(
with
:
URL
(
string
:
cardListModel
.
icon
))
titleLabel
.
text
=
cardListModel
.
title
subtitleLabel
.
text
=
cardListModel
.
description
bottomBtn
.
setTitle
(
cardListModel
.
title
,
for
:
.
normal
)
bottomBtn
.
setTitle
(
cardListModel
.
btnText
,
for
:
.
normal
)
listView
.
removeSubviews
()
var
lastItemView
:
YHAICardItemView
?
=
nil
...
...
galaxy/galaxy/Res/Assets.xcassets/AI-Chat/ai_auto_chat_img.imageset/Contents.json
0 → 100644
View file @
155a35b4
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"Mask group@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"Mask group@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
galaxy/galaxy/Res/Assets.xcassets/AI-Chat/ai_auto_chat_img.imageset/Mask group@2x.png
0 → 100644
View file @
155a35b4
204 KB
galaxy/galaxy/Res/Assets.xcassets/AI-Chat/ai_auto_chat_img.imageset/Mask group@3x.png
0 → 100644
View file @
155a35b4
426 KB
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