Skip to content

Commit cd1dee8

Browse files
committed
style(ai): ruff-format runner.py and test_record_cassette_format.py
CI runs 'ruff format --check .' repo-wide; these two files (carried in from #199) were unformatted and failed the check.
1 parent 3659e42 commit cd1dee8

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

fastapi_startkit/src/fastapi_startkit/ai/runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def _record_ai_message(
5353
tool_calls = list(getattr(message, "tool_calls", None) or [])
5454
uses = recording.uses_from_usage_metadata(getattr(message, "usage_metadata", None))
5555
self._transcript.append(
56-
recording.ai(content=content, tool_calls=tool_calls, uses=uses, response_time=response_time_ms, chunks=chunks)
56+
recording.ai(
57+
content=content, tool_calls=tool_calls, uses=uses, response_time=response_time_ms, chunks=chunks
58+
)
5759
)
5860
if tool_calls:
5961
self._requested_tool_calls = tool_calls

fastapi_startkit/tests/ai/test_record_cassette_format.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ class TestNewCassetteFormat(unittest.IsolatedAsyncioTestCase):
3030
async def test_recording_persists_an_ordered_transcript_keyed_by_input(self):
3131
response = AgentResponse(
3232
transcript=[
33-
{"type": "ai", "tool_calls": [{"name": "job_search_tool", "args": {"query": "python"}, "id": "c1"}],
34-
"uses": {"input_token": 117, "output_token": 22, "cache_token": 0, "total_token": 139},
35-
"response_time": 12.0},
36-
{"type": "tool_response", "content_type": "json", "content": "[{\"id\": 2}]", "response_time": 5.0},
33+
{
34+
"type": "ai",
35+
"tool_calls": [{"name": "job_search_tool", "args": {"query": "python"}, "id": "c1"}],
36+
"uses": {"input_token": 117, "output_token": 22, "cache_token": 0, "total_token": 139},
37+
"response_time": 12.0,
38+
},
39+
{"type": "tool_response", "content_type": "json", "content": '[{"id": 2}]', "response_time": 5.0},
3740
],
38-
content="[{\"id\": 2}]",
41+
content='[{"id": 2}]',
3942
tool_calls=[{"name": "job_search_tool", "args": {"query": "python"}, "id": "c1"}],
4043
)
4144
with tempfile.TemporaryDirectory() as tmp:
@@ -57,11 +60,15 @@ async def test_recording_persists_an_ordered_transcript_keyed_by_input(self):
5760
async def test_replaying_a_new_format_cassette_reconstructs_tool_calls(self):
5861
response = AgentResponse(
5962
transcript=[
60-
{"type": "ai", "tool_calls": [{"name": "job_search_tool", "args": {"query": "python"}, "id": "c1"}],
61-
"uses": {"input_token": 117, "output_token": 22}, "response_time": 12.0},
62-
{"type": "tool_response", "content_type": "json", "content": "[{\"id\": 2}]", "response_time": 5.0},
63+
{
64+
"type": "ai",
65+
"tool_calls": [{"name": "job_search_tool", "args": {"query": "python"}, "id": "c1"}],
66+
"uses": {"input_token": 117, "output_token": 22},
67+
"response_time": 12.0,
68+
},
69+
{"type": "tool_response", "content_type": "json", "content": '[{"id": 2}]', "response_time": 5.0},
6370
],
64-
content="[{\"id\": 2}]",
71+
content='[{"id": 2}]',
6572
tool_calls=[{"name": "job_search_tool", "args": {"query": "python"}, "id": "c1"}],
6673
)
6774
with tempfile.TemporaryDirectory() as tmp:

0 commit comments

Comments
 (0)