fix(formats): add optional chaining for grounding support properties to prevent errors
This commit is contained in:
parent
d38c4c7368
commit
97c1d67cbf
@ -71,12 +71,16 @@ export function withGeminiGrounding(message: Message) {
|
|||||||
let content = message.content
|
let content = message.content
|
||||||
|
|
||||||
groundingSupports.forEach((support) => {
|
groundingSupports.forEach((support) => {
|
||||||
const text = support.segment.text
|
const text = support?.segment
|
||||||
const indices = support.groundingChunkIndices
|
const indices = support?.groundingChunckIndices
|
||||||
const nodes = indices.reduce((acc, index) => {
|
|
||||||
|
if (!text || !indices) return
|
||||||
|
|
||||||
|
const nodes = indices.reduce<string[]>((acc, index) => {
|
||||||
acc.push(`<sup>${index + 1}</sup>`)
|
acc.push(`<sup>${index + 1}</sup>`)
|
||||||
return acc
|
return acc
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
content = content.replace(text, `${text} ${nodes.join(' ')}`)
|
content = content.replace(text, `${text} ${nodes.join(' ')}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user