~/bend-docscommunity

llm.bend relies on unsafe/foreign

raw source on the hub · import bend-kit-llm@0.18.0.0/llm.bend as Llm

LLM client for the Anthropic Messages and OpenAI Chat Completions APIs, with SSE streaming. Source: https://github.com/paymog/bend-kit/tree/main/llm

10 imports
import Base
import ./sse.bend as Sse
import bend-kit-hairpin@0.18.0.0/hairpin.bend as Hairpin
import bend-kit-retry@0.3.0.0/retry.bend as Retry
import bend-kit-http@0.45.0.0/http.bend as Http
import bend-kit-http@0.45.0.0/pure.bend as HttpPure
import bend-kit-json@0.7.3.0/json.bend as Json
import bend-kit-bytes@0.3.3.1/bytes.bend as Bytes
import bend-kit-encoding@0.5.0.1/encoding.bend as Enc
import ./pure.bend as Pure

Types

type Api source · line 14 · raw

Data

Anthropic: POST {base}/v1/messages. OpenAI: POST {base}/chat/completions, which many other providers serve too.

type Role source · line 18 · raw

Data

type Msg source · line 22 · raw

Data

type Req source · line 26 · raw

Data

system: "" for none. max: the most tokens to write.

type Reply source · line 30 · raw

Data

stop: the API's reason, as "end_turn" or "stop". input and output count tokens.

type Err source · line 35 · raw

Data

ErrNet: the request did not complete, or Hairpin's breaker admitted no attempt. ErrApi: the API refused, with its status and error text; an error event in a stream has status 200. ErrReply: a reply that is not the API's JSON, with its text.

type Client source · line 41 · raw

Type

headers go on every request. ms: the step timeout. retries: extra tries after a retryable failure.

type Leaf source · line 126 · raw

Data

A JSON leaf: its path, as "content.0.text", and its text.

type Ev source · line 212 · raw

Data

A text piece, the end, an error, or an event with no text.

type Stream source · line 414 · raw

Type

type Rn source · line 534 · raw

Type

The reader after the next event, or the stream's result.

Definitions

def api.to.pure source · line 44 · raw

@v:Api -> 0xa138c0f6ea843d6536a9dbee24466900/pure.Api

def role.to.pure source · line 51 · raw

@v:Role -> 0xa138c0f6ea843d6536a9dbee24466900/pure.Role

def msg.to.pure source · line 58 · raw

@v:Msg -> 0xa138c0f6ea843d6536a9dbee24466900/pure.Msg

def msgs.to.pure source · line 62 · raw

@xs:List<&2, Msg> -> List<&2, 0xa138c0f6ea843d6536a9dbee24466900/pure.Msg>

def req.to.pure source · line 69 · raw

@v:Req -> 0xa138c0f6ea843d6536a9dbee24466900/pure.Req

def reply.from.pure source · line 73 · raw

@v:0xa138c0f6ea843d6536a9dbee24466900/pure.Reply -> Reply

def err.from.pure source · line 77 · raw

@v:0xa138c0f6ea843d6536a9dbee24466900/pure.Err -> Err

def reply.result.from.pure source · line 84 · raw

@v:Result<&1, &1, 0xa138c0f6ea843d6536a9dbee24466900/pure.Err, 0xa138c0f6ea843d6536a9dbee24466900/pure.Reply> -> Result<&1, &1, Err, Reply>

def str source · line 94 · raw

@s:String -> 0x419ec39802735c4664960ab4b9d962e5/json.Val

def kv source · line 97 · raw

@k:String -> @v:0x419ec39802735c4664960ab4b9d962e5/json.Val -> Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0x419ec39802735c4664960ab4b9d962e5/json.Val)

def num source · line 100 · raw

@+n:U32 -> 0x419ec39802735c4664960ab4b9d962e5/json.Val

def obj source · line 103 · raw

@kvs:List<&1, Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0x419ec39802735c4664960ab4b9d962e5/json.Val)> -> 0x419ec39802735c4664960ab4b9d962e5/json.Val

def when source · line 106 · raw

@on:Bool -> @x:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0x419ec39802735c4664960ab4b9d962e5/json.Val) -> @xs:List<&1, Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0x419ec39802735c4664960ab4b9d962e5/json.Val)> -> List<&1, Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0x419ec39802735c4664960ab4b9d962e5/json.Val)>

def role source · line 109 · raw

@r:Role -> String

def msg source · line 112 · raw

@+r:String -> @t:String -> 0x419ec39802735c4664960ab4b9d962e5/json.Val

def msgs source · line 115 · raw

@xs:List<&2, Msg> -> List<&1, 0x419ec39802735c4664960ab4b9d962e5/json.Val>

