~/bend-docscommunity

llm.bend relies on unsafe/foreign

raw source on the hub · import bend-kit-llm@0.19.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

11 imports
import Base
import ./sse.bend as Sse
import bend-kit-hairpin@0.19.0.0/hairpin.bend as Hairpin
import bend-kit-hairpin@0.19.0.0/pure.bend as HairpinPure
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 15 · raw

Data

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

type Role source · line 19 · raw

Data

type Msg source · line 23 · raw

Data

type Req source · line 27 · raw

Data

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

type Reply source · line 31 · raw

Data

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

type Err source · line 36 · 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 42 · raw

Type

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

type Leaf source · line 127 · raw

Data

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

type Ev source · line 213 · raw

Data

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

type Stream source · line 415 · raw

Type

type Rn source · line 535 · raw

Type

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

Definitions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

def str source · line 95 · raw

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

def kv source · line 98 · raw

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

def num source · line 101 · raw

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

def obj source · line 104 · raw

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

def when source · line 107 · 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 110 · raw

@r:Role -> String

def msg source · line 113 · raw

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

def msgs source · line 116 · raw

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

def sys source · line 119 · raw

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

def body source · line 123 · 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 130 · raw

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

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

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

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

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

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

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

def path source · line 158 · raw

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

def push.arr source · line 161 · 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 164 · 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 168 · 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 171 · raw

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

def doc source · line 176 · 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 180 · raw

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

The first value at path k, or "".

def count source · line 183 · raw

@s:String -> U32

def dots source · line 186 · raw

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

def block source · line 190 · raw

@+p:String -> Bool

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

def blocks source · line 194 · raw

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

The text blocks of an Anthropic message, joined.

def reply.of source · line 197 · raw

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

def reply.got source · line 200 · raw

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

def reply.copy source · line 203 · raw

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

def reply source · line 207 · 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 219 · raw

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

def ev.text source · line 230 · raw

@+s:String -> Ev

def ev.doc source · line 233 · raw

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

def ev.anthropic source · line 236 · raw

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

def ev.openai source · line 239 · raw

@+s:String -> Ev

def ev source · line 243 · raw

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

What one SSE event of api means.

def ok source · line 248 · raw

@+s:U32 -> Bool

def again.status source · line 252 · 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 256 · raw

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

A refused connect or a timeout may clear.

def again.of source · line 265 · raw

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

def verdict source · line 269 · raw

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

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

def again source · line 277 · raw

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

Hairpin's judge for every call.

def body.ok source · line 285 · raw

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

def body.of source · line 293 · raw

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

The 2xx body, or why there is none.

def url source · line 301 · raw

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

def new source · line 310 · raw

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

def json source · line 313 · raw

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

def anthropic source · line 317 · raw

@key:String -> Client

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

def openai source · line 321 · raw

@key:String -> Client

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

def base source · line 325 · raw

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

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

def timeout source · line 334 · raw

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

def retry source · line 338 · raw

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

def close source · line 342 · raw

@c:Client -> IO(Unit)

def call.done source · line 346 · raw

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

def call.budget source · line 351 · raw

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

def call source · line 360 · 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 367 · raw

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

def raw.copy source · line 374 · raw

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

def raw.of source · line 378 · raw

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

def raw.done source · line 385 · 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 390 · 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 395 · raw

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

def send.done source · line 402 · raw

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

def send source · line 407 · raw

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

One whole reply.

def open.res source · line 418 · raw

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

def open.judge source · line 423 · raw

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

def drain source · line 431 · raw

@f:Nat -> @c:0x335131bcb1e55013272f7f1ce4c9d71d/hairpin.Client -> @x:Pair(0x4d75a4c849d23a41c6b8dab4e9d823b1/http.Stream, Result<&1, &1, 0x4d75a4c849d23a41c6b8dab4e9d823b1/pure.Err, Maybe<&1, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>>) -> @acc:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Pair(0x335131bcb1e55013272f7f1ce4c9d71d/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 457 · raw

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

def start.refused source · line 461 · raw

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

def start.ok source · line 467 · raw

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

def start.res source · line 474 · raw

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

def start source · line 479 · raw

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

def stream.of source · line 486 · raw

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

def stream.result source · line 493 · raw

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

def stream.done source · line 498 · raw

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

def open.budget source · line 505 · raw

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

def stream.raw source · line 514 · 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 522 · 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 527 · 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 539 · raw

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

def event.loop source · line 552 · raw

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

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

def event.done source · line 575 · raw

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

def event source · line 580 · raw

@s:Stream -> IO(Pair(Stream, Result<&1, &1, Err, Maybe<&1, 0x63b164be3814d7c18657e45dc5830f17/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 586 · raw

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

def next.of source · line 597 · raw

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

def next.loop source · line 603 · 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 623 · raw

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

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