@@ -110,7 +110,7 @@ def schema_config(
110
110
valid_entities : list [SchemaEntity ],
111
111
valid_relations : list [SchemaRelation ],
112
112
potential_schema : list [tuple [str , str , str ]],
113
- ):
113
+ ) -> SchemaConfig :
114
114
return schema_builder .create_schema_model (
115
115
valid_entities , valid_relations , potential_schema
116
116
)
@@ -445,14 +445,14 @@ def test_create_schema_model_missing_relations(
445
445
446
446
447
447
@pytest .fixture
448
- def mock_llm ():
448
+ def mock_llm () -> AsyncMock :
449
449
mock = AsyncMock ()
450
450
mock .invoke = AsyncMock ()
451
451
return mock
452
452
453
453
454
454
@pytest .fixture
455
- def valid_schema_json ():
455
+ def valid_schema_json () -> str :
456
456
return """
457
457
{
458
458
"entities": [
@@ -485,7 +485,7 @@ def valid_schema_json():
485
485
486
486
487
487
@pytest .fixture
488
- def invalid_schema_json ():
488
+ def invalid_schema_json () -> str :
489
489
return """
490
490
{
491
491
"entities": [
@@ -499,14 +499,14 @@ def invalid_schema_json():
499
499
500
500
501
501
@pytest .fixture
502
- def schema_from_text (mock_llm ) :
502
+ def schema_from_text (mock_llm : AsyncMock ) -> SchemaFromText :
503
503
return SchemaFromText (llm = mock_llm )
504
504
505
505
506
506
@pytest .mark .asyncio
507
507
async def test_schema_from_text_run_valid_response (
508
- schema_from_text , mock_llm , valid_schema_json
509
- ):
508
+ schema_from_text : SchemaFromText , mock_llm : AsyncMock , valid_schema_json : str
509
+ ) -> None :
510
510
# configure the mock LLM to return a valid schema JSON
511
511
mock_llm .invoke .return_value = valid_schema_json
512
512
@@ -534,8 +534,8 @@ async def test_schema_from_text_run_valid_response(
534
534
535
535
@pytest .mark .asyncio
536
536
async def test_schema_from_text_run_invalid_json (
537
- schema_from_text , mock_llm , invalid_schema_json
538
- ):
537
+ schema_from_text : SchemaFromText , mock_llm : AsyncMock , invalid_schema_json : str
538
+ ) -> None :
539
539
# configure the mock LLM to return invalid JSON
540
540
mock_llm .invoke .return_value = invalid_schema_json
541
541
@@ -547,7 +547,9 @@ async def test_schema_from_text_run_invalid_json(
547
547
548
548
549
549
@pytest .mark .asyncio
550
- async def test_schema_from_text_custom_template (mock_llm , valid_schema_json ):
550
+ async def test_schema_from_text_custom_template (
551
+ mock_llm : AsyncMock , valid_schema_json : str
552
+ ) -> None :
551
553
# create a custom template
552
554
custom_prompt = "This is a custom prompt with text: {text}"
553
555
custom_template = PromptTemplate (template = custom_prompt , expected_inputs = ["text" ])
@@ -567,7 +569,9 @@ async def test_schema_from_text_custom_template(mock_llm, valid_schema_json):
567
569
568
570
569
571
@pytest .mark .asyncio
570
- async def test_schema_from_text_llm_params (mock_llm , valid_schema_json ):
572
+ async def test_schema_from_text_llm_params (
573
+ mock_llm : AsyncMock , valid_schema_json : str
574
+ ) -> None :
571
575
# configure custom LLM parameters
572
576
llm_params = {"temperature" : 0.1 , "max_tokens" : 500 }
573
577
@@ -588,7 +592,7 @@ async def test_schema_from_text_llm_params(mock_llm, valid_schema_json):
588
592
589
593
590
594
@pytest .mark .asyncio
591
- async def test_schema_config_store_as_json (schema_config ) :
595
+ async def test_schema_config_store_as_json (schema_config : SchemaConfig ) -> None :
592
596
with tempfile .TemporaryDirectory () as temp_dir :
593
597
# create file path
594
598
json_path = os .path .join (temp_dir , "schema.json" )
@@ -614,7 +618,7 @@ async def test_schema_config_store_as_json(schema_config):
614
618
615
619
616
620
@pytest .mark .asyncio
617
- async def test_schema_config_store_as_yaml (schema_config ) :
621
+ async def test_schema_config_store_as_yaml (schema_config : SchemaConfig ) -> None :
618
622
with tempfile .TemporaryDirectory () as temp_dir :
619
623
# Create file path
620
624
yaml_path = os .path .join (temp_dir , "schema.yaml" )
@@ -640,7 +644,7 @@ async def test_schema_config_store_as_yaml(schema_config):
640
644
641
645
642
646
@pytest .mark .asyncio
643
- async def test_schema_config_from_file (schema_config ) :
647
+ async def test_schema_config_from_file (schema_config : SchemaConfig ) -> None :
644
648
with tempfile .TemporaryDirectory () as temp_dir :
645
649
# create file paths with different extensions
646
650
json_path = os .path .join (temp_dir , "schema.json" )
0 commit comments