def sys source · line 118 · raw

@on:Bool -> @s:String -> @xs:List<&1, 0x419ec39802735c4664960ab4b9d962e5/json.Val> -> List<&1, 0x419ec39802735c4664960ab4b9d962e5/json.Val>

def body source · line 122 · raw

@api:Api -> @req:Req -> @stream:Bool -> 0x419ec39802735c4664960ab4b9d962e5/json.Val

The request body for api. stream asks for SSE.

def leaves.to.pure source · line 129 · raw

@xs:List<&2, Leaf> -> List<&2, 0xa138c0f6ea843d6536a9dbee24466900/pure.Leaf>

def leaves.from.pure source · line 136 · raw

@xs:List<&2, 0xa138c0f6ea843d6536a9dbee24466900/pure.Leaf> -> List<&2, Leaf>

def doc.to.pure source · line 143 · raw

@v:Maybe<&2, List<&2, Leaf>> -> Maybe<&2, List<&2, 0xa138c0f6ea843d6536a9dbee24466900/pure.Leaf>>

def doc.from.pure source · line 150 · raw

@v:Maybe<&2, List<&2, 0xa138c0f6ea843d6536a9dbee24466900/pure.Leaf>> -> Maybe<&2, List<&2, Leaf>>

def path source · line 157 · raw

@+p:String -> @+k:String -> String

def push.arr source · line 160 · raw

@xs:List<&1, 0x419ec39802735c4664960ab4b9d962e5/json.Val> -> @+p:String -> @+i:U32 -> @t:List<&1, Pair(String, 0x419ec39802735c4664960ab4b9d962e5/json.Val)> -> List<&1, Pair(String, 0x419ec39802735c4664960ab4b9d962e5/json.Val)>

def push.obj source · line 163 · raw

@kvs:List<&1, Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0x419ec39802735c4664960ab4b9d962e5/json.Val)> -> @+p:String -> @t:List<&1, Pair(String, 0x419ec39802735c4664960ab4b9d962e5/json.Val)> -> List<&1, Pair(String, 0x419ec39802735c4664960ab4b9d962e5/json.Val)>

def flat source · line 167 · raw

@f:Nat -> @stack:List<&1, Pair(String, 0x419ec39802735c4664960ab4b9d962e5/json.Val)> -> @acc:List<&2, Leaf> -> List<&2, Leaf>

The leaves under the stack's values, last first. f: at least the values left.

def doc.of source · line 170 · raw

@+n:U32 -> @m:Maybe<&1, 0x419ec39802735c4664960ab4b9d962e5/json.Val> -> Maybe<&2, List<&2, Leaf>>

def doc source · line 175 · raw

@b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Maybe<&2, List<&2, Leaf>>

Every non-null leaf of a JSON text in document order, keyed by its path, as ("content.0.text", "Hi"). Strings are decoded; numbers keep their text. None when b is not JSON. Each value takes a byte, so n + 1 steps suffice.

def look source · line 179 · raw

@d:List<&2, Leaf> -> @+k:String -> String

The first value at path k, or "".

def count source · line 182 · raw

@s:String -> U32

def dots source · line 185 · raw

@s:String -> @+n:U32 -> U32

def block source · line 189 · raw

@+p:String -> Bool

Is p the text of a content block, "content.<i>.text"?

def blocks source · line 193 · raw

@d:List<&2, Leaf> -> String

The text blocks of an Anthropic message, joined.

def reply.of source · line 196 · raw

@api:Api -> @+d:List<&2, Leaf> -> Reply

def reply.got source · line 199 · raw

@api:Api -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> @m:Maybe<&2, List<&2, Leaf>> -> Result<&1, &1, Err, Reply>

def reply.copy source · line 202 · raw

@api:Api -> @r:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> Result<&1, &1, Err, Reply>

def reply source · line 206 · raw

@api:Api -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Result<&1, &1, Err, Reply>

A 2xx response body as a Reply.

def ev.from.pure source · line 218 · raw

@v:0xa138c0f6ea843d6536a9dbee24466900/pure.Ev -> Ev

def ev.text source · line 229 · raw

@+s:String -> Ev

def ev.doc source · line 232 · raw

@m:Maybe<&2, List<&2, Leaf>> -> List<&2, Leaf>

def ev.anthropic source · line 235 · raw

@+name:String -> @data:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Ev

def ev.openai source · line 238 · raw

@+s:String -> Ev

def ev source · line 242 · raw

@api:Api -> @e:0xa138c0f6ea843d6536a9dbee24466900/sse.Message -> Ev

What one SSE event of api means.

def ok source · line 247 · raw

