@xuda.io/ai_module 1.1.4571 → 1.1.4573

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 +31 -14
  2. 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 conversation_item_obj = {
5166
- _id: obj.id,
5184
+ let in_conversation_item_obj = {
5185
+ _id: await _common.xuda_get_uuid('chat_conversation_item'),
5167
5186
  stat: 3,
5168
5187
  docType: 'chat_conversation_item',
5169
5188
  uid,
5170
- conversation_type: obj.conversation_type,
5171
- type: obj.conversation_type,
5172
- date_created_ts: obj.ts,
5173
- ts: obj.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
- output: output.output,
5176
- prompt,
5177
- response: output.state._currentStep.output,
5178
- reference_id: conversation_doc.reference_id,
5179
- direction: 'out',
5180
- role: 'user',
5194
+ text: output.state._currentStep.output,
5195
+ reference_id: output.state._lastTurnResponse.responseId,
5196
+ direction: 'in',
5197
+ role: 'assistant',
5181
5198
  };
5182
- 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);
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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4571",
3
+ "version": "1.1.4573",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",