UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into

1 lines 2.21 kB
{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-Z5KZJ74V.cjs","../src/libs/providers/ollama/utils/response-handler.ts"],"names":["createJsonStreamResponseHandler","chunkSchema","response","responseHeaders","extractResponseHeaders","EmptyResponseBodyError","TextLineStream","chunkText","controller","safeParseJSON"],"mappings":"AAAA;AACA,wDAAwC,4CCDH,uDAM9B,IAKMA,CAAAA,CAETC,CAAAA,EAEF,KAAA,CAAO,CAAC,QAAA,CAAAC,CAAQ,CAAA,CAAA,EAA4B,CAC1C,IAAMC,CAAAA,CAAkBC,mDAAAA,CAA+B,CAAA,CAEvD,EAAA,CAAIF,CAAAA,CAAS,IAAA,GAAS,IAAA,CACpB,MAAM,IAAIG,qCAAAA,CAAuB,CAAC,CAAC,CAAA,CAGrC,MAAO,CACL,eAAA,CAAAF,CAAAA,CACA,KAAA,CAAOD,CAAAA,CAAS,IAAA,CACb,WAAA,CAAY,IAAI,iBAAmB,CAAA,CACnC,WAAA,CAAY,IAAII,mBAAgB,CAAA,CAChC,WAAA,CACC,IAAI,eAAA,CAAwC,CAC1C,MAAM,SAAA,CAAUC,CAAAA,CAAWC,CAAAA,CAAY,CACrCA,CAAAA,CAAW,OAAA,CACT,MAAMC,0CAAAA,CACJ,MAAA,CAAQR,CAAAA,CACR,IAAA,CAAMM,CACR,CAAC,CACH,CACF,CACF,CAAC,CACH,CACJ,CACF,CAAA,CAAA,cAAA;ADtCF","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-Z5KZJ74V.cjs","sourcesContent":[null,"import {EmptyResponseBodyError} from '@ai-sdk/provider';\nimport {\n extractResponseHeaders,\n type ParseResult,\n type ResponseHandler,\n safeParseJSON,\n} from '@ai-sdk/provider-utils';\nimport type {ZodSchema} from 'zod';\n\nimport {TextLineStream} from './text-line-stream.js';\n\nexport const createJsonStreamResponseHandler =\n <T>(\n chunkSchema: ZodSchema<T>,\n ): ResponseHandler<ReadableStream<ParseResult<T>>> =>\n async ({response}: {response: Response}) => {\n const responseHeaders = extractResponseHeaders(response);\n\n if (response.body === null) {\n throw new EmptyResponseBodyError({});\n }\n\n return {\n responseHeaders,\n value: response.body\n .pipeThrough(new TextDecoderStream())\n .pipeThrough(new TextLineStream())\n .pipeThrough(\n new TransformStream<string, ParseResult<T>>({\n async transform(chunkText, controller) {\n controller.enqueue(\n await safeParseJSON({\n schema: chunkSchema,\n text: chunkText,\n }),\n );\n },\n }),\n ),\n };\n };\n"]}