@+s:U32 -> Bool

def again.status source · line 251 · raw

@+s:U32 -> Bool

Statuses a later try may clear: 408, 409, 429, and 5xx, which holds Anthropic's 529.

def again.err source · line 255 · raw

@+e:0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err -> Maybe<&2, String>

A refused connect or a timeout may clear.

def again.of source · line 264 · raw

@+status:U32 -> @+h:Map<&2, List<&2, String>> -> Maybe<&2, String>

def verdict source · line 268 · raw

@m:Maybe<&2, String> -> @settled:0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Verdict -> 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Verdict

Again when another try may help; otherwise settled, as Hairpin.judge would settle it.

def again source · line 276 · raw

@r:Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res> -> Pair(Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res>, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Verdict)

Hairpin's judge for every call.

def body.ok source · line 284 · raw

@good:Bool -> @+status:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>

def body.of source · line 292 · raw

@r:Result<&1, &1, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res> -> Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>

The 2xx body, or why there is none.

def url source · line 300 · raw

@api:Api -> @+base:String -> String

def new source · line 309 · raw

@+api:Api -> @base:String -> @headers:Map<&2, List<&2, String>> -> Client

def json source · line 312 · raw

@h:Map<&2, List<&2, String>> -> Map<&2, List<&2, String>>

def anthropic source · line 316 · raw

@key:String -> Client

base https://api.anthropic.com, 10 min steps, 2 retries.

def openai source · line 320 · raw

@key:String -> Client

base https://api.openai.com/v1, 10 min steps, 2 retries.

def base source · line 324 · raw

@c:Client -> @url:String -> Client

Another base URL, as for a provider that serves the same API.

def timeout source · line 333 · raw

@c:Client -> @+ms:U32 -> Client

def retry source · line 337 · raw

@c:Client -> @n:U32 -> Client

def close source · line 341 · raw

@c:Client -> IO(Unit)

def call.done source · line 345 · raw

@+api:Api -> @base:String -> @headers:Map<&2, List<&2, String>> -> @+ms:U32 -> @+n:U32 -> @x:Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Pair(0x14e48621ef66156b0eb652524b8594d4/retry.Budget, Result<&1, &1, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res>)) -> Pair(Client, Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

def call.budget source · line 350 · raw

@+api:Api -> @+base:String -> @+headers:Map<&2, List<&2, String>> -> @body:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> @y:Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, 0x14e48621ef66156b0eb652524b8594d4/retry.Budget) -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Pair(0x14e48621ef66156b0eb652524b8594d4/retry.Budget, Result<&1, &1, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res>)))

def call source · line 359 · raw

@c:Client -> @body:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Pair(Client, Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>))

POST body to the API with n retries on a budget of n + 1; the 2xx body comes back. These POSTs are safe to repeat, so Hairpin retries them as again judges.

def raw.got source · line 366 · raw

@b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> @m:Maybe<&1, 0x419ec39802735c4664960ab4b9d962e5/json.Val> -> Result<&1, &1, Err, 0x419ec39802735c4664960ab4b9d962e5/json.Val>

def raw.copy source · line 373 · raw

@r:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> Result<&1, &1, Err, 0x419ec39802735c4664960ab4b9d962e5/json.Val>

def raw.of source · line 377 · raw

@r:Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes> -> Result<&1, &1, Err, 0x419ec39802735c4664960ab4b9d962e5/json.Val>

def raw.done source · line 384 · raw

@x:Pair(Client, Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>) -> Pair(Client, Result<&1, &1, Err, 0x419ec39802735c4664960ab4b9d962e5/json.Val>)

def send.raw source · line 389 · raw

@c:Client -> @v:0x419ec39802735c4664960ab4b9d962e5/json.Val -> IO(Pair(Client, Result<&1, &1, Err, 0x419ec39802735c4664960ab4b9d962e5/json.Val>))

Any request body, as for tools or images, and the reply as JSON.

def send.of source · line 394 · raw

@r:Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes> -> @+api:Api -> Result<&1, &1, Err, Reply>

def send.done source · line 401 · raw

@+api:Api -> @x:Pair(Client, Result<&1, &1, Err, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>) -> Pair(Client, Result<&1, &1, Err, Reply>)

def send source · line 406 · raw

@c:Client -> @req:Req -> IO(Pair(Client, Result<&1, &1, Err, Reply>))

One whole reply.

def open.res source · line 417 · raw

@x:Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res) -> Pair(Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Verdict)

def open.judge source · line 422 · raw

@r:Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream> -> Pair(Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Verdict)

def drain source · line 430 · raw

@f:Nat -> @c:0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client -> @x:Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, Maybe<&1, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>>) -> @acc:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes))

