(data: any)
| 1875 | |
| 1876 | const readResponseBodyAsText = async (data: any): Promise<string> => { |
| 1877 | if (typeof data === "string") return data; |
| 1878 | if (Buffer.isBuffer(data)) return data.toString("utf8"); |
| 1879 | if (data instanceof Uint8Array) return Buffer.from(data).toString("utf8"); |
| 1880 | if (!isAsyncIterable(data)) return ""; |
| 1881 | |
| 1882 | let body = ""; |
| 1883 | for await (const chunk of data) { |
| 1884 | if (typeof chunk === "string") { |
| 1885 | body += chunk; |
| 1886 | } else if (Buffer.isBuffer(chunk)) { |
| 1887 | body += chunk.toString("utf8"); |
| 1888 | } else if (chunk instanceof Uint8Array) { |
| 1889 | body += Buffer.from(chunk).toString("utf8"); |
| 1890 | } else if (chunk !== undefined && chunk !== null) { |
| 1891 | body += String(chunk); |
| 1892 | } |
| 1893 | } |
| 1894 | |
| 1895 | return body; |
| 1896 | }; |
| 1897 | |
| 1898 | const collectOpenAISources = ( |
| 1899 | data: any, |
| 1900 | ): Array<{ url: string; title?: string }> => { |
no test coverage detected