@xuda.io/ai_module 1.1.5210 → 1.1.5211

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 +18 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4715,6 +4715,22 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4715
4715
  // emitToDashboard('stream_delta', 'suggestions end');
4716
4716
  };
4717
4717
 
4718
+ const run_agent = function (_agent, prompt, opt) {
4719
+ return new Promise(async (resolve, reject) => {
4720
+ let interval = setInterval(async function () {
4721
+ const job_info = await jobs_ms.get_job_info({ job_id });
4722
+
4723
+ if (job_info.code < 0 || job_info.data.stat === 4) {
4724
+ reject('aborted');
4725
+ clearInterval(interval);
4726
+ }
4727
+ }, 1000);
4728
+ const ret = await runner.run(_agent, prompt, opt);
4729
+ clearInterval(interval);
4730
+ resolve(ret);
4731
+ });
4732
+ };
4733
+
4718
4734
  // try {
4719
4735
  const runner = new Runner();
4720
4736
  let _agent = [];
@@ -4781,7 +4797,8 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4781
4797
 
4782
4798
  await update_job('submitting chat');
4783
4799
  init_agent_hooks(_agent);
4784
- const output = await runner.run(_agent, prompt, opt);
4800
+ // const output = await runner.run(_agent, prompt, opt);
4801
+ const output = await run_agent(_agent, prompt, opt);
4785
4802
  const done = async function (output) {
4786
4803
  try {
4787
4804
  // const obj = { id: output.state._lastTurnResponse.responseId, ts: Date.now(), ai_agent_id: output.state._currentAgent.name, attachments, conversation_type: 'ai_chat' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5210",
3
+ "version": "1.1.5211",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",