mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-14 15:25:17 +02:00
add independent openllm and fireworks config fields, add llm output postprecess plugin
This commit is contained in:
parent
fc5c01e219
commit
642335317b
10 changed files with 243 additions and 29 deletions
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue