@xuda.io/ai_module 1.1.4570 → 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.
Files changed (2) hide show
  1. package/index.mjs +29 -13
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4531,7 +4531,6 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4531
4531
  await _utils.delay(1000);
4532
4532
  const conversation_id = conversation_doc._id;
4533
4533
 
4534
- const obj = { id: output.state._lastTurnResponse.responseId, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments, conversation_type: 'ai_chat' };
4535
4534
  let out_conversation_item_obj = {
4536
4535
  _id: await _common.xuda_get_uuid('chat_conversation_item'),
4537
4536
  stat: 1,
@@ -5161,26 +5160,43 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5161
5160
  outputTokens += item.usage.outputTokens;
5162
5161
  }
5163
5162
 
5164
- 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);
5165
5183
 
5166
- let conversation_item_obj = {
5167
- _id: obj.id,
5168
- stat: 3,
5184
+ let out_conversation_item_obj = {
5185
+ _id: await _common.xuda_get_uuid('chat_conversation_item'),
5186
+ stat: 1,
5169
5187
  docType: 'chat_conversation_item',
5170
5188
  uid,
5171
- conversation_type: obj.conversation_type,
5172
- type: obj.conversation_type,
5173
- date_created_ts: obj.ts,
5174
- ts: obj.ts,
5189
+ conversation_type: 'ai_chat',
5190
+ type: 'ai_chat',
5191
+ date_created_ts: Date.now(),
5192
+ ts: Date.now(),
5175
5193
  conversation_id,
5176
- output: output.output,
5177
- prompt,
5178
- response: output.state._currentStep.output,
5194
+ text: prompt,
5179
5195
  reference_id: conversation_doc.reference_id,
5180
5196
  direction: 'out',
5181
5197
  role: 'user',
5182
5198
  };
5183
- await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_item_obj);
5199
+ await db_module.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj);
5184
5200
 
5185
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);
5186
5202
  // if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4570",
3
+ "version": "1.1.4572",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",