chore: generate
This commit is contained in:
@@ -276,12 +276,16 @@ export const SessionRoutes = lazy(() =>
|
|||||||
const sessionID = c.req.valid("param").sessionID
|
const sessionID = c.req.valid("param").sessionID
|
||||||
const updates = c.req.valid("json")
|
const updates = c.req.valid("json")
|
||||||
|
|
||||||
const updatedSession = await Session.update(sessionID, (session) => {
|
const updatedSession = await Session.update(
|
||||||
if (updates.title !== undefined) {
|
sessionID,
|
||||||
session.title = updates.title
|
(session) => {
|
||||||
}
|
if (updates.title !== undefined) {
|
||||||
if (updates.time?.archived !== undefined) session.time.archived = updates.time.archived
|
session.title = updates.title
|
||||||
}, { touch: false })
|
}
|
||||||
|
if (updates.time?.archived !== undefined) session.time.archived = updates.time.archived
|
||||||
|
},
|
||||||
|
{ touch: false },
|
||||||
|
)
|
||||||
|
|
||||||
return c.json(updatedSession)
|
return c.json(updatedSession)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -255,11 +255,15 @@ export namespace Session {
|
|||||||
}
|
}
|
||||||
const { ShareNext } = await import("@/share/share-next")
|
const { ShareNext } = await import("@/share/share-next")
|
||||||
const share = await ShareNext.create(id)
|
const share = await ShareNext.create(id)
|
||||||
await update(id, (draft) => {
|
await update(
|
||||||
draft.share = {
|
id,
|
||||||
url: share.url,
|
(draft) => {
|
||||||
}
|
draft.share = {
|
||||||
}, { touch: false })
|
url: share.url,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ touch: false },
|
||||||
|
)
|
||||||
return share
|
return share
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -267,9 +271,13 @@ export namespace Session {
|
|||||||
// Use ShareNext to remove the share (same as share function uses ShareNext to create)
|
// Use ShareNext to remove the share (same as share function uses ShareNext to create)
|
||||||
const { ShareNext } = await import("@/share/share-next")
|
const { ShareNext } = await import("@/share/share-next")
|
||||||
await ShareNext.remove(id)
|
await ShareNext.remove(id)
|
||||||
await update(id, (draft) => {
|
await update(
|
||||||
draft.share = undefined
|
id,
|
||||||
}, { touch: false })
|
(draft) => {
|
||||||
|
draft.share = undefined
|
||||||
|
},
|
||||||
|
{ touch: false },
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export async function update(id: string, editor: (session: Info) => void, options?: { touch?: boolean }) {
|
export async function update(id: string, editor: (session: Info) => void, options?: { touch?: boolean }) {
|
||||||
|
|||||||
@@ -1806,16 +1806,20 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|||||||
})
|
})
|
||||||
const text = await result.text.catch((err) => log.error("failed to generate title", { error: err }))
|
const text = await result.text.catch((err) => log.error("failed to generate title", { error: err }))
|
||||||
if (text)
|
if (text)
|
||||||
return Session.update(input.session.id, (draft) => {
|
return Session.update(
|
||||||
const cleaned = text
|
input.session.id,
|
||||||
.replace(/<think>[\s\S]*?<\/think>\s*/g, "")
|
(draft) => {
|
||||||
.split("\n")
|
const cleaned = text
|
||||||
.map((line) => line.trim())
|
.replace(/<think>[\s\S]*?<\/think>\s*/g, "")
|
||||||
.find((line) => line.length > 0)
|
.split("\n")
|
||||||
if (!cleaned) return
|
.map((line) => line.trim())
|
||||||
|
.find((line) => line.length > 0)
|
||||||
|
if (!cleaned) return
|
||||||
|
|
||||||
const title = cleaned.length > 100 ? cleaned.substring(0, 97) + "..." : cleaned
|
const title = cleaned.length > 100 ? cleaned.substring(0, 97) + "..." : cleaned
|
||||||
draft.title = title
|
draft.title = title
|
||||||
}, { touch: false })
|
},
|
||||||
|
{ touch: false },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user