@xuda.io/ai_module 1.1.4580 → 1.1.4581
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 +5 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5145,12 +5145,12 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5145
5145
|
const output = await runner.run(_agent, prompt, opt);
|
|
5146
5146
|
const done = async function (output) {
|
|
5147
5147
|
try {
|
|
5148
|
-
const obj = { id: output.state._lastTurnResponse.responseId, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments, conversation_type: 'ai_chat' };
|
|
5148
|
+
// const obj = { id: output.state._lastTurnResponse.responseId, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments, conversation_type: 'ai_chat' };
|
|
5149
5149
|
conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
5150
5150
|
|
|
5151
5151
|
conversation_doc.ts = Date.now();
|
|
5152
5152
|
conversation_doc.stat = 3;
|
|
5153
|
-
conversation_doc.messages.push(obj);
|
|
5153
|
+
// conversation_doc.messages.push(obj);
|
|
5154
5154
|
|
|
5155
5155
|
let inputTokens = output?.state?._context.usage?.inputTokens || 0;
|
|
5156
5156
|
let outputTokens = output?.state?._context?.usage?.outputTokens || 0;
|
|
@@ -5196,6 +5196,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5196
5196
|
conversation_item_reference_id: output.state._lastTurnResponse.responseId,
|
|
5197
5197
|
direction: 'in',
|
|
5198
5198
|
role: 'assistant',
|
|
5199
|
+
ai_agent_id: output.state._currentAgent.name,
|
|
5199
5200
|
};
|
|
5200
5201
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, in_conversation_item_obj);
|
|
5201
5202
|
|
|
@@ -5204,10 +5205,10 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5204
5205
|
|
|
5205
5206
|
let out_conversation_item_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_obj._id);
|
|
5206
5207
|
out_conversation_item_doc.stat = 3;
|
|
5207
|
-
conversation_item_reference_id = '?';
|
|
5208
|
+
out_conversation_item_doc.conversation_item_reference_id = '?';
|
|
5208
5209
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, out_conversation_item_doc);
|
|
5209
5210
|
|
|
5210
|
-
account_module.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id:
|
|
5211
|
+
account_module.record_ai_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: in_conversation_item_obj.ai_agent_id, item_id: in_conversation_item_obj._id }, account_profile_info);
|
|
5211
5212
|
// if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
|
|
5212
5213
|
// update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
|
|
5213
5214
|
// }
|