Skip to content

Commit c35437d

Browse files
authored
fix: documentation inconsistencies (#6)
* Fix model name inconsistency in documentation * Fix callback event documentation inaccuracies Correct the documentation to accurately reflect which callback events are supported by each streaming type: - Object: on_start, on_complete, on_update - List: on_start, on_complete, on_append - String: on_start, on_complete, on_append - Atom: on_start, on_complete Previously, documentation incorrectly suggested all types support on_append, on_update, and on_complete uniformly. * fix: preserve the original sentence
1 parent b2fc901 commit c35437d

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

docs/api/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The parser module contains streaming-aware data types and the core parser for pr
1616

1717
### Key Features
1818

19-
- **Event Callbacks**: All streaming types support `on_start`, `on_append`, and `on_complete` callbacks
19+
- **Event Callbacks**: All streaming types support `on_start` and `on_complete` callbacks. Additionally, `Object` supports `on_update`, while `List` and `String` support `on_append`
2020
- **Type Safety**: Full type hints and generic support for compile-time checking
2121
- **Pydantic Integration**: Convert streaming models to Pydantic models via `to_pydantic()`
2222

docs/api/parser.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ response_format = BlogPost.to_pydantic()
117117

118118
client = openai.OpenAI()
119119
with client.chat.completions.stream(
120-
model="gpt-4o-mini",
120+
model="gpt-5-mini",
121121
messages=[{"role": "user", "content": "Write a blog post"}],
122122
response_format=response_format,
123123
) as stream:
@@ -130,7 +130,7 @@ with client.chat.completions.stream(
130130

131131
## Event System
132132

133-
All streaming types support three main events:
133+
All streaming types support common events, with type-specific additional events:
134134

135135
### on_start()
136136
Called when streaming begins for a value:
@@ -142,12 +142,25 @@ def on_title_start():
142142
```
143143

144144
### on_append()
145-
Called as new data is appended:
145+
Called as new data is appended (supported by `String` and `List` types):
146146

147147
```python
148-
@response.content.on_append
148+
@response.content.on_append # String type
149149
def on_content_chunk(chunk: str):
150150
print(f"New content: {chunk}")
151+
152+
@response.items.on_append # List type
153+
def on_item_append(item: ld.String, index: int):
154+
print(f"New item at index {index}")
155+
```
156+
157+
### on_update()
158+
Called when an object is updated (supported by `Object` type only):
159+
160+
```python
161+
@response.on_update # Object type
162+
def on_object_update(data: dict):
163+
print(f"Object updated: {data}")
151164
```
152165

153166
### on_complete()

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LangDiff provides intelligent partial parsing with granular, type-safe events as
1010

1111
### Streaming Parsing
1212
- Define schemas for streaming structured outputs using Pydantic-style models
13-
- Receive granular, type-safe callbacks (`on_append`, `on_update`, `on_complete`) as tokens stream in
13+
- Receive granular, type-safe callbacks (`on_append`, `on_update`, `on_complete`) as tokens stream in.
1414
- Derive Pydantic models from LangDiff models for seamless interop with existing libraries and SDKs like OpenAI SDK
1515

1616
### Change Tracking
@@ -69,7 +69,7 @@ def on_section_append(section: ld.String, index: int):
6969
# Stream from OpenAI
7070
client = openai.OpenAI()
7171
with client.chat.completions.stream(
72-
model="gpt-4o-mini",
72+
model="gpt-5-mini",
7373
messages=[{"role": "user", "content": "Write a short article about Python"}],
7474
response_format=ArticleResponse.to_pydantic(),
7575
) as stream:

0 commit comments

Comments
 (0)