@xuda.io/ai_module 1.1.4245 → 1.1.4247
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 +4 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5120,7 +5120,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5120
5120
|
const output = await runner.run(_agent, prompt, opt);
|
|
5121
5121
|
const done = async function (output) {
|
|
5122
5122
|
try {
|
|
5123
|
-
const obj = { id: output?.output?.[0]?.id, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments };
|
|
5123
|
+
const obj = { id: output?.output?.[0]?.id, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments, conversation_type: 'ai_chat' };
|
|
5124
5124
|
conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
5125
5125
|
|
|
5126
5126
|
conversation_doc.ts = Date.now();
|
|
@@ -5136,6 +5136,8 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5136
5136
|
}
|
|
5137
5137
|
|
|
5138
5138
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
5139
|
+
await db_module.save_app_couch_doc_native(account_profile_info.app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, response: output.output });
|
|
5140
|
+
|
|
5139
5141
|
record_chat_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id });
|
|
5140
5142
|
// if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
|
|
5141
5143
|
// update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
|
|
@@ -6608,7 +6610,7 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
|
|
|
6608
6610
|
});
|
|
6609
6611
|
system_message_items.push({ id: items.last_id, ts: Date.now(), conversation_type: 'attachment', file });
|
|
6610
6612
|
|
|
6611
|
-
await db_module.save_app_couch_doc_native(uid, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, file });
|
|
6613
|
+
await db_module.save_app_couch_doc_native(uid, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, file, transcript });
|
|
6612
6614
|
}
|
|
6613
6615
|
|
|
6614
6616
|
// const items = await client.conversations.items.create(conversation_id, {
|