Repository navigation
Commit 786c303
authored
[feat] Add experiemental support for accessing collector prior to first streamed value in go (#2146)
We now support streaming out thinking tokens in go prior to streaming
out parsed chunks.
```
$> cd engine/generators/languages/go/generated_tests/sample
$> go test -run TestOnTick
2025-07-16T01:22:47.374 [BAML INFO] BAML (v0.201.0) loaded
Tick: 1 chunks
Accumulated: 0
--------------------------------
Tick: 2 chunks
Accumulated: 0
--------------------------------
Tick: 3 chunks
Accumulated: 0
--------------------------------
Tick: 4 chunks
Accumulated: 1
--------------------------------
Tick: 5 chunks
Accumulated: 36
--------------------------------
Tick: 6 chunks
Accumulated: 62
--------------------------------
Tick: 7 chunks
Accumulated: 103
--------------------------------
Tick: 8 chunks
Accumulated: 123
--------------------------------
Tick: 9 chunks
Accumulated: 142
--------------------------------
Tick: 10 chunks
Accumulated: 157
--------------------------------
Tick: 11 chunks
Accumulated: 180
--------------------------------
Tick: 12 chunks
Accumulated: 211
--------------------------------
Tick: 13 chunks
Accumulated: 240
--------------------------------
Tick: 14 chunks
Accumulated: 260
--------------------------------
Tick: 15 chunks
Accumulated: 279
--------------------------------
Tick: 16 chunks
Accumulated: 295
--------------------------------
Tick: 17 chunks
Accumulated: 312
--------------------------------
Tick: 18 chunks
Accumulated: 354
--------------------------------
Tick: 19 chunks
Accumulated: 387
--------------------------------
Tick: 20 chunks
Accumulated: 427
--------------------------------
Tick: 21 chunks
Accumulated: 453
--------------------------------
Tick: 22 chunks
Accumulated: 454
--------------------------------
Tick: 23 chunks
Accumulated: 454
--------------------------------
Tick: 24 chunks
Accumulated: 454
--------------------------------
Tick: 25 chunks
Accumulated: 454
--------------------------------
Tick: 26 chunks
Accumulated: 454
--------------------------------
Tick: 27 chunks
Accumulated: 454
--------------------------------
Tick: 28 chunks
Accumulated: 454
--------------------------------
Tick: 29 chunks
Accumulated: 454
--------------------------------
Tick: 30 chunks
Accumulated: 454
--------------------------------
Tick: 31 chunks
Accumulated: 454
--------------------------------
Tick: 32 chunks
Accumulated: 454
--------------------------------
Tick: 33 chunks
Accumulated: 454
--------------------------------
Tick: 34 chunks
Accumulated: 454
--------------------------------
Tick: 35 chunks
Accumulated: 454
--------------------------------
Tick: 36 chunks
Accumulated: 454
--------------------------------
Tick: 37 chunks
Accumulated: 454
--------------------------------
Tick: 38 chunks
Accumulated: 454
--------------------------------
Tick: 39 chunks
Accumulated: 454
--------------------------------
Tick: 40 chunks
Accumulated: 454
--------------------------------
Tick: 41 chunks
Accumulated: 454
--------------------------------
Tick: 42 chunks
Accumulated: 454
--------------------------------
Tick: 43 chunks
Accumulated: 454
--------------------------------
Tick: 44 chunks
Accumulated: 454
--------------------------------
Tick: 45 chunks
Accumulated: 454
--------------------------------
Tick: 46 chunks
Accumulated: 454
--------------------------------
Tick: 47 chunks
Accumulated: 454
--------------------------------
Tick: 48 chunks
Accumulated: 454
--------------------------------
Tick: 49 chunks
Accumulated: 454
--------------------------------
Tick: 50 chunks
Accumulated: 454
--------------------------------
Tick: 51 chunks
Accumulated: 454
--------------------------------
Tick: 52 chunks
Accumulated: 454
--------------------------------
2025-07-16T01:22:54.638 [BAML INFO] Function Foo:
Client: Thinking (claude-sonnet-4-20250514) - 7237ms. StopReason: end_turn. Tokens(in/out): 145/358
---PROMPT---
user: Fill out this data model with some examples.
Answer in JSON using any of these schemas:
{
type: "example_2",
item: {
type: "example_1",
a: int,
b: string,
},
element: string,
element2: string,
} or {
type: "example_1",
a: int,
b: string,
}
use 8192 somewhere in the data model
---LLM REPLY---
Here are examples using both schemas:
```json
{
"type": "example_2",
"item": {
"type": "example_1",
"a": 8192,
"b": "buffer_size"
},
"element": "memory_allocation",
"element2": "high_performance_mode"
}
```
```json
{
"type": "example_1",
"a": 8192,
"b": "bytes_per_block"
}
```
```json
{
"type": "example_2",
"item": {
"type": "example_1",
"a": 42,
"b": "processing_threads"
},
"element": "cache_size_8192",
"element2": "optimization_enabled"
}
```
---Parsed Response (class Example2)---
{
"type": "example_2",
"item": {
"type": "example_1",
"a": 8192,
"b": "buffer_size"
},
"element": "memory_allocation",
"element2": "high_performance_mode"
}
Tick: 1 chunks
Accumulated: 0
--------------------------------
Tick: 2 chunks
Accumulated: 0
--------------------------------
Tick: 3 chunks
Accumulated: 0
--------------------------------
Tick: 4 chunks
Accumulated: 1
--------------------------------
Tick: 5 chunks
Accumulated: 36
--------------------------------
Tick: 6 chunks
Accumulated: 84
--------------------------------
Tick: 7 chunks
Accumulated: 127
--------------------------------
Tick: 8 chunks
Accumulated: 160
--------------------------------
Tick: 9 chunks
Accumulated: 200
--------------------------------
Tick: 10 chunks
Accumulated: 244
--------------------------------
Tick: 11 chunks
Accumulated: 275
--------------------------------
Tick: 12 chunks
Accumulated: 308
--------------------------------
Tick: 13 chunks
Accumulated: 342
--------------------------------
Tick: 14 chunks
Accumulated: 400
--------------------------------
^[[ATick: 15 chunks
Accumulated: 438
--------------------------------
Tick: 16 chunks
Accumulated: 464
--------------------------------
Tick: 17 chunks
Accumulated: 487
--------------------------------
Tick: 18 chunks
Accumulated: 527
--------------------------------
Tick: 19 chunks
Accumulated: 557
--------------------------------
Tick: 20 chunks
Accumulated: 585
--------------------------------
Tick: 21 chunks
Accumulated: 585
--------------------------------
Tick: 22 chunks
Accumulated: 585
--------------------------------
Tick: 23 chunks
Accumulated: 585
--------------------------------
Tick: 24 chunks
Accumulated: 585
--------------------------------
Tick: 25 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x140003b2de0}
Tick: 26 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000424150}
Tick: 27 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x1400035b5f0}
Tick: 28 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000424540}
Tick: 29 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000306360}
Tick: 30 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000424510}
Tick: 31 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000307f20}
Tick: 32 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x1400021f2c0}
Tick: 33 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000239080}
Tick: 34 chunks
Accumulated: 585
--------------------------------
Stream: &{variant:Example2 variant_Example:<nil> variant_Example2:0x14000244f00}
2025-07-16T01:23:01.230 [BAML INFO] Function Foo:
Client: Thinking (claude-sonnet-4-20250514) - 6578ms. StopReason: end_turn. Tokens(in/out): 145/280
---PROMPT---
user: Fill out this data model with some examples.
Answer in JSON using any of these schemas:
{
type: "example_2",
item: {
type: "example_1",
a: int,
b: string,
},
element: string,
element2: string,
} or {
type: "example_1",
a: int,
b: string,
}
use 8192 somewhere in the data model
---LLM REPLY---
```json
{
"type": "example_2",
"item": {
"type": "example_1",
"a": 8192,
"b": "buffer_size_configuration"
},
"element": "memory_management",
"element2": "system_optimization"
}
```
---Parsed Response (class Example2)---
{
"type": "example_2",
"item": {
"type": "example_1",
"a": 8192,
"b": "buffer_size_configuration"
},
"element": "memory_management",
"element2": "system_optimization"
}
final &{Example2 <nil> 0x1400023d4a0}
PASS
ok sample 14.069s
```1 parent de024cf commit 786c303
88 files changed
Lines changed: 9434 additions & 3105 deletions
File tree
- engine
- baml-runtime/src
- cli/serve
- internal/llm_client/orchestrator
- tracingv2/storage
- types
- generators
- data/sample
- baml_src
- go
- languages
- go
- generated_tests
- array_types/baml_client
- asserts/baml_client
- classes/baml_client
- edge_cases/baml_client
- enums/baml_client
- literal_types/baml_client
- map_types/baml_client
- mixed_complex_types/baml_client
- nested_structures/baml_client
- optional_nullable/baml_client
- primitive_types/baml_client
- recursive_types/baml_client
- sample/baml_client
- stream_types
- types
- semantic_streaming/baml_client
- union_types_extended/baml_client
- unions/baml_client
- src/_templates
- python/generated_tests/sample/baml_client
- typescript/generated_tests/sample/baml_client
- language_client_cffi/src
- language_client_go
- baml_go
- raw_objects
- serde
- include
- pkg
- language_client_python/src/types
- language_client_ruby/ext/ruby_ffi/src
- language_client_typescript/src/types
- integ-tests/go/baml_client
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| 451 | + | |
451 | 452 | | |
452 | 453 | | |
453 | 454 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
517 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
518 | 525 | | |
519 | 526 | | |
520 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | 251 | | |
253 | 252 | | |
254 | 253 | | |
| |||
370 | 369 | | |
371 | 370 | | |
372 | 371 | | |
373 | | - | |
| 372 | + | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | | - | |
| 84 | + | |
83 | 85 | | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
| |||
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
| 121 | + | |
117 | 122 | | |
118 | 123 | | |
119 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
15 | 29 | | |
16 | | - | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
15 | 113 | | |
16 | 114 | | |
17 | 115 | | |
| |||
0 commit comments