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
dedb5827
Commit
dedb5827
authored
Dec 03, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
4ffced05
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
17 deletions
+80
-17
YHAIMainChatViewController.swift
...s/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
+13
-0
YHAIRobotChatViewController.swift
.../AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
+13
-0
YHAIViewModel.swift
...lasses/Modules/AI/AI-Dialogue(AI对话)/M/YHAIViewModel.swift
+39
-0
YHAIPictureMessageCell.swift
...dules/AI/AI-Dialogue(AI对话)/V/YHAIPictureMessageCell.swift
+14
-17
YHAllApiName.swift
galaxy/galaxy/Classes/Tools/NetWork/YHAllApiName.swift
+1
-0
No files found.
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
View file @
dedb5827
...
@@ -159,6 +159,14 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -159,6 +159,14 @@ class YHAIMainChatViewController: YHBaseViewController {
self
.
tableView
.
reloadData
()
self
.
tableView
.
reloadData
()
}
}
}
}
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
viewModel
.
createMessage
(
conversationId
:
conversationId
,
role
:
"assistant"
,
msg
:
msg
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
callback
?(
success
)
}
}
}
}
extension
YHAIMainChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHAIMainChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
...
@@ -213,21 +221,26 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -213,21 +221,26 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
[
weak
self
]
dict
in
[
weak
self
]
dict
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
// 生成测评结果文字 和测评结果图片 两种消息
var
arr
=
[
YHAIChatMessage
]()
var
arr
=
[
YHAIChatMessage
]()
if
let
satisfy_count
=
dict
[
"meet_number"
]
as?
Int
{
if
let
satisfy_count
=
dict
[
"meet_number"
]
as?
Int
{
let
text
=
"测评成功!优才新政策要求满足12项评核准则中的任意6项即可申请(即12分制满足6分),您当前满足
\(
satisfy_count
)
项,联系专属顾问咨询详细方案!"
let
text
=
"测评成功!优才新政策要求满足12项评核准则中的任意6项即可申请(即12分制满足6分),您当前满足
\(
satisfy_count
)
项,联系专属顾问咨询详细方案!"
let
textMsg
=
YHAIChatMessage
.
createTextMesssage
(
text
:
text
)
let
textMsg
=
YHAIChatMessage
.
createTextMesssage
(
text
:
text
)
arr
.
append
(
textMsg
)
arr
.
append
(
textMsg
)
self
.
uploadEvaluationMessage
(
textMsg
)
}
}
if
let
img1
=
dict
[
"consultant_qr_code_with_text"
]
as?
String
{
if
let
img1
=
dict
[
"consultant_qr_code_with_text"
]
as?
String
{
let
picMsg
=
YHAIChatMessage
.
createPictureMessage
(
url
:
img1
,
imgType
:
1
)
let
picMsg
=
YHAIChatMessage
.
createPictureMessage
(
url
:
img1
,
imgType
:
1
)
arr
.
append
(
picMsg
)
arr
.
append
(
picMsg
)
self
.
uploadEvaluationMessage
(
picMsg
)
}
}
if
arr
.
count
>
0
{
if
arr
.
count
>
0
{
messages
.
append
(
contentsOf
:
arr
)
messages
.
append
(
contentsOf
:
arr
)
tableView
.
reloadData
()
tableView
.
reloadData
()
}
}
}
}
}
}
return
cell
return
cell
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
View file @
dedb5827
...
@@ -157,6 +157,14 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -157,6 +157,14 @@ class YHAIRobotChatViewController: YHBaseViewController {
self
.
tableView
.
reloadData
()
self
.
tableView
.
reloadData
()
}
}
}
}
func
uploadEvaluationMessage
(
_
msg
:
YHAIChatMessage
,
callback
:((
Bool
)
->
())?
=
nil
)
{
viewModel
.
createMessage
(
conversationId
:
conversationId
,
role
:
"assistant"
,
msg
:
msg
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
callback
?(
success
)
}
}
}
}
extension
YHAIRobotChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHAIRobotChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
...
@@ -211,21 +219,26 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -211,21 +219,26 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
[
weak
self
]
dict
in
[
weak
self
]
dict
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
// 生成测评结果文字 和测评结果图片 两种消息
var
arr
=
[
YHAIChatMessage
]()
var
arr
=
[
YHAIChatMessage
]()
if
let
satisfy_count
=
dict
[
"meet_number"
]
as?
Int
{
if
let
satisfy_count
=
dict
[
"meet_number"
]
as?
Int
{
let
text
=
"测评成功!优才新政策要求满足12项评核准则中的任意6项即可申请(即12分制满足6分),您当前满足
\(
satisfy_count
)
项,联系专属顾问咨询详细方案!"
let
text
=
"测评成功!优才新政策要求满足12项评核准则中的任意6项即可申请(即12分制满足6分),您当前满足
\(
satisfy_count
)
项,联系专属顾问咨询详细方案!"
let
textMsg
=
YHAIChatMessage
.
createTextMesssage
(
text
:
text
)
let
textMsg
=
YHAIChatMessage
.
createTextMesssage
(
text
:
text
)
arr
.
append
(
textMsg
)
arr
.
append
(
textMsg
)
self
.
uploadEvaluationMessage
(
textMsg
)
}
}
if
let
img1
=
dict
[
"consultant_qr_code_with_text"
]
as?
String
{
if
let
img1
=
dict
[
"consultant_qr_code_with_text"
]
as?
String
{
let
picMsg
=
YHAIChatMessage
.
createPictureMessage
(
url
:
img1
,
imgType
:
1
)
let
picMsg
=
YHAIChatMessage
.
createPictureMessage
(
url
:
img1
,
imgType
:
1
)
arr
.
append
(
picMsg
)
arr
.
append
(
picMsg
)
self
.
uploadEvaluationMessage
(
picMsg
)
}
}
if
arr
.
count
>
0
{
if
arr
.
count
>
0
{
messages
.
append
(
contentsOf
:
arr
)
messages
.
append
(
contentsOf
:
arr
)
tableView
.
reloadData
()
tableView
.
reloadData
()
}
}
}
}
}
}
return
cell
return
cell
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/M/YHAIViewModel.swift
View file @
dedb5827
...
@@ -108,5 +108,44 @@ class YHAIViewModel: NSObject {
...
@@ -108,5 +108,44 @@ class YHAIViewModel: NSObject {
callBackBlock
(
false
,
err
)
callBackBlock
(
false
,
err
)
}
}
}
}
func
createMessage
(
conversationId
:
String
,
role
:
String
,
msg
:
YHAIChatMessage
,
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
guard
let
msgDict
=
msg
.
body
.
toDictionary
()
else
{
return
}
let
content
=
self
.
dicToJSONString
(
dict
:
msgDict
)
let
params
:[
String
:
Any
]
=
[
"conversationId"
:
conversationId
,
"contentType"
:
"
\(
msg
.
body
.
contentType
)
"
,
"role"
:
role
,
"content"
:
content
]
printLog
(
"CREATE_MSG:
\n
\(
params
)
"
)
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
AIChat
.
createMessage
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
self
=
self
else
{
return
}
printLog
(
"model 是 ==>
\(
json
)
"
)
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
err
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
.
isEmpty
?
""
:
json
.
msg
)
callBackBlock
(
false
,
err
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
dicToJSONString
(
dict
:
[
String
:
Any
])
->
String
{
if
let
jsonData
=
try
?
JSONSerialization
.
data
(
withJSONObject
:
dict
,
options
:
.
prettyPrinted
)
{
return
String
(
data
:
jsonData
,
encoding
:
.
utf8
)
??
""
}
return
""
}
}
}
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/V/YHAIPictureMessageCell.swift
View file @
dedb5827
...
@@ -31,25 +31,21 @@ class YHAIPictureMessageCell: UITableViewCell {
...
@@ -31,25 +31,21 @@ class YHAIPictureMessageCell: UITableViewCell {
var
imgW
=
220.0
var
imgW
=
220.0
var
imgH
=
220.0
var
imgH
=
220.0
var
imgScale
=
1.0
var
ratio
=
1.0
if
image
.
size
.
width
>
0
,
image
.
size
.
height
>
0
{
if
image
.
size
.
width
>
0
,
image
.
size
.
height
>
0
{
if
UIScreen
.
main
.
scale
>
0
{
ratio
=
image
.
size
.
width
/
image
.
size
.
height
imgScale
=
UIScreen
.
main
.
scale
}
imgW
=
image
.
size
.
width
/
imgScale
imgH
=
image
.
size
.
height
/
imgScale
printLog
(
"AI_MSG_PICTURE_REAL_SIZE: (
\(
imgW
)
,
\(
imgH
)
,
\(
imgScale
)
"
)
let
ratio
=
imgW
/
imgH
if
imgH
>
476
{
imgH
=
476
imgW
=
imgH
*
ratio
}
else
{
imgW
=
220
imgH
=
imgW
/
ratio
}
}
}
imgH
=
imgW
/
ratio
// if imgH > 476 {
// imgH = 476
// imgW = imgH*ratio
//
// } else {
// imgW = 220
// imgH = imgW/ratio
// }
return
CGSizeMake
(
imgW
,
imgH
)
return
CGSizeMake
(
imgW
,
imgH
)
}
}
...
@@ -122,6 +118,7 @@ class YHAIPictureMessageCell: UITableViewCell {
...
@@ -122,6 +118,7 @@ class YHAIPictureMessageCell: UITableViewCell {
@objc
func
didMessageClicked
()
{
@objc
func
didMessageClicked
()
{
self
.
endEditing
(
true
)
self
.
endEditing
(
true
)
YHPictureReviewManager
.
shared
.
showNetWorkPicturs
(
curIndex
:
0
,
arrPicturs
:
[
imgInfo
.
imageUrl
])
}
}
}
}
galaxy/galaxy/Classes/Tools/NetWork/YHAllApiName.swift
View file @
dedb5827
...
@@ -666,6 +666,7 @@ class YHAllApiName {
...
@@ -666,6 +666,7 @@ class YHAllApiName {
static
let
getAIChatSessionId
=
"super-app/ai/agent/conversation"
static
let
getAIChatSessionId
=
"super-app/ai/agent/conversation"
static
let
cancelAIChat
=
"super-app/ai/agent/chat-cancel"
static
let
cancelAIChat
=
"super-app/ai/agent/chat-cancel"
static
let
chatHistory
=
"super-app/ai/agent/chat-details"
static
let
chatHistory
=
"super-app/ai/agent/chat-details"
static
let
createMessage
=
"super-app/ai/agent/chat-create-message"
}
}
}
}
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