Skip to content

Commit dcd68e4

Browse files
committed
fix: fix create record text splitter
1 parent a5b8b47 commit dcd68e4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

taskingai/client/models/schemas/record_create_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ class RecordCreateRequest(BaseModel):
2525
url: Optional[str] = Field(None, min_length=1, max_length=2048)
2626
title: str = Field("", min_length=0, max_length=256)
2727
content: Optional[str] = Field(None, min_length=1, max_length=32768)
28-
text_splitter: TextSplitter = Field(...)
28+
text_splitter: Optional[TextSplitter] = Field(None)
2929
metadata: Dict[str, str] = Field({}, min_length=0, max_length=16)

taskingai/retrieval/record.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def create_record(
137137
collection_id: str,
138138
*,
139139
type: Union[RecordType, str],
140-
text_splitter: Union[TextSplitter, Dict[str, Any]],
140+
text_splitter: Optional[Union[TextSplitter, Dict[str, Any]]] = None,
141141
title: Optional[str] = None,
142142
content: Optional[str] = None,
143143
file_id: Optional[str] = None,
@@ -158,7 +158,8 @@ def create_record(
158158
:return: The created record object.
159159
"""
160160
type = _validate_record_type(type, content, file_id, url)
161-
text_splitter = text_splitter if isinstance(text_splitter, TextSplitter) else TextSplitter(**text_splitter)
161+
if text_splitter:
162+
text_splitter = text_splitter if isinstance(text_splitter, TextSplitter) else TextSplitter(**text_splitter)
162163

163164
body = RecordCreateRequest(
164165
title=title or "",
@@ -177,7 +178,7 @@ async def a_create_record(
177178
collection_id: str,
178179
*,
179180
type: Union[RecordType, str],
180-
text_splitter: Union[TextSplitter, Dict[str, Any]],
181+
text_splitter: Optional[Union[TextSplitter, Dict[str, Any]]] = None,
181182
title: Optional[str] = None,
182183
content: Optional[str] = None,
183184
file_id: Optional[str] = None,
@@ -199,7 +200,8 @@ async def a_create_record(
199200
"""
200201

201202
type = _validate_record_type(type, content, file_id, url)
202-
text_splitter = text_splitter if isinstance(text_splitter, TextSplitter) else TextSplitter(**text_splitter)
203+
if text_splitter:
204+
text_splitter = text_splitter if isinstance(text_splitter, TextSplitter) else TextSplitter(**text_splitter)
203205

204206
body = RecordCreateRequest(
205207
title=title or "",

0 commit comments

Comments
 (0)