1- import { Provider } from "@/provider/provider"
2-
31import { fn } from "@/util/fn"
42import z from "zod"
53import { Session } from "."
@@ -8,16 +6,10 @@ import { MessageV2 } from "./message-v2"
86import { Identifier } from "@/id/id"
97import { Snapshot } from "@/snapshot"
108
11- import { Log } from "@/util/log"
129import { Storage } from "@/storage/storage"
1310import { Bus } from "@/bus"
1411
15- import { LLM } from "./llm"
16- import { Agent } from "@/agent/agent"
17-
1812export namespace SessionSummary {
19- const log = Log . create ( { service : "session.summary" } )
20-
2113 function unquoteGitPath ( input : string ) {
2214 if ( ! input . startsWith ( '"' ) ) return input
2315 if ( ! input . endsWith ( '"' ) ) return input
@@ -117,41 +109,6 @@ export namespace SessionSummary {
117109 diffs,
118110 }
119111 await Session . updateMessage ( userMsg )
120-
121- const textPart = msgWithParts . parts . find ( ( p ) => p . type === "text" && ! p . synthetic ) as MessageV2 . TextPart
122- if ( textPart && ! userMsg . summary ?. title ) {
123- const agent = await Agent . get ( "title" )
124- if ( ! agent ) return
125- const stream = await LLM . stream ( {
126- agent,
127- user : userMsg ,
128- tools : { } ,
129- model : agent . model
130- ? await Provider . getModel ( agent . model . providerID , agent . model . modelID )
131- : ( ( await Provider . getSmallModel ( userMsg . model . providerID ) ) ??
132- ( await Provider . getModel ( userMsg . model . providerID , userMsg . model . modelID ) ) ) ,
133- small : true ,
134- messages : [
135- {
136- role : "user" as const ,
137- content : `
138- The following is the text to summarize:
139- <text>
140- ${ textPart ?. text ?? "" }
141- </text>
142- ` ,
143- } ,
144- ] ,
145- abort : new AbortController ( ) . signal ,
146- sessionID : userMsg . sessionID ,
147- system : [ ] ,
148- retries : 3 ,
149- } )
150- const result = await stream . text
151- log . info ( "title" , { title : result } )
152- userMsg . summary . title = result
153- await Session . updateMessage ( userMsg )
154- }
155112 }
156113
157114 export const diff = fn (
0 commit comments