@xuda.io/ai_module 1.1.5117 → 1.1.5118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +19 -21
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4686,25 +4686,6 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4686
4686
|
|
|
4687
4687
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4688
4688
|
|
|
4689
|
-
// let conversation_item_obj = {
|
|
4690
|
-
// _id: obj.id,
|
|
4691
|
-
// stat: 3,
|
|
4692
|
-
// docType: 'chat_conversation_item',
|
|
4693
|
-
// uid,
|
|
4694
|
-
// conversation_type: obj.conversation_type,
|
|
4695
|
-
// type: obj.conversation_type,
|
|
4696
|
-
// date_created_ts: obj.ts,
|
|
4697
|
-
// ts: obj.ts,
|
|
4698
|
-
// conversation_id,
|
|
4699
|
-
// output: output.output,
|
|
4700
|
-
// prompt,
|
|
4701
|
-
// response: output.state._currentStep.output,
|
|
4702
|
-
// reference_id: conversation_doc.reference_id,
|
|
4703
|
-
// direction: 'out',
|
|
4704
|
-
// role: 'user',
|
|
4705
|
-
// };
|
|
4706
|
-
// await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_item_obj);
|
|
4707
|
-
|
|
4708
4689
|
let in_conversation_item_obj = {
|
|
4709
4690
|
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
4710
4691
|
stat: 3,
|
|
@@ -4804,7 +4785,7 @@ setTimeout(async () => {
|
|
|
4804
4785
|
|
|
4805
4786
|
// await init_studio_units();
|
|
4806
4787
|
let ret;
|
|
4807
|
-
ret = await get_chat_suggestions(uid, []);
|
|
4788
|
+
ret = await get_chat_suggestions(uid, [], 'cov_7b65b783af38b91c8ec4c499d368e73e');
|
|
4808
4789
|
// ret = await get_active_account_profile_info(uid);
|
|
4809
4790
|
// ret = await is_spam_email(uid, 'dsgr8-2994400420@gigs.craigslist.org', 'To: You, From: Us - 70% Off Stickers & Labels Today Only');
|
|
4810
4791
|
// ret = await is_spam_email(uid, 'noreply@tm.openai.com', 'Please update your Plus payment method', account_profile_info);
|
|
@@ -10856,9 +10837,14 @@ export const open_ai_alive_check = async function () {};
|
|
|
10856
10837
|
|
|
10857
10838
|
export const get_chat_suggestions = async function (uid, ai_agents, conversation_item_id, ai_model = _conf.default_ai_model) {
|
|
10858
10839
|
let ret = [];
|
|
10859
|
-
const account_profile_info = await get_active_account_profile_info(uid);
|
|
10860
10840
|
|
|
10861
10841
|
try {
|
|
10842
|
+
const account_profile_info = await get_active_account_profile_info(uid);
|
|
10843
|
+
|
|
10844
|
+
const conversation_item_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_item_id);
|
|
10845
|
+
|
|
10846
|
+
let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_item_doc.conversation_id);
|
|
10847
|
+
|
|
10862
10848
|
const get_agents = async function () {
|
|
10863
10849
|
if (typeof ai_agents === 'undefined') {
|
|
10864
10850
|
// no agents
|
|
@@ -10902,6 +10888,18 @@ export const get_chat_suggestions = async function (uid, ai_agents, conversation
|
|
|
10902
10888
|
};
|
|
10903
10889
|
|
|
10904
10890
|
const agents_docs = await get_agents();
|
|
10891
|
+
|
|
10892
|
+
const mood_level = await submit_chat_gpt_prompt({
|
|
10893
|
+
uid,
|
|
10894
|
+
prompt: `analyze the mood of the following prompt: ${prompt}. return -2: very negative,-1: negative 0:natural 1:positive 2: very positive.`,
|
|
10895
|
+
model: _conf.default_ai_model,
|
|
10896
|
+
response_format: z.object({
|
|
10897
|
+
mood_level: z.number().describe('mood level of interaction: -2: very negative,-1: negative 0:natural 1:positive 2: very positive'),
|
|
10898
|
+
}),
|
|
10899
|
+
metadata: { conversation_id, func: 'update_conversation_mood_level' },
|
|
10900
|
+
account_profile_info,
|
|
10901
|
+
});
|
|
10902
|
+
|
|
10905
10903
|
debugger;
|
|
10906
10904
|
} catch (err) {
|
|
10907
10905
|
return { code: -44, data: err.message || String(err) };
|