mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
style: auto-format ranker and test_markdown_utils
This commit is contained in:
parent
85a1c8b183
commit
16e043883a
2 changed files with 8 additions and 9 deletions
|
|
@ -385,13 +385,9 @@ async def rank_optimizations( # noqa: D417
|
|||
if json_response is not None:
|
||||
logging.info("Successfully parsed JSON response")
|
||||
ranking = (
|
||||
_scores_to_ranking(json_response.scores)
|
||||
if json_response.scores is not None
|
||||
else json_response.ranking
|
||||
)
|
||||
return RankResponseSchema(
|
||||
ranking=ranking, explanation=json_response.explanation, scores=json_response.scores
|
||||
_scores_to_ranking(json_response.scores) if json_response.scores is not None else json_response.ranking
|
||||
)
|
||||
return RankResponseSchema(ranking=ranking, explanation=json_response.explanation, scores=json_response.scores)
|
||||
|
||||
# Fall back to regex parsing (legacy XML-tag format)
|
||||
logging.info("JSON parsing failed, falling back to regex")
|
||||
|
|
|
|||
|
|
@ -185,14 +185,17 @@ def test_extract_code_block_nested_code_fence_in_triple_quote() -> None:
|
|||
# LLM embeds function definition in a triple-quoted string containing ```
|
||||
text = '```python\nimport pytest\n_source = """```python:file.py\ndef foo(): pass\n```"""\ndef test_foo():\n assert True\n```'
|
||||
result = extract_code_block(text)
|
||||
assert result == 'import pytest\n_source = """```python:file.py\ndef foo(): pass\n```"""\ndef test_foo():\n assert True'
|
||||
assert (
|
||||
result
|
||||
== 'import pytest\n_source = """```python:file.py\ndef foo(): pass\n```"""\ndef test_foo():\n assert True'
|
||||
)
|
||||
|
||||
|
||||
def test_extract_code_block_nested_code_fence_block() -> None:
|
||||
# LLM nests a ```python:filepath block inside the main block
|
||||
text = '```python\nimport pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True\n```'
|
||||
text = "```python\nimport pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True\n```"
|
||||
result = extract_code_block(text)
|
||||
assert result == 'import pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True'
|
||||
assert result == "import pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True"
|
||||
|
||||
|
||||
def test_extract_all_code_single_block() -> None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue