@@ -146,8 +146,13 @@ def store_as_yaml(self, file_path: str) -> None:
146
146
Args:
147
147
file_path (str): The path where the schema configuration will be saved.
148
148
"""
149
+ # create a copy of the data and convert tuples to lists for YAML compatibility
150
+ data = self .model_dump ()
151
+ if data .get ('potential_schema' ):
152
+ data ['potential_schema' ] = [list (item ) for item in data ['potential_schema' ]]
153
+
149
154
with open (file_path , 'w' ) as f :
150
- yaml .dump (self . model_dump () , f , default_flow_style = False , sort_keys = False )
155
+ yaml .dump (data , f , default_flow_style = False , sort_keys = False )
151
156
152
157
@classmethod
153
158
def from_file (cls , file_path : Union [str , Path ]) -> Self :
@@ -347,18 +352,18 @@ def __init__(
347
352
self ._llm_params : dict [str , Any ] = llm_params or {}
348
353
349
354
@validate_call
350
- async def run (self , text : str , ** kwargs : Any ) -> SchemaConfig :
355
+ async def run (self , text : str , examples : str = "" , ** kwargs : Any ) -> SchemaConfig :
351
356
"""
352
357
Asynchronously extracts the schema from text and returns a SchemaConfig object.
353
358
354
359
Args:
355
360
text (str): the text from which the schema will be inferred.
356
-
361
+ examples (str): examples to guide schema extraction.
357
362
Returns:
358
363
SchemaConfig: A configured schema object, extracted automatically and
359
364
constructed asynchronously.
360
365
"""
361
- prompt : str = self ._prompt_template .format (text = text )
366
+ prompt : str = self ._prompt_template .format (text = text , examples = examples )
362
367
363
368
response = await self ._llm .invoke (prompt , ** self ._llm_params )
364
369
content : str = (
0 commit comments