fix: markdown解析bug
This commit is contained in:
@@ -99,13 +99,13 @@ export const EnhancedMarkdownRenderer: React.FC<EnhancedMarkdownRendererProps> =
|
||||
return null;
|
||||
}
|
||||
|
||||
// 计算节点在原始文本中的字符偏移位置
|
||||
const nodeStartOffset = node.range?.start?.offset || 0;
|
||||
const nodeEndOffset = node.range?.end?.offset || 0;
|
||||
// 计算节点在原始文本中的字节偏移位置(与grounding数据的字节偏移匹配)
|
||||
const nodeStartOffset = node.range?.start?.byte_offset || 0;
|
||||
const nodeEndOffset = node.range?.end?.byte_offset || 0;
|
||||
|
||||
// 查找与当前节点位置重叠的grounding支持信息
|
||||
|
||||
const relatedSupports = groundingMetadata.grounding_supports.filter(support => {
|
||||
// 这里是字符串二进制的offset
|
||||
// grounding数据使用字节偏移
|
||||
const segmentStart = support.segment.startIndex;
|
||||
const segmentEnd = support.segment.endIndex;
|
||||
|
||||
@@ -113,7 +113,11 @@ export const EnhancedMarkdownRenderer: React.FC<EnhancedMarkdownRendererProps> =
|
||||
// 检查节点范围与grounding片段是否有重叠
|
||||
return hasOverlap;
|
||||
});
|
||||
|
||||
console.log({
|
||||
relatedSupports,
|
||||
nodeStartOffset,
|
||||
nodeEndOffset
|
||||
})
|
||||
if (relatedSupports.length > 0) {
|
||||
// 获取相关的来源信息
|
||||
const relatedSources = relatedSupports.flatMap(support =>
|
||||
|
||||
Reference in New Issue
Block a user