add independent openllm and fireworks config fields, add llm output postprecess plugin

This commit is contained in:
better629 2023-11-23 01:46:14 +08:00
parent fc5c01e219
commit 642335317b
10 changed files with 243 additions and 29 deletions

View file

@ -77,11 +77,11 @@ def test_required_key_pair_missing():
raw_output = '''[CONTENT]
{
"a": "b"
"key": "value"
]'''
target_output = '''[CONTENT]
{
"a": "b"
"key": "value"
]
[/CONTENT]'''
@ -92,17 +92,15 @@ def test_required_key_pair_missing():
raw_output = '''[CONTENT] tag
[CONTENT]
{
"a": "b"
"key": "value"
}
xxx
'''
target_output = '''[CONTENT] tag
[CONTENT]
target_output = '''[CONTENT]
{
"a": "b"
"key": "value"
}
[/CONTENT]
'''
[/CONTENT]'''
output = repair_llm_raw_output(output=raw_output,
req_keys=["[/CONTENT]"])
assert output == target_output
@ -117,6 +115,22 @@ def test_repair_json_format():
repair_type=RepairType.JSON)
assert output == target_output
raw_output = "[{ xxx }"
target_output = "{ xxx }"
output = repair_llm_raw_output(output=raw_output,
req_keys=[None],
repair_type=RepairType.JSON)
assert output == target_output
raw_output = "{ xxx ]"
target_output = "{ xxx }"
output = repair_llm_raw_output(output=raw_output,
req_keys=[None],
repair_type=RepairType.JSON)
assert output == target_output
def test_retry_parse_json_text():
invalid_json_text = """{
@ -130,7 +144,7 @@ def test_retry_parse_json_text():
"Competitive Quadrant Chart": "quadrantChart\n\ttitle Reach and engagement of campaigns\n\t\tx-axis",
"Requirement Analysis": "The requirements are clear and well-defined"
}
output = retry_parse_json_text(invalid_json_text)
output = retry_parse_json_text(output=invalid_json_text)
assert output == target_json
invalid_json_text = """{
@ -144,7 +158,7 @@ def test_retry_parse_json_text():
"Competitive Quadrant Chart": "quadrantChart\n\ttitle Reach and engagement of campaigns\n\t\tx-axis",
"Requirement Analysis": "The requirements are clear and well-defined"
}
output = retry_parse_json_text(invalid_json_text)
output = retry_parse_json_text(output=invalid_json_text)
assert output == target_json