* 剥离 Markdown 代码块包裹,返回裸 JSON 字符串 * 处理 ```json\n...\n``` 和 ```\n...\n``` 两种格式
(text: string)
| 1271 | * 处理 ```json\n...\n``` 和 ```\n...\n``` 两种格式 |
| 1272 | */ |
| 1273 | function stripMarkdownJsonWrapper(text: string): string { |
| 1274 | if (!text) return text; |
| 1275 | const trimmed = text.trim(); |
| 1276 | const match = trimmed.match(/^```(?:json)?\s*\n([\s\S]*?)\n\s*```$/); |
| 1277 | if (match) { |
| 1278 | return match[1].trim(); |
| 1279 | } |
| 1280 | return text; |
| 1281 | } |
| 1282 | |
| 1283 | function writeOpenAISSE(res: Response, data: OpenAIChatCompletionChunk): void { |
| 1284 | res.write(`data: ${JSON.stringify(data)}\n\n`); |
no outgoing calls
no test coverage detected