@@ -235,10 +235,8 @@ export async function sendStreamChatRequest(
235235
236236 const requestBody = buildChatRequestBody ( messagesArray , options )
237237
238- // 确保总是设置stream=true,因为这个函数是专门用于流式请求的
239238 requestBody . stream = true
240239
241- // 创建AbortController用于中止请求
242240 const abortController = new AbortController ( )
243241
244242 try {
@@ -328,17 +326,13 @@ export function formatOutputText(text: string): string {
328326
329327 // 替换井号标记(如 "###","####"等)
330328 text = text . replace ( / ^ ( # { 1 , 6 } ) \s + ( .+ ) $ / gm, ( hashes , content ) => {
331- // 根据井号数量决定标题级别或者样式
332329 const level = Math . min ( hashes . length , 6 )
333- // 对于标题内容,应用颜色样式而不是使用h标签
330+
334331 return `<div class="markdown-heading level-${ level } ">${ content } </div>`
335332 } )
336333
337- // 防止连续的#标签被错误解析(如#标签1#标签2),先将非标题格式的#标签替换为安全标记
338334 text = text . replace ( / # ( \S + ?) (? = # | \s | $ ) / g, ( match , tagContent ) => {
339- // 检查标签内容是否包含HTML标签起始符号但没有闭合符号
340335 if ( tagContent . includes ( '<' ) && ! tagContent . includes ( '>' ) ) {
341- // 遇到不完整的HTML标签,返回原始文本
342336 return match
343337 }
344338 return `<span class="tag">#${ tagContent } </span>`
@@ -370,13 +364,13 @@ export function formatOutputTextLight(text: string): string {
370364 // 基本的Markdown格式转换
371365 let formatted = text
372366
373- // 处理标题格式 (# 标题)
367+ // 处理标题格式
374368 formatted = formatted . replace ( / ^ ( # { 1 , 6 } ) \s + ( .+ ) $ / gm, ( hashes , content ) => {
375369 const level = Math . min ( hashes . length , 6 )
376370 return `<div class="markdown-heading level-${ level } ">${ content } </div>`
377371 } )
378372
379- // 处理中文标签格式 (#标签)
373+ // 处理中文标签格式
380374 formatted = formatted . replace ( / # ( \S + ?) (? = # | \s | $ ) / g, ( match , tagContent ) => {
381375 if ( tagContent . includes ( '<' ) && ! tagContent . includes ( '>' ) ) {
382376 return match
@@ -449,7 +443,7 @@ export async function generateImage(options: {
449443}
450444
451445/**
452- * 处理带图片的消息
446+ * 编辑图片
453447 * @param prompt 提示词
454448 * @param imageBase64 图片base64数据
455449 * @param signal 可选的AbortSignal,用于取消请求
@@ -470,7 +464,7 @@ export async function handleImageWithKontextPro(
470464 }
471465 const requestBody = {
472466 model : 'flux-kontext-dev' ,
473- prompt : prompt || '请编辑这张图片 ' ,
467+ prompt : prompt || '' ,
474468 image : imageData ,
475469 stream : false
476470 }
@@ -486,11 +480,9 @@ export async function handleImageWithKontextPro(
486480 } )
487481 const responseData = await response . json ( )
488482
489- // 处理包含在data字段中的实际响应
490483 if ( responseData . code === 20000 && responseData . data ) {
491484 const data = responseData . data
492485
493- // 处理result字段是字符串的情况
494486 if ( data . result && typeof data . result === 'string' ) {
495487 try {
496488 const resultJson = JSON . parse ( data . result )
0 commit comments