weifuwu 0.23.1 → 0.23.2
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/dist/index.js +9 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2441,7 +2441,7 @@ function aiProvider(options) {
|
|
|
2441
2441
|
return result.embedding;
|
|
2442
2442
|
},
|
|
2443
2443
|
async embedMany(texts) {
|
|
2444
|
-
const result = await aiEmbedMany({ model: this.embeddingModel(),
|
|
2444
|
+
const result = await aiEmbedMany({ model: this.embeddingModel(), values: texts });
|
|
2445
2445
|
return result.embeddings;
|
|
2446
2446
|
},
|
|
2447
2447
|
generateText(params) {
|
|
@@ -3993,7 +3993,7 @@ function attachCron(q, handlers) {
|
|
|
3993
3993
|
function createMemoryQueue(opts) {
|
|
3994
3994
|
const pollInterval = opts?.pollInterval ?? 200;
|
|
3995
3995
|
const handlers = /* @__PURE__ */ new Map();
|
|
3996
|
-
const
|
|
3996
|
+
const pending = [];
|
|
3997
3997
|
const failed = [];
|
|
3998
3998
|
const MAX_FAILED = 1e3;
|
|
3999
3999
|
let running = false;
|
|
@@ -4004,8 +4004,8 @@ function createMemoryQueue(opts) {
|
|
|
4004
4004
|
const MAX_CONCURRENT = 16;
|
|
4005
4005
|
function insertJob(job) {
|
|
4006
4006
|
let i = 0;
|
|
4007
|
-
while (i <
|
|
4008
|
-
|
|
4007
|
+
while (i < pending.length && pending[i].runAt <= job.runAt) i++;
|
|
4008
|
+
pending.splice(i, 0, job);
|
|
4009
4009
|
}
|
|
4010
4010
|
async function execute(job, handler) {
|
|
4011
4011
|
inflight++;
|
|
@@ -4030,8 +4030,8 @@ function createMemoryQueue(opts) {
|
|
|
4030
4030
|
async function poll() {
|
|
4031
4031
|
if (!running) return;
|
|
4032
4032
|
const now = Date.now();
|
|
4033
|
-
while (running && inflight < MAX_CONCURRENT &&
|
|
4034
|
-
const job =
|
|
4033
|
+
while (running && inflight < MAX_CONCURRENT && pending.length > 0 && pending[0].runAt <= now) {
|
|
4034
|
+
const job = pending.shift();
|
|
4035
4035
|
const handler = handlers.get(job.type);
|
|
4036
4036
|
if (handler) execute(job, handler);
|
|
4037
4037
|
}
|
|
@@ -4081,8 +4081,8 @@ function createMemoryQueue(opts) {
|
|
|
4081
4081
|
mw.stop();
|
|
4082
4082
|
while (inflight > 0) await new Promise((r) => setTimeout(r, 50));
|
|
4083
4083
|
};
|
|
4084
|
-
mw.jobs = async function
|
|
4085
|
-
return
|
|
4084
|
+
mw.jobs = async function(limit) {
|
|
4085
|
+
return pending.slice(0, limit ?? 50);
|
|
4086
4086
|
};
|
|
4087
4087
|
mw.failedJobs = async function failedJobs(limit) {
|
|
4088
4088
|
return failed.slice(0, limit ?? 50);
|
|
@@ -5626,7 +5626,7 @@ function createRunner(deps) {
|
|
|
5626
5626
|
}
|
|
5627
5627
|
}
|
|
5628
5628
|
async function addKnowledge(agentId, title, content) {
|
|
5629
|
-
const chunks = chunkContent(content);
|
|
5629
|
+
const chunks = chunkContent(content, 1024, 128);
|
|
5630
5630
|
const [first] = chunks;
|
|
5631
5631
|
const embedding = await provider.embed(first);
|
|
5632
5632
|
const vec = `[${embedding.join(",")}]`;
|