on main help sign in
fix: fix title generation
d8a4fa0Kujtim Hoxha
internal/llm/agent/agent.go+15−4
@@ -163,7 +163,9 @@ func (a *agent) generateTitle(ctx context.Context, sessionID string, content str
163 return err
163 return err
164 }
164 }
165 parts := []message.ContentPart{message.TextContent{Text: content}}
165 parts := []message.ContentPart{message.TextContent{Text: content}}
166+
167+ // Use streaming approach like summarization
166− response, err := a.titleProvider.SendMessages(
168+ response := a.titleProvider.StreamResponse(
167 ctx,
169 ctx,
168 []message.Message{
170 []message.Message{
169 {
171 {
@@ -173,11 +175,20 @@ func (a *agent) generateTitle(ctx context.Context, sessionID string, content str
173 },
175 },
174 make([]tools.BaseTool, 0),
176 make([]tools.BaseTool, 0),
175 )
177 )
178+
179+ var finalResponse *provider.ProviderResponse
180+ for r := range response {
176− if err != nil {
181+ if r.Error != nil {
177− return err
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")
178 }
189 }
179
190
180− title := strings.TrimSpace(strings.ReplaceAll(response.Content, "\n", " "))
191+ title := strings.TrimSpace(strings.ReplaceAll(finalResponse.Content, "\n", " "))
181 if title == "" {
192 if title == "" {
182 return nil
193 return nil
183 }
194 }