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
|
||||
|
||||
groundingSupports.forEach((support) => {
|
||||
const text = support.segment.text
|
||||
const indices = support.groundingChunkIndices
|
||||
const nodes = indices.reduce((acc, index) => {
|
||||
const text = support?.segment
|
||||
const indices = support?.groundingChunckIndices
|
||||
|
||||
if (!text || !indices) return
|
||||
|
||||
const nodes = indices.reduce<string[]>((acc, index) => {
|
||||
acc.push(`<sup>${index + 1}</sup>`)
|
||||
return acc
|
||||
}, [])
|
||||
|
||||
content = content.replace(text, `${text} ${nodes.join(' ')}`)
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user