https://www.boundaryml.com logo
🟡 Extracting text outside the parsed object using...
# questions
c
Hi folks, is it possible to get the text outside of the parsed object? (I am using b.parseStream) For example:
Copy code
Hello, there.
{
 "name": "anna"
}
How are you doing today?
Getting both "Hello, there.\nHow are you doing today?" and
{ name: "anna"}
a
I think not, you'd have to split the output in different parts, something like:
Copy code
Class Greeting {
    hello_message string
    user User
    greeting_message string
And then you can get each individual message
v
You can always use the collector!
a
Yeah you can get the raw full response with the [collector](https://docs.boundaryml.com/guide/baml-advanced/collector-track-tokens) but you still have to parse the text you want manually
c
Thanks! I will try collector out. I have also been getting errors like these while using parseStream, however the baml works through the vscode extension. This seems to only happen with parseStream and not parse
Copy code
[error] Failed to parse BAML stream for NARRATIVE_EVALUATION: BamlError: Failed to coerce value: <root>: Failed while parsing required fields: missing=0, unparsed=6
  - <root>: Failed to parse field sceneCharacters: sceneCharacters: Internal error: Class SceneCharacters not found
    - sceneCharacters: Internal error: Class SceneCharacters not found
  - <root>: Failed to parse field eventAnalysis: eventAnalysis: Internal error: Class EventAnalysis not found
    - eventAnalysis: Internal error: Class EventAnalysis not found
I found the issue, when using @@stream.done with nested class, you have to add @@stream.done to all child as well, otherwise I end up with the internal error above
v
oh thats a bug!
thanks for sharing
a
@ChadGPT can you give me a repro of that bug? By add stream done to nested classes , you mean this:
Copy code
ts
class Foo {
  bar Bar
  @@stream.done
}

class Bar {
  a int
  b string
  @@strea.done // If I removed this one it fails?
}
I can't repro it