xg15 5 hours ago

Doesn't it do exactly that?

> As a consequence of 1 and 5, we only add a property to an object once we have the entire key and enough of the value to know that value's type.

  • 0x6c6f6c an hour ago

    Their example in the README is extremely misleading then. It indicates your stream output is

    name: A name: Al name: Ale name: Alex

    Which would suggest you are getting unfinished strings out in the stream.

    • __jonas 3 minutes ago

      How is it misleading? It shows that it gives back unfinished values but finished keys.

rictic 7 hours ago

Cumulative is a good term too. I come from the browser world where it's typically called incremental parsing, e.g. when web browsers parse and render HTML as it streams in over the wire. I was doing the same thing with JSON from LLMs.

simonw 8 hours ago

If you're building a UI that renders output from a streaming LLM you might get back something which looks like this:

  {"role": "assistant", "text": "Here's that Python code you aske
Incomplete parsing with incomplete strings is still useful in order to render that to your end user while it's still streaming in.
  • trevor-e 6 hours ago

    In this example the value is incomplete, not the key.

  • cozzyd 7 hours ago

    incomplete strings could be fun in certain cases

    {"cleanup_cmd":"rm -rf /home/foo/.tmp" }

    • stronglikedan 6 hours ago

      If any part of that value actually made it, unchecked, to execution, then you have bigger problems than partial JSON keys/values.

    • rictic 7 hours ago

      Yeah, another fun one is string enums. Could tread "DeleteIfEmpty" as "Delete".

      • Waterluvian 7 hours ago

        I imagine if you reason about incomplete strings as a sort of “unparsed data” where you might store or transport or render it raw (like a string version of printing response.data instead of response.json()), but not act on it (compare, concat, etc), it’s a reasonably safe model?

        I’m imagining it in my mental model as being typed “unknown”. Anything that prevents accidental use as if it were a whole string… I imagine a more complex type with an “isComplete” flag of sorts would be more powerful but a bit of a blunderbuss.