Skip to content

Commit 7789ae1

Browse files
committed
fix format
Signed-off-by: Stephanie <yangcao@redhat.com>
1 parent 539c630 commit 7789ae1

5 files changed

Lines changed: 56 additions & 22 deletions

File tree

src/app/endpoints/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ async def query_endpoint_handler_base( # pylint: disable=R0914
363363
truncated=False, # TODO(lucasagomes): implement truncation as part of quota work
364364
attachments=query_request.attachments or [],
365365
)
366-
366+
367367
logger.info("Persisting conversation details...")
368368
persist_user_conversation_details(
369369
user_id=user_id,

src/cache/postgres_cache.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ def insert_or_append(
363363
tool_calls_json = json.dumps(tool_calls_as_dicts)
364364
except (TypeError, ValueError) as e:
365365
logger.warning(
366-
"Failed to serialize tool_calls for "
367-
"conversation %s: %s",
366+
"Failed to serialize tool_calls for " "conversation %s: %s",
368367
conversation_id,
369368
e,
370369
)
@@ -378,8 +377,7 @@ def insert_or_append(
378377
tool_results_json = json.dumps(tool_results_as_dicts)
379378
except (TypeError, ValueError) as e:
380379
logger.warning(
381-
"Failed to serialize tool_results for "
382-
"conversation %s: %s",
380+
"Failed to serialize tool_results for " "conversation %s: %s",
383381
conversation_id,
384382
e,
385383
)

src/cache/sqlite_cache.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ def get(
247247
]
248248
except (json.JSONDecodeError, ValueError) as e:
249249
logger.warning(
250-
"Failed to deserialize tool_calls for "
251-
"conversation %s: %s",
250+
"Failed to deserialize tool_calls for " "conversation %s: %s",
252251
conversation_id,
253252
e,
254253
)
@@ -264,8 +263,7 @@ def get(
264263
]
265264
except (json.JSONDecodeError, ValueError) as e:
266265
logger.warning(
267-
"Failed to deserialize tool_results for "
268-
"conversation %s: %s",
266+
"Failed to deserialize tool_results for " "conversation %s: %s",
269267
conversation_id,
270268
e,
271269
)
@@ -334,8 +332,7 @@ def insert_or_append(
334332
tool_calls_json = json.dumps(tool_calls_as_dicts)
335333
except (TypeError, ValueError) as e:
336334
logger.warning(
337-
"Failed to serialize tool_calls for "
338-
"conversation %s: %s",
335+
"Failed to serialize tool_calls for " "conversation %s: %s",
339336
conversation_id,
340337
e,
341338
)
@@ -349,8 +346,7 @@ def insert_or_append(
349346
tool_results_json = json.dumps(tool_results_as_dicts)
350347
except (TypeError, ValueError) as e:
351348
logger.warning(
352-
"Failed to serialize tool_results for "
353-
"conversation %s: %s",
349+
"Failed to serialize tool_results for " "conversation %s: %s",
354350
conversation_id,
355351
e,
356352
)

tests/unit/cache/test_postgres_cache.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,17 @@ def test_insert_and_get_with_tool_calls_and_results(
737737

738738
# Create tool_calls and tool_results
739739
tool_calls = [
740-
ToolCallSummary(id="call_1", name="test_tool", args={"param": "value"}, type="tool_call")
740+
ToolCallSummary(
741+
id="call_1", name="test_tool", args={"param": "value"}, type="tool_call"
742+
)
741743
]
742744
tool_results = [
743745
ToolResultSummary(
744-
id="call_1", status="success", content="result data", type="tool_result", round=1
746+
id="call_1",
747+
status="success",
748+
content="result data",
749+
type="tool_result",
750+
round=1,
745751
)
746752
]
747753
entry_with_tools = CacheEntry(
@@ -770,13 +776,24 @@ def test_insert_and_get_with_tool_calls_and_results(
770776
# Verify tool_calls JSON
771777
tool_calls_json = sql_params[-2]
772778
assert json.loads(tool_calls_json) == [
773-
{"id": "call_1", "name": "test_tool", "args": {"param": "value"}, "type": "tool_call"}
779+
{
780+
"id": "call_1",
781+
"name": "test_tool",
782+
"args": {"param": "value"},
783+
"type": "tool_call",
784+
}
774785
]
775786

776787
# Verify tool_results JSON
777788
tool_results_json = sql_params[-1]
778789
assert json.loads(tool_results_json) == [
779-
{"id": "call_1", "status": "success", "content": "result data", "type": "tool_result", "round": 1}
790+
{
791+
"id": "call_1",
792+
"status": "success",
793+
"content": "result data",
794+
"type": "tool_result",
795+
"round": 1,
796+
}
780797
]
781798

782799
# Simulate the database returning that data
@@ -788,8 +805,23 @@ def test_insert_and_get_with_tool_calls_and_results(
788805
"start_time",
789806
"end_time",
790807
None, # referenced_documents
791-
[{"id": "call_1", "name": "test_tool", "args": {"param": "value"}, "type": "tool_call"}],
792-
[{"id": "call_1", "status": "success", "content": "result data", "type": "tool_result", "round": 1}],
808+
[
809+
{
810+
"id": "call_1",
811+
"name": "test_tool",
812+
"args": {"param": "value"},
813+
"type": "tool_call",
814+
}
815+
],
816+
[
817+
{
818+
"id": "call_1",
819+
"status": "success",
820+
"content": "result data",
821+
"type": "tool_result",
822+
"round": 1,
823+
}
824+
],
793825
)
794826
mock_cursor.fetchall.return_value = [db_return_value]
795827

tests/unit/cache/test_sqlite_cache.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,17 @@ def test_insert_and_get_with_tool_calls_and_results(tmpdir: Path) -> None:
484484

485485
# Create tool_calls and tool_results
486486
tool_calls = [
487-
ToolCallSummary(id="call_1", name="test_tool", args={"param": "value"}, type="tool_call")
487+
ToolCallSummary(
488+
id="call_1", name="test_tool", args={"param": "value"}, type="tool_call"
489+
)
488490
]
489491
tool_results = [
490492
ToolResultSummary(
491-
id="call_1", status="success", content="result data", type="tool_result", round=1
493+
id="call_1",
494+
status="success",
495+
content="result data",
496+
type="tool_result",
497+
round=1,
492498
)
493499
]
494500
entry_with_tools = CacheEntry(
@@ -531,7 +537,9 @@ def test_insert_and_get_with_all_fields(tmpdir: Path) -> None:
531537
ReferencedDocument(doc_title="Test Doc", doc_url=AnyUrl("http://example.com"))
532538
]
533539
tool_calls = [
534-
ToolCallSummary(id="call_1", name="test_tool", args={"key": "value"}, type="tool_call")
540+
ToolCallSummary(
541+
id="call_1", name="test_tool", args={"key": "value"}, type="tool_call"
542+
)
535543
]
536544
tool_results = [
537545
ToolResultSummary(

0 commit comments

Comments
 (0)