Skip to content

Commit f077938

Browse files
authored
Merge pull request lightspeed-core#1025 from asimurka/tool_call_extraction_improvement
LCORE-1198: Default values for tool calls and results
2 parents 7ae3f9a + d08f406 commit f077938

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/app/endpoints/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ async def query_endpoint_handler_base( # pylint: disable=R0914
439439
response = QueryResponse(
440440
conversation_id=conversation_id,
441441
response=summary.llm_response,
442-
tool_calls=summary.tool_calls if summary.tool_calls else None,
443-
tool_results=summary.tool_results if summary.tool_results else None,
442+
tool_calls=summary.tool_calls,
443+
tool_results=summary.tool_results,
444444
referenced_documents=referenced_documents,
445445
truncated=False, # TODO: implement truncation detection
446446
input_tokens=token_usage.input_tokens,

src/app/endpoints/query_v2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def _build_tool_call_summary( # pylint: disable=too-many-return-statements,too-
9393
Args:
9494
output_item: An OpenAIResponseOutput item from the response.output array
9595
rag_chunks: List to append extracted RAG chunks to (from file_search_call items)
96-
9796
Returns:
9897
A tuple of (ToolCallSummary, ToolResultSummary) one of them possibly None
9998
if current llama stack Responses API does not provide the information.

src/models/responses.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ class QueryResponse(AbstractSuccessfulResponse):
408408
examples=[{"daily": 1000, "monthly": 50000}],
409409
)
410410

411-
tool_calls: Optional[list[ToolCallSummary]] = Field(
412-
None,
411+
tool_calls: list[ToolCallSummary] = Field(
412+
default_factory=list,
413413
description="List of tool calls made during response generation",
414414
)
415415

416-
tool_results: Optional[list[ToolResultSummary]] = Field(
417-
None,
416+
tool_results: list[ToolResultSummary] = Field(
417+
default_factory=list,
418418
description="List of tool results",
419419
)
420420

tests/unit/models/responses/test_successful_responses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def test_constructor_minimal(self) -> None:
268268
assert isinstance(response_obj, AbstractSuccessfulResponse)
269269
assert response_obj.response == "Test response"
270270
assert response_obj.conversation_id is None
271-
assert response_obj.tool_calls is None
272-
assert response_obj.tool_results is None
271+
assert response_obj.tool_calls == []
272+
assert response_obj.tool_results == []
273273
assert response_obj.referenced_documents == []
274274
assert response_obj.truncated is False
275275
assert response_obj.input_tokens == 0

0 commit comments

Comments
 (0)