MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / generateSessionTitle

Method generateSessionTitle

chat/api.js:366–453  ·  view source on GitHub ↗
(prompt, apiKey, options = {})

Source from the content-addressed store, hash-verified

364 if (typeof content === 'string') return content;
365 if (Array.isArray(content)) {
366 return content
367 .map(part => {
368 if (!part) return '';
369 if (typeof part === 'string') return part;
370 if (typeof part.text === 'string') return part.text;
371 if (typeof part.content === 'string') return part.content;
372 return '';
373 })
374 .filter(Boolean)
375 .join(' ');
376 }
377 if (content && typeof content.text === 'string') return content.text;
378 if (content && typeof content.content === 'string') return content.content;
379 return '';
380 }
381
382 // Get model-specific max_tokens (disabled - let OpenRouter use API key credits)
383 // getMaxTokensForModel(modelId) {
384 // const baseModelId = typeof modelId === 'string' ? modelId.split(':')[0] : '';
385 // // Check for Opus 4.1
386 // if (baseModelId.includes('claude-opus-4.1')) {
387 // return 13333;
388 // }
389 // // Check for GPT-5 Thinking (exclude chat variants)
390 // if (
391 // baseModelId.includes('gpt-5') &&
392 // !baseModelId.endsWith('-chat')
393 // ) {
394 // return 120000;
395 // }
396 // return undefined; // Use API default for other models
397 // }
398
399 // Fallback models if API fails
400 getFallbackModels() {
401 return [
402 { id: 'openai/gpt-5.3-chat', name: 'OpenAI: GPT-5.3 Instant', category: 'Flagship models', provider: 'OpenAI' },
403 { id: 'openai/gpt-5.3', name: 'OpenAI: GPT-5.3 Thinking', category: 'Flagship models', provider: 'OpenAI' },
404 { id: 'openai/gpt-5.2-chat', name: 'OpenAI: GPT-5.2 Instant', category: 'Flagship models', provider: 'OpenAI' },
405 { id: 'openai/gpt-5.1-chat', name: 'OpenAI: GPT-5.1 Instant', category: 'Flagship models', provider: 'OpenAI' },
406 { id: 'anthropic/claude-sonnet-4.5', name: 'Anthropic: Claude Sonnet 4.5', category: 'Flagship models', provider: 'Anthropic' },
407 { id: 'google/gemini-3-pro-preview', name: 'Google: Gemini 3 Pro Preview', category: 'Flagship models', provider: 'Google' },
408 ];
409 }
410
411 // Send chat completion request
412 async _sendCompletionStrict(messages, modelId, apiKey, options = {}) {
413 const url = `${this.baseUrl}/chat/completions`;
414 const headers = this._requestAccess.headers;
415
416 const {
417 context = 'Inference completion',
418 maxAttempts = 3,
419 timeoutMs = 0,
420 signal = null,
421 searchEnabled = false,
422 reasoningEnabled = true,
423 reasoningEffort = DEFAULT_REASONING_EFFORT

Callers 3

generateSessionTitleFunction · 0.80

Calls 5

getApiKeyMethod · 0.95
extractTextContentMethod · 0.95
fetchWithRetryJsonMethod · 0.80
logRequestMethod · 0.80
sanitizeHeadersMethod · 0.80

Tested by

no test coverage detected