Skip to content

Commit

Permalink
fix: add missing await in some hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 committed Oct 29, 2024
1 parent e075284 commit fff6240
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const pluginSettings = t.Object({
})

export const serverContext = new Elysia({ name: 'server-context' }).use(httpError).decorate({
// cat: cheshireCat, // TODO: Fix RangeError: Maximum call stack size exceeded.
// cat: cheshireCat, // FIXME: Fix RangeError: Maximum call stack size exceeded.
mh: madHatter,
rh: rabbitHole,
log,
Expand Down
2 changes: 1 addition & 1 deletion src/looking_glass/agent-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class AgentManager {
output: memoryOutput,
intermediateSteps,
}
const afterMemory = madHatter.executeHook('afterMemoryChain', reply, stray)
const afterMemory = await madHatter.executeHook('afterMemoryChain', reply, stray)

return afterMemory
}
Expand Down
2 changes: 1 addition & 1 deletion src/looking_glass/cheshire-cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class CheshireCat {
{ logMessage: 'Failed to retrieve embedder size. Reset to FakeEmbeddings.' },
)

// TODO: Should we also set it in the db?
// QUESTION: Should we also set it in the db?
if (error) this.embedder = getEmbedder('FakeEmbeddings')!.initModel({})

this._embedderSize = vector.length
Expand Down
10 changes: 5 additions & 5 deletions src/looking_glass/stray-cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class StrayCat {
log.warn(`No websocket connection is open for "${this.userId}". Queuing the message...`)
this.wsQueue.push(msg)
}
madHatter.executeHook('afterSendMessage', msg, this)
madHatter.executeHook('afterSendMessage', msg, this) // QUESTION: Should we introduce MaybePromise also here?
}

/**
Expand All @@ -148,7 +148,7 @@ export class StrayCat {

const response = this.userMessage = await madHatter.executeHook('beforeReadMessage', msg, this)

// TODO: Find another way to handle this
// FEATURE: Find another way to handle this
if (response.text.length > cheshireCat.embedderSize) {
log.warn(`The input is too long. Storing it as document...`)
await rabbitHole.ingestContent(this, response.text)
Expand Down Expand Up @@ -257,7 +257,7 @@ ${labelsList}${examplesList}
async queryDb<T extends Exclude<SqlDialect, 'sap hana'>>(
question: string,
type: T,
source: Omit<Extract<DataSourceOptions, { type: T }>, 'type'>, // TODO: Fix type inference
source: Omit<Extract<DataSourceOptions, { type: T }>, 'type'>, // BUG: Fix type inference
) {
const appDataSource = new DataSource({ type, ...source } as DataSourceOptions)
const db = await SqlDatabase.fromDataSourceParams({ appDataSource })
Expand Down Expand Up @@ -316,7 +316,7 @@ ${labelsList}${examplesList}
*/
addInteraction(interaction: ModelInteraction) {
this.modelsInteractions.push(interaction)
madHatter.executeHook('afterModelInteraction', interaction, this)
madHatter.executeHook('afterModelInteraction', interaction, this) // QUESTION: Should we introduce MaybePromise also here?
}

/**
Expand Down Expand Up @@ -386,7 +386,7 @@ ${labelsList}${examplesList}
log.info(`Recalled ${memories.length} memories for ${key} collection.`)
this.workingMemory[key] = memories
}
madHatter.executeHook('afterRecallMemories', structuredClone(this.workingMemory), this)
await madHatter.executeHook('afterRecallMemories', structuredClone(this.workingMemory), this)

interaction.reply = queryEmbedding
interaction.endedAt = Date.now()
Expand Down

0 comments on commit fff6240

Please sign in to comment.