| 580 | |
| 581 | const body = { |
| 582 | model: titleModelId, |
| 583 | messages: [ |
| 584 | { |
| 585 | role: 'system', |
| 586 | content: [ |
| 587 | 'Generate a concise chat title from the user message.', |
| 588 | 'Return only the title.', |
| 589 | 'Use 3 to 7 words.', |
| 590 | 'No quotation marks, trailing punctuation, or prefixes like "Title:".' |
| 591 | ].join(' ') |
| 592 | }, |
| 593 | { |
| 594 | role: 'user', |
| 595 | content: normalizedPrompt |
| 596 | } |
| 597 | ], |
| 598 | temperature: 0.2, |
| 599 | max_tokens: 24, |
| 600 | reasoning: { effort: 'minimal' } |
| 601 | }; |
| 602 | |
| 603 | try { |
| 604 | const { response, data, text } = await this.fetchWithRetryJson( |
| 605 | access, |
| 606 | url, |
| 607 | { |
| 608 | method: 'POST', |
| 609 | headers, |
| 610 | body: JSON.stringify(body) |
| 611 | }, |
| 612 | { |
| 613 | context: 'Session title generation', |
| 614 | maxAttempts: 2, |
| 615 | timeoutMs: options.timeoutMs || 10000, |
| 616 | signal: options.signal |
| 617 | } |
| 618 | ); |