@xuda.io/ai_module 1.1.4571 → 1.1.4572
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 +29 -12
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5160,26 +5160,43 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5160
5160
|
outputTokens += item.usage.outputTokens;
|
|
5161
5161
|
}
|
|
5162
5162
|
|
|
5163
|
-
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
5163
|
+
// await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
5164
|
+
|
|
5165
|
+
// let conversation_item_obj = {
|
|
5166
|
+
// _id: obj.id,
|
|
5167
|
+
// stat: 3,
|
|
5168
|
+
// docType: 'chat_conversation_item',
|
|
5169
|
+
// uid,
|
|
5170
|
+
// conversation_type: obj.conversation_type,
|
|
5171
|
+
// type: obj.conversation_type,
|
|
5172
|
+
// date_created_ts: obj.ts,
|
|
5173
|
+
// ts: obj.ts,
|
|
5174
|
+
// conversation_id,
|
|
5175
|
+
// output: output.output,
|
|
5176
|
+
// prompt,
|
|
5177
|
+
// response: output.state._currentStep.output,
|
|
5178
|
+
// reference_id: conversation_doc.reference_id,
|
|
5179
|
+
// direction: 'out',
|
|
5180
|
+
// role: 'user',
|
|
5181
|
+
// };
|
|
5182
|
+
// await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_item_obj);
|
|
5164
5183
|
|
|
5165
|
-
let
|
|
5166
|
-
_id:
|
|
5167
|
-
stat:
|
|
5184
|
+
let out_conversation_item_obj = {
|
|
5185
|
+
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
5186
|
+
stat: 1,
|
|
5168
5187
|
docType: 'chat_conversation_item',
|
|
5169
5188
|
uid,
|
|
5170
|
-
conversation_type:
|
|
5171
|
-
type:
|
|
5172
|
-
date_created_ts:
|
|
5173
|
-
ts:
|
|
5189
|
+
conversation_type: 'ai_chat',
|
|
5190
|
+
type: 'ai_chat',
|
|
5191
|
+
date_created_ts: Date.now(),
|
|
5192
|
+
ts: Date.now(),
|
|
5174
5193
|
conversation_id,
|
|
5175
|
-
|
|
5176
|
-
prompt,
|
|
5177
|
-
response: output.state._currentStep.output,
|
|
5194
|
+
text: prompt,
|
|
5178
5195
|
reference_id: conversation_doc.reference_id,
|
|
5179
5196
|
direction: 'out',
|
|
5180
5197
|
role: 'user',
|
|
5181
5198
|
};
|
|
5182
|
-
await db_module.save_app_couch_doc_native(account_profile_info.app_id,
|
|
5199
|
+
await db_module.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj);
|
|
5183
5200
|
|
|
5184
5201
|
account_module.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id }, account_profile_info);
|
|
5185
5202
|
// if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
|