@@ -377,11 +377,8 @@ export function formatOutputTextLight(text: string): string {
377377 } )
378378
379379 // 处理中文标签格式 (#标签)
380- // 在流式输出时使用更安全的方式处理标签,避免HTML标签未闭合问题
381380 formatted = formatted . replace ( / # ( \S + ?) (? = # | \s | $ ) / g, ( match , tagContent ) => {
382- // 检查标签内容是否包含HTML标签起始符号但没有闭合符号
383381 if ( tagContent . includes ( '<' ) && ! tagContent . includes ( '>' ) ) {
384- // 在流式输出中遇到不完整的HTML标签,返回原始文本,等待完整内容
385382 return match
386383 }
387384 return `<span class="tag">#${ tagContent } </span>`
@@ -452,7 +449,7 @@ export async function generateImage(options: {
452449}
453450
454451/**
455- * 处理带图片的消息,使用flux-kontext-pro模型编辑图片
452+ * 处理带图片的消息
456453 * @param prompt 提示词
457454 * @param imageBase64 图片base64数据
458455 * @param signal 可选的AbortSignal,用于取消请求
@@ -463,31 +460,21 @@ export async function handleImageWithKontextPro(
463460 imageBase64 : string ,
464461 options : Record < string , any > = { }
465462) {
466- console . log ( '进入handleImageWithKontextPro函数' )
467-
468463 try {
469- // 验证imageBase64是否有效
470464 if ( ! imageBase64 || typeof imageBase64 !== 'string' ) {
471465 throw new Error ( '图片数据无效' )
472466 }
473-
474- // 确保图片数据包含正确的前缀
475467 let imageData = imageBase64
476468 if ( ! imageBase64 . startsWith ( 'data:' ) ) {
477- // 如果没有前缀,添加webp前缀
478469 imageData = `data:image/webp;base64,${ imageBase64 } `
479470 }
480-
481- // 使用新的专用图像编辑API端点
482471 const requestBody = {
483- model : 'flux-kontext-pro ' ,
472+ model : 'flux-kontext-dev ' ,
484473 prompt : prompt || '请编辑这张图片' ,
485474 image : imageData ,
486475 stream : false
487476 }
488477
489- console . log ( '发送图像编辑请求到新的图像编辑API端点' )
490-
491478 const response = await fetch ( '/bizyair/model/image-edit' , {
492479 method : 'POST' ,
493480 headers : {
@@ -497,15 +484,11 @@ export async function handleImageWithKontextPro(
497484 } ,
498485 body : JSON . stringify ( requestBody )
499486 } )
500- console . log ( response , '请求结果' )
501-
502487 const responseData = await response . json ( )
503- console . log ( 'API响应数据:' , responseData )
504488
505489 // 处理包含在data字段中的实际响应
506490 if ( responseData . code === 20000 && responseData . data ) {
507491 const data = responseData . data
508- console . log ( '从data中提取的数据:' , data )
509492
510493 // 处理result字段是字符串的情况
511494 if ( data . result && typeof data . result === 'string' ) {
0 commit comments