Skip to content

Commit

Permalink
add llama agent logic for multiple urls
Browse files Browse the repository at this point in the history
  • Loading branch information
fegloff committed Apr 16, 2024
1 parent ead1e50 commit 36b20bf
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/modules/subagents/llamaSubagent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,22 @@ export class LlamaAgent extends SubagentBase {
const id = msg.id ?? 0
if (ctx.chat?.id) {
if (urls && urls?.length > 0) {
let collection = ctx.session.collections.activeCollections.find(c => c.url === urls[0])
if (!collection) {
await this.addUrlToCollection(ctx, ctx.chat?.id, urls[0], msg.content as string)
if (!ctx.session.collections.isProcessingQueue) {
ctx.session.collections.isProcessingQueue = true
await this.onCheckCollectionStatus(ctx).then(() => {
await Promise.all(urls.map(async url => {
let collection = ctx.session.collections.activeCollections.find(c => c.url === url)
if (!collection) {
await this.addUrlToCollection(ctx, ctx.chat?.id, url, msg.content as string)
if (!ctx.session.collections.isProcessingQueue) {
ctx.session.collections.isProcessingQueue = true
await this.onCheckCollectionStatus(ctx)
ctx.session.collections.isProcessingQueue = false
})
}
collection = ctx.session.collections.activeCollections.find(c => c.url === url)
}
collection = ctx.session.collections.activeCollections.find(c => c.url === urls[0])
}
if (collection) {
collection.agentId = id
await this.queryUrlCollection(ctx, urls[0], msg.content as string)
}
if (collection) {
collection.agentId = id
await this.queryUrlCollection(ctx, url, msg.content as string)
}
}))
} else if (fileName !== '') {
const collection = ctx.session.collections.activeCollections.find(c => c.fileName === fileName)
if (!collection) {
Expand Down

0 comments on commit 36b20bf

Please sign in to comment.