MCPcopy Index your code
hub / github.com/Effect-TS/effect / createMessageStream

Function createMessageStream

packages/ai/anthropic/src/AnthropicClient.ts:301–314  ·  view source on GitHub ↗
(options: {
    readonly params?: typeof Generated.BetaMessagesPostParams.Encoded | undefined
    readonly payload: Omit<typeof Generated.BetaCreateMessageParams.Encoded, "stream">
  })

Source from the content-addressed store, hash-verified

299 )
300
301 const createMessageStream = (options: {
302 readonly params?: typeof Generated.BetaMessagesPostParams.Encoded | undefined
303 readonly payload: Omit<typeof Generated.BetaCreateMessageParams.Encoded, "stream">
304 }): Stream.Stream<MessageStreamEvent, AiError.AiError> => {
305 const request = HttpClientRequest.post("/v1/messages", {
306 headers: Headers.fromInput({
307 "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined
308 }),
309 body: HttpBody.unsafeJson({ ...options.payload, stream: true })
310 })
311 return streamRequest(request, MessageStreamEvent).pipe(
312 Stream.takeUntil((event) => event.type === "message_stop")
313 )
314 }
315
316 return AnthropicClient.of({
317 client,

Callers

nothing calls this directly

Calls 2

streamRequestFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected