on main help sign in
fix: fix title generation
commitd8a4fa0b26b73133e2f3211ee0b3bbf0c27260c2 authorKujtim Hoxha <kujtimii.h@gmail.com> dateTue 17 Jun 2025, 14:06 (1 year ago) parentac5fb91
1 file changed+15−4
internal/llm/agent/agent.go+15−4
internal/llm/agent/agent.go+15−4
@@ -163,7 +163,9 @@ func (a *agent) generateTitle(ctx context.Context, sessionID string, content str
163163 return err
164164 }
165165 parts := []message.ContentPart{message.TextContent{Text: content}}
166− response, err := a.titleProvider.SendMessages(
166+
167+ // Use streaming approach like summarization
168+ response := a.titleProvider.StreamResponse(
167169 ctx,
168170 []message.Message{
169171 {
@@ -173,11 +175,20 @@ func (a *agent) generateTitle(ctx context.Context, sessionID string, content str
173175 },
174176 make([]tools.BaseTool, 0),
175177 )
176− if err != nil {
177− return err
178+
179+ var finalResponse *provider.ProviderResponse
180+ for r := range response {
181+ if r.Error != nil {
182+ return r.Error
183+ }
184+ finalResponse = r.Response
185+ }
186+
187+ if finalResponse == nil {
188+ return fmt.Errorf("no response received from title provider")
178189 }
179190
180− title := strings.TrimSpace(strings.ReplaceAll(response.Content, "\n", " "))
191+ title := strings.TrimSpace(strings.ReplaceAll(finalResponse.Content, "\n", " "))
181192 if title == "" {
182193 return nil
183194 }