Skip to content

Commit ad1d990

Browse files
committed
🐛 FIX: Types Fix
1 parent c0d697d commit ad1d990

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
hooks:
1818
- id: black
1919
language_version: python3
20-
args: [--line-length=88]
20+
args: [.]
2121

2222
- repo: https://github.com/pycqa/isort
2323
rev: 5.13.2

langbase/helper.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
"""
2-
Helper utilities for the Langbase SDK.
3-
4-
This module provides utility functions for handling streaming responses,
5-
extracting content from chunks, and working with tool calls from streams.
6-
7-
"""
8-
91
import json
102
from typing import Any, Dict, Iterator, List, Literal, Optional, Union
113

12-
from .streaming import TypedStreamProcessor
134
from .types import ToolCall
145

156
# Type aliases to match TypeScript version
@@ -129,7 +120,10 @@ def parse_chunk(chunk_data: Union[bytes, str]) -> Optional[ChunkStream]:
129120
return None
130121

131122
# Handle SSE format - remove "data: " prefix if present
132-
json_str = chunk_str[6:] if chunk_str.startswith("data: ") else chunk_str
123+
if chunk_str.startswith("data: "):
124+
json_str = chunk_str[6:] # Remove "data: " prefix
125+
else:
126+
json_str = chunk_str
133127

134128
# Skip if it's just whitespace after removing prefix
135129
if not json_str.strip():
@@ -439,6 +433,8 @@ def get_typed_runner(
439433
Returns:
440434
TypedStreamProcessor instance with event-based handling
441435
"""
436+
from .streaming import TypedStreamProcessor
437+
442438
# Extract stream and thread_id
443439
thread_id = None
444440

0 commit comments

Comments
 (0)