mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-08 01:39:12 +00:00
fix: update references after moving message functions to MessageV2 namespace
This commit is contained in:
@@ -273,17 +273,6 @@ export namespace Session {
|
||||
return diffs ?? []
|
||||
})
|
||||
|
||||
export const messageStream = fn(Identifier.schema("session"), async function* (sessionID) {
|
||||
const list = await Array.fromAsync(await Storage.list(["message", sessionID]))
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
const read = await Storage.read<MessageV2.Info>(list[i])
|
||||
yield {
|
||||
info: read,
|
||||
parts: await getParts(read.id),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export const messages = fn(
|
||||
z.object({
|
||||
sessionID: Identifier.schema("session"),
|
||||
@@ -291,7 +280,7 @@ export namespace Session {
|
||||
}),
|
||||
async (input) => {
|
||||
const result = [] as MessageV2.WithParts[]
|
||||
for await (const msg of messageStream(input.sessionID)) {
|
||||
for await (const msg of MessageV2.stream(input.sessionID)) {
|
||||
if (input.limit && result.length >= input.limit) break
|
||||
result.push(msg)
|
||||
}
|
||||
@@ -300,29 +289,6 @@ export namespace Session {
|
||||
},
|
||||
)
|
||||
|
||||
export const getMessage = fn(
|
||||
z.object({
|
||||
sessionID: Identifier.schema("session"),
|
||||
messageID: Identifier.schema("message"),
|
||||
}),
|
||||
async (input) => {
|
||||
return {
|
||||
info: await Storage.read<MessageV2.Info>(["message", input.sessionID, input.messageID]),
|
||||
parts: await getParts(input.messageID),
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export const getParts = fn(Identifier.schema("message"), async (messageID) => {
|
||||
const result = [] as MessageV2.Part[]
|
||||
for (const item of await Storage.list(["part", messageID])) {
|
||||
const read = await Storage.read<MessageV2.Part>(item)
|
||||
result.push(read)
|
||||
}
|
||||
result.sort((a, b) => (a.id > b.id ? 1 : -1))
|
||||
return result
|
||||
})
|
||||
|
||||
export async function* list() {
|
||||
const project = Instance.project
|
||||
for (const item of await Storage.list(["session", project.id])) {
|
||||
|
||||
Reference in New Issue
Block a user