@xuda.io/ai_module 1.1.4250 → 1.1.4251
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 +14 -3
- 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
|
|
5123
|
+
const obj = { id: output.state._lastTurnResponse.responseId, 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();
|
|
@@ -5134,9 +5134,20 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5134
5134
|
inputTokens += item.usage.inputTokens;
|
|
5135
5135
|
outputTokens += item.usage.outputTokens;
|
|
5136
5136
|
}
|
|
5137
|
-
|
|
5137
|
+
|
|
5138
5138
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
5139
|
-
|
|
5139
|
+
await db_module.save_app_couch_doc_native(account_profile_info.app_id, {
|
|
5140
|
+
_id: obj.id,
|
|
5141
|
+
stat: 3,
|
|
5142
|
+
docType: 'chat_conversation_item',
|
|
5143
|
+
uid,
|
|
5144
|
+
conversation_type: obj.conversation_type,
|
|
5145
|
+
date_created_ts: obj.ts,
|
|
5146
|
+
conversation_id,
|
|
5147
|
+
output: output.output,
|
|
5148
|
+
prompt,
|
|
5149
|
+
response: output.state._currentStep.output,
|
|
5150
|
+
});
|
|
5140
5151
|
|
|
5141
5152
|
record_chat_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id });
|
|
5142
5153
|
// if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
|