MCPcopy
hub / github.com/7836246/cursor2api / extractThinking

Function extractThinking

src/handler.ts:61–79  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

59 * 导致 thinking 后半段 + 闭合标签泄漏到正文。
60 */
61export function extractThinking(text: string): { thinkingContent: string; strippedText: string } {
62 const startIdx = text.indexOf(THINKING_OPEN);
63 if (startIdx === -1) return { thinkingContent: '', strippedText: text };
64
65 const contentStart = startIdx + THINKING_OPEN.length;
66 const endIdx = text.lastIndexOf(THINKING_CLOSE);
67
68 if (endIdx > startIdx) {
69 return {
70 thinkingContent: text.slice(contentStart, endIdx).trim(),
71 strippedText: (text.slice(0, startIdx) + text.slice(endIdx + THINKING_CLOSE.length)).trim(),
72 };
73 }
74 // 未闭合(流式截断)→ thinking 取到末尾,正文为开头部分
75 return {
76 thinkingContent: text.slice(contentStart).trim(),
77 strippedText: text.slice(0, startIdx).trim(),
78 };
79}
80
81// ==================== 模型列表 ====================
82

Callers 7

handleOpenAIStreamFunction · 0.85
handleOpenAINonStreamFunction · 0.85
handleResponsesStreamFunction · 0.85
handleResponsesNonStreamFunction · 0.85
handleDirectTextStreamFunction · 0.85
handleStreamFunction · 0.85
handleNonStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected