core: fix model selection in title generation to use user's model instead of assistant's
This commit is contained in:
@@ -74,11 +74,6 @@ export namespace SessionSummary {
|
|||||||
}
|
}
|
||||||
await Session.updateMessage(userMsg)
|
await Session.updateMessage(userMsg)
|
||||||
|
|
||||||
const assistantMsg = messages.find((m) => m.info.role === "assistant")!.info as MessageV2.Assistant
|
|
||||||
const small =
|
|
||||||
(await Provider.getSmallModel(assistantMsg.providerID)) ??
|
|
||||||
(await Provider.getModel(assistantMsg.providerID, assistantMsg.modelID))
|
|
||||||
|
|
||||||
const textPart = msgWithParts.parts.find((p) => p.type === "text" && !p.synthetic) as MessageV2.TextPart
|
const textPart = msgWithParts.parts.find((p) => p.type === "text" && !p.synthetic) as MessageV2.TextPart
|
||||||
if (textPart && !userMsg.summary?.title) {
|
if (textPart && !userMsg.summary?.title) {
|
||||||
const agent = await Agent.get("title")
|
const agent = await Agent.get("title")
|
||||||
@@ -86,7 +81,10 @@ export namespace SessionSummary {
|
|||||||
agent,
|
agent,
|
||||||
user: userMsg,
|
user: userMsg,
|
||||||
tools: {},
|
tools: {},
|
||||||
model: agent.model ? await Provider.getModel(agent.model.providerID, agent.model.modelID) : small,
|
model: agent.model
|
||||||
|
? await Provider.getModel(agent.model.providerID, agent.model.modelID)
|
||||||
|
: ((await Provider.getSmallModel(userMsg.model.providerID)) ??
|
||||||
|
(await Provider.getModel(userMsg.model.providerID, userMsg.model.modelID))),
|
||||||
small: true,
|
small: true,
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
@@ -109,49 +107,6 @@ export namespace SessionSummary {
|
|||||||
userMsg.summary.title = result
|
userMsg.summary.title = result
|
||||||
await Session.updateMessage(userMsg)
|
await Session.updateMessage(userMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
messages.some(
|
|
||||||
(m) =>
|
|
||||||
m.info.role === "assistant" && m.parts.some((p) => p.type === "step-finish" && p.reason !== "tool-calls"),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if (diffs.length > 0) {
|
|
||||||
for (const msg of messages) {
|
|
||||||
for (const part of msg.parts) {
|
|
||||||
if (part.type === "tool" && part.state.status === "completed") {
|
|
||||||
part.state.output = "[TOOL OUTPUT PRUNED]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const summaryAgent = await Agent.get("summary")
|
|
||||||
const stream = await LLM.stream({
|
|
||||||
agent: summaryAgent,
|
|
||||||
user: userMsg,
|
|
||||||
tools: {},
|
|
||||||
model: summaryAgent.model
|
|
||||||
? await Provider.getModel(summaryAgent.model.providerID, summaryAgent.model.modelID)
|
|
||||||
: small,
|
|
||||||
small: true,
|
|
||||||
messages: [
|
|
||||||
...MessageV2.toModelMessage(messages),
|
|
||||||
{
|
|
||||||
role: "user" as const,
|
|
||||||
content: `Summarize the above conversation according to your system prompts.`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
abort: new AbortController().signal,
|
|
||||||
sessionID: userMsg.sessionID,
|
|
||||||
system: [],
|
|
||||||
retries: 3,
|
|
||||||
})
|
|
||||||
const result = await stream.text
|
|
||||||
if (result) {
|
|
||||||
userMsg.summary.body = result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Session.updateMessage(userMsg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const diff = fn(
|
export const diff = fn(
|
||||||
|
|||||||
Reference in New Issue
Block a user