Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6431eaf6
authored
Dec 24, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
1f105b96
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
11 deletions
utils/chat-info.ts
utils/chat-info.ts
View file @
6431eaf6
...
@@ -8,13 +8,30 @@ const chatInfo: ChatInfo = {};
...
@@ -8,13 +8,30 @@ const chatInfo: ChatInfo = {};
export
const
getChatModel
=
()
=>
chatInfo
;
export
const
getChatModel
=
()
=>
chatInfo
;
const
loadingKeys
=
new
Set
<
string
>
();
let
waitingAction
=
[];
export
interface
ChatModelInfoData
{
uniplatId
:
string
|
number
;
chat_id
:
number
;
uniplat_version
:
number
;
data
:
any
;
}
export
async
function
getChatModelInfo
(
export
async
function
getChatModelInfo
(
modelName
:
string
,
modelName
:
string
,
id
:
string
|
number
,
id
:
string
|
number
,
detailname
?:
string
,
detailname
?:
string
,
forceReload
=
false
forceReload
=
false
)
{
)
{
const
key
=
`
${
modelName
}
-
${
id
}
`
const
key
=
`
${
modelName
}
-
${
id
}
`
;
if
(
loadingKeys
.
has
(
key
))
{
return
new
Promise
<
ChatModelInfoData
>
((
resolve
)
=>
waitingAction
.
push
({
key
,
resolve
})
);
}
if
(
chatInfo
[
key
]
&&
!
forceReload
)
{
if
(
chatInfo
[
key
]
&&
!
forceReload
)
{
const
d
=
chatInfo
[
key
];
const
d
=
chatInfo
[
key
];
if
(
d
.
row
&&
d
.
row
.
UniplatChatId
)
{
if
(
d
.
row
&&
d
.
row
.
UniplatChatId
)
{
...
@@ -23,23 +40,52 @@ export async function getChatModelInfo(
...
@@ -23,23 +40,52 @@ export async function getChatModelInfo(
chat_id
:
+
d
.
row
.
UniplatImChatId
.
value
,
chat_id
:
+
d
.
row
.
UniplatImChatId
.
value
,
uniplat_version
:
0
,
uniplat_version
:
0
,
data
:
d
,
data
:
d
,
});
}
as
ChatModelInfoData
);
}
}
return
Promise
.
resolve
({
uniplatId
:
0
,
chat_id
:
0
,
uniplat_version
:
0
,
data
:
d
});
return
Promise
.
resolve
({
uniplatId
:
0
,
chat_id
:
0
,
uniplat_version
:
0
,
data
:
d
,
});
}
}
loadingKeys
.
add
(
key
);
const
info
=
await
Chat
.
getSdk
()
const
info
=
await
Chat
.
getSdk
()
.
model
(
modelName
)
.
model
(
modelName
)
.
detail
(
id
+
""
,
detailname
)
.
detail
(
id
+
""
,
detailname
)
.
query
();
.
query
();
const
data
=
info
;
const
data
=
info
;
chatInfo
[
key
]
=
data
;
chatInfo
[
key
]
=
data
;
if
(
info
.
row
&&
info
.
row
.
UniplatChatId
)
{
loadingKeys
.
delete
(
key
);
return
{
uniplatId
:
info
.
row
.
UniplatChatId
.
value
,
const
o
=
(
chat_id
:
Number
(
info
.
row
.
UniplatImChatId
.
value
),
info
.
row
&&
info
.
row
.
UniplatChatId
uniplat_version
:
0
,
?
{
data
,
uniplatId
:
info
.
row
.
UniplatChatId
.
value
,
};
chat_id
:
+
info
.
row
.
UniplatImChatId
.
value
,
uniplat_version
:
0
,
data
,
}
:
{
uniplatId
:
0
,
chat_id
:
0
,
uniplat_version
:
0
,
data
,
}
)
as
ChatModelInfoData
;
let
removing
=
[];
for
(
const
item
of
waitingAction
)
{
if
(
item
.
key
===
key
)
{
item
.
resolve
(
o
);
removing
.
push
(
item
.
key
);
}
}
}
return
{
uniplatId
:
0
,
chat_id
:
0
,
uniplat_version
:
0
,
data
,
};
for
(
const
item
of
removing
)
{
waitingAction
=
waitingAction
.
filter
((
i
)
=>
i
.
key
!==
item
);
}
return
o
;
}
}
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