MCPcopy Create free account
hub / github.com/Effect-TS/effect / streamRequest

Function streamRequest

packages/ai/amazon-bedrock/src/AmazonBedrockClient.ts:146–174  ·  view source on GitHub ↗
(
      request: HttpClientRequest.HttpClientRequest,
      schema: Schema.Schema<A, I, R>
    )

Source from the content-addressed store, hash-verified

144 )
145
146 const streamRequest = <A, I, R>(
147 request: HttpClientRequest.HttpClientRequest,
148 schema: Schema.Schema<A, I, R>
149 ): Stream.Stream<A, AiError.AiError, R> =>
150 httpClientOk.execute(request).pipe(
151 Effect.map((r) => r.stream),
152 Stream.unwrapScoped,
153 Stream.pipeThroughChannel(EventStreamEncoding.makeChannel(schema)),
154 Stream.catchTags({
155 RequestError: (error) =>
156 AiError.HttpRequestError.fromRequestError({
157 module: "AmazonBedrockClient",
158 method: "streamRequest",
159 error
160 }),
161 ResponseError: (error) =>
162 AiError.HttpResponseError.fromResponseError({
163 module: "AmazonBedrockClient",
164 method: "streamRequest",
165 error
166 }),
167 ParseError: (error) =>
168 AiError.MalformedOutput.fromParseError({
169 module: "AmazonBedrockClient",
170 method: "streamRequest",
171 error
172 })
173 })
174 )
175
176 const converseStream = (options: {
177 readonly params?: { "anthropic-beta"?: string | undefined } | undefined

Callers 1

converseStreamFunction · 0.70

Calls 6

fromRequestErrorMethod · 0.80
fromResponseErrorMethod · 0.80
pipeMethod · 0.65
mapMethod · 0.65
executeMethod · 0.45
fromParseErrorMethod · 0.45

Tested by

no test coverage detected