Skip to content

Commit 138d7cd

Browse files
committed
chore: update graphai docs
1 parent 32b225b commit 138d7cd

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,4 @@
246246
"youtube": "https://www.youtube.com/@jamesbriggs"
247247
}
248248
}
249-
}
249+
}

graphai/client-reference/callback.mdx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,36 @@ sidebarTitle: callback
33
title: graphai.callback
44
---
55

6+
## GraphEvent Objects
7+
8+
```python
9+
@dataclass
10+
class GraphEvent()
11+
```
12+
13+
A graph event emitted for specific graph events such as start node or end node,
14+
15+
and used by the callback to emit user-defined events.
16+
17+
**Arguments**:
18+
19+
- `type` (`GraphEventType`): The type of event, can be start_node, end_node, or callback.
20+
- `identifier` (`str`): The identifier of the event, this is set typically by a callback
21+
handler and can be used to distinguish between different events. For example, a
22+
conversation/session ID could be used.
23+
- `token` (`str | None`): The token associated with the event, such as LLM streamed output.
24+
- `params` (`dict[str, Any] | None`): The parameters associated with the event, such as tool call parameters
25+
or event metadata.
26+
627
## Callback Objects
728

829
```python
930
class Callback()
1031
```
1132

33+
The original callback handler class. Outputs a stream of structured text
34+
tokens. It is recommended to use the newer `EventCallback` handler instead.
35+
1236
#### aiter
1337

1438
```python
@@ -44,3 +68,47 @@ async def close()
4468
Close the stream and prevent further tokens from being added.
4569
This will send an END token and set the done flag to True.
4670

71+
## EventCallback Objects
72+
73+
```python
74+
class EventCallback(Callback)
75+
```
76+
77+
The event callback handler class. Outputs a stream of structured text
78+
tokens. It is recommended to use the newer `EventCallback` handler instead.
79+
80+
#### aiter
81+
82+
```python
83+
async def aiter() -> AsyncIterator[GraphEvent]
84+
```
85+
86+
Used by receiver to get the tokens from the stream queue. Creates
87+
a generator that yields tokens from the queue until the END token is
88+
received.
89+
90+
#### start\_node
91+
92+
```python
93+
async def start_node(node_name: str, active: bool = True)
94+
```
95+
96+
Starts a new node and emits the start token.
97+
98+
#### end\_node
99+
100+
```python
101+
async def end_node(node_name: str)
102+
```
103+
104+
Emits the end token for the current node.
105+
106+
#### close
107+
108+
```python
109+
async def close()
110+
```
111+
112+
Close the stream and prevent further tokens from being added.
113+
This will send an END token and set the done flag to True.
114+

graphai/user-guide/release-notes.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
See below for all notable changes to the GraphAI library.
22

3+
## [0.0.9] - TBD
4+
5+
### Added
6+
- Enhanced `FunctionSchema.from_pydantic()` method with full Pydantic v2 support
7+
- Correctly extracts field types, descriptions, and default values from Pydantic models
8+
- Handles `Optional` types and complex type annotations
9+
- Properly identifies required vs optional fields using `PydanticUndefined`
10+
- New `to_openai()` method on FunctionSchema for OpenAI API format support
11+
- Supports both `completions` and `responses` API endpoints
12+
- Export schemas for either nested or flat format structures
13+
- New `EventCallback` class for object-based callback handling
14+
- Outputs structured `GraphEvent` objects instead of formatted strings
15+
- Provides `GraphEventType` enum for event type identification
16+
- Better structured data with `type`, `identifier`, `token`, and `params` fields
17+
- Maintains backward compatibility with existing callback interface
18+
- Comprehensive graph compilation validation
19+
- Stricter validation of node connections and dependencies
20+
- Better error messages for graph construction issues
21+
- Cycle detection with clear `GraphCompileError` reporting
22+
23+
### Changed
24+
- Graph compilation now validates execution order at compile time
25+
- Graphs with cycles now raise `GraphCompileError` during compilation to ensure predictable execution order
26+
27+
### Deprecated
28+
- `Callback` class is deprecated and will be removed in v0.1.0 - use `EventCallback` instead
29+
- `special_token_format` and `token_format` parameters in `EventCallback` exist for backwards compatibility but are deprecated and will be removed in v0.1.0
30+
31+
### Fixed
32+
- Added Python 3.10 compatibility for `StrEnum` with fallback implementation
33+
- Fixed type annotation issues with `default_factory` in Pydantic field definitions
34+
- Improved type extraction for complex Pydantic field types including `Union` and `Optional`
35+
336
## [0.0.8] - 2025-08-16
437

538
### Added

0 commit comments

Comments
 (0)