( item: any, )
| 2065 | |
| 2066 | const parseResponsesOutputContent = ( |
| 2067 | item: any, |
| 2068 | ): { |
| 2069 | text: string; |
| 2070 | images: AIImage[]; |
| 2071 | sources: Array<{ url: string; title?: string }>; |
| 2072 | } => { |
| 2073 | const textSegments: string[] = []; |
| 2074 | const images: AIImage[] = []; |
| 2075 | const sources = collectResponsesSources(item); |
| 2076 | |
| 2077 | if (item?.type !== "message") { |
| 2078 | return { text: "", images, sources }; |
| 2079 | } |
| 2080 | |
| 2081 | for (const part of item.content || []) { |
| 2082 | if (part?.type === "output_text" && typeof part.text === "string") { |
| 2083 | textSegments.push(part.text); |
| 2084 | continue; |
| 2085 | } |
| 2086 | if (part?.type === "image_url" && part.image_url?.url) { |
| 2087 | const dataUrl = parseDataUrl(part.image_url.url); |
| 2088 | if (dataUrl) { |
| 2089 | images.push({ data: dataUrl.data, mimeType: dataUrl.mimeType }); |
| 2090 | } else { |
| 2091 | images.push({ url: part.image_url.url, mimeType: "image/jpeg" }); |
| 2092 | } |
| 2093 | } |
| 2094 | } |
| 2095 | |
| 2096 | return { |
| 2097 | text: textSegments.join("\n").trim(), |
| 2098 | images, |
| 2099 | sources, |
| 2100 | }; |
| 2101 | }; |
| 2102 | |
| 2103 | const aggregateResponsesApiPayloads = ( |
| 2104 | payloads: any[], |
| 2105 | ): { |
no test coverage detected