A refused stream's error body, at most f more pieces; only a complete body returns its connection.

def start.error source · line 456 · raw

@+status:U32 -> @x:Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>)

def start.refused source · line 460 · raw

@+status:U32 -> @c:0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client -> @h:0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>))

def start.ok source · line 466 · raw

@good:Bool -> @+status:U32 -> @c:0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client -> @h:0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>))

def start.res source · line 473 · raw

@c:0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client -> @x:Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Res) -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>))

def start source · line 478 · raw

@c:0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client -> @r:Result<&1, &1, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream> -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>))

def stream.of source · line 485 · raw

@r:Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream> -> @+api:Api -> Result<&1, &1, Err, Stream>

def stream.result source · line 492 · raw

@+api:Api -> @base:String -> @headers:Map<&2, List<&2, String>> -> @+ms:U32 -> @+n:U32 -> @x:Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Result<&1, &1, Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>) -> Pair(Client, Result<&1, &1, Err, Stream>)

def stream.done source · line 497 · raw

@+api:Api -> @base:String -> @headers:Map<&2, List<&2, String>> -> @+ms:U32 -> @+n:U32 -> @x:Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Pair(0x14e48621ef66156b0eb652524b8594d4/retry.Budget, Result<&1, &1, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>)) -> IO(Pair(Client, Result<&1, &1, Err, Stream>))

def open.budget source · line 504 · raw

@+api:Api -> @+base:String -> @+headers:Map<&2, List<&2, String>> -> @body:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> @y:Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, 0x14e48621ef66156b0eb652524b8594d4/retry.Budget) -> IO(Pair(0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Client, Pair(0x14e48621ef66156b0eb652524b8594d4/retry.Budget, Result<&1, &1, 0x7ccafdbf09a65ba56ef818710d31b1d1/hairpin.Err, 0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream>)))

def stream.raw source · line 513 · raw

@c:Client -> @v:0x419ec39802735c4664960ab4b9d962e5/json.Val -> IO(Pair(Client, Result<&1, &1, Err, Stream>))

Any request body that asks for SSE, as for tools. The open retries as call does, on a budget of n + 1. A stream opens on the client's pool. Close it with stream.close to give its connection back.

def stream source · line 521 · raw

@c:Client -> @req:Req -> IO(Pair(Client, Result<&1, &1, Err, Stream>))

The reply as it is written: read it with next.

def stream.close source · line 526 · raw

@c:Client -> @s:Stream -> IO(Client)

Close a stream. A stream read to its end gives its connection to the client's pool.

def event.read source · line 538 · raw

@rd:0xa138c0f6ea843d6536a9dbee24466900/sse.Reader -> @x:Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, Maybe<&1, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>>) -> Rn

def event.loop source · line 551 · raw

@f:Nat -> @st:Rn -> IO(Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, Pair(0xa138c0f6ea843d6536a9dbee24466900/sse.Reader, Result<&1, &1, Err, Maybe<&1, 0xa138c0f6ea843d6536a9dbee24466900/sse.Message>>)))

f: pieces left to read before the stream counts as stalled.

def event.done source · line 574 · raw

@+api:Api -> @x:Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, Pair(0xa138c0f6ea843d6536a9dbee24466900/sse.Reader, Result<&1, &1, Err, Maybe<&1, 0xa138c0f6ea843d6536a9dbee24466900/sse.Message>>)) -> Pair(Stream, Result<&1, &1, Err, Maybe<&1, 0xa138c0f6ea843d6536a9dbee24466900/sse.Message>>)

def event source · line 579 · raw

@s:Stream -> IO(Pair(Stream, Result<&1, &1, Err, Maybe<&1, 0xa138c0f6ea843d6536a9dbee24466900/sse.Message>>))

The next SSE event, or None when the stream ends. An event the end cuts off is dropped.

def next.ev source · line 585 · raw

@r:Result<&1, &1, Err, Maybe<&1, 0xa138c0f6ea843d6536a9dbee24466900/sse.Message>> -> @+api:Api -> Ev

def next.of source · line 596 · raw

@x:Pair(Stream, Result<&1, &1, Err, Maybe<&1, 0xa138c0f6ea843d6536a9dbee24466900/sse.Message>>) -> Pair(Stream, Ev)

def next.loop source · line 602 · raw

@f:Nat -> @x:Pair(Stream, Ev) -> IO(Pair(Stream, Result<&1, &1, Err, Maybe<&2, String>>))

f: events left to skip.

def next source · line 622 · raw

@s:Stream -> IO(Pair(Stream, Result<&1, &1, Err, Maybe<&2, String>>))

The next piece of reply text, or None at the end.