(entries: any[] | undefined, isAnnotation = false)
| 1903 | |
| 1904 | const appendEntries = (entries: any[] | undefined, isAnnotation = false) => { |
| 1905 | if (!Array.isArray(entries)) return; |
| 1906 | for (const entry of entries) { |
| 1907 | const url = isAnnotation |
| 1908 | ? entry?.url_citation?.url || entry?.url |
| 1909 | : entry?.url; |
| 1910 | const title = isAnnotation |
| 1911 | ? entry?.url_citation?.title || entry?.title |
| 1912 | : entry?.title; |
| 1913 | if (!url || seen.has(url)) continue; |
| 1914 | seen.add(url); |
| 1915 | sources.push({ url, title }); |
| 1916 | } |
| 1917 | }; |
| 1918 | |
| 1919 | const choice = data?.choices?.[0]; |
| 1920 | |
| 1921 | appendEntries(data?.citations); |
no test coverage detected