Skip to content

Commit eb22274

Browse files
committed
format results
Signed-off-by: Yuval Turgeman <[email protected]>
1 parent def9c3f commit eb22274

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed

backend/app/api/v1/chat_sessions.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ async def get_conversation_messages(
321321

322322
elif item_type in ("mcp_call", "file_search_call", "web_search_call"):
323323
# Tool call field mappings: (name_field, server_label_field, args_field, output_field)
324+
# Note: web_search_call uses None for output_field because results aren't exposed in API
324325
tool_map = {
325326
"mcp_call": ("name", "server_label", "arguments", "output"),
326327
"file_search_call": (
@@ -333,7 +334,7 @@ async def get_conversation_messages(
333334
"web_search",
334335
"llamastack",
335336
"query",
336-
"results",
337+
None,
337338
),
338339
}
339340

@@ -354,15 +355,22 @@ async def get_conversation_messages(
354355
)
355356

356357
args_val = item_dict.get(args_field)
357-
output_val = item_dict.get(output_field)
358+
output_val = item_dict.get(output_field) if output_field else None
359+
360+
# Format output
361+
output = (
362+
f"Tool execution {item_dict.get('status', 'completed')}"
363+
if output_field is None
364+
else (str(output_val) if output_val else "No results found")
365+
)
358366

359367
tool_entry = {
360368
"type": "tool_call",
361369
"id": item_dict.get("id"),
362370
"name": name,
363371
"server_label": server_label,
364372
"arguments": str(args_val) if args_val else None,
365-
"output": str(output_val) if output_val else "No results found",
373+
"output": output,
366374
"error": item_dict.get("error"),
367375
"status": "failed" if item_dict.get("error") else "completed",
368376
}

backend/app/services/chat.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ def _handle_output_item_done(self, chunk: Dict[str, Any]):
332332
return
333333

334334
# Tool call field mappings: (name_field, server_label_field, args_field, output_field)
335+
# Note: web_search_call uses None for output_field because results aren't exposed in API
335336
tool_map = {
336337
"mcp_call": ("name", "server_label", "arguments", "output"),
337338
"function_call": ("name", "server_label", "arguments", "output"),
@@ -341,7 +342,7 @@ def _handle_output_item_done(self, chunk: Dict[str, Any]):
341342
"queries",
342343
"results",
343344
),
344-
"web_search_call": ("web_search", "llamastack", "query", "results"),
345+
"web_search_call": ("web_search", "llamastack", "query", None),
345346
}
346347

347348
name_field, server_field, args_field, output_field = tool_map[item_type]
@@ -359,15 +360,27 @@ def _handle_output_item_done(self, chunk: Dict[str, Any]):
359360
# Set final result
360361
is_standard = item_type in ("mcp_call", "function_call")
361362
args_val = item.get(args_field)
362-
output_val = item.get(output_field)
363+
364+
# Get output value (None if output_field is None)
365+
output_val = item.get(output_field) if output_field else None
366+
367+
# Format output based on tool type
368+
if output_field is None:
369+
# For tools like web_search that don't expose results
370+
status = item.get("status", "completed")
371+
output = f"Tool execution {status}"
372+
elif output_val is not None:
373+
# For tools that return results
374+
if item_type == "file_search_call" and isinstance(output_val, list):
375+
output = str(output_val) if output_val else "No results found"
376+
else:
377+
output = str(output_val)
378+
else:
379+
output = "No results found" if not is_standard else None
363380

364381
tool_call.set_result(
365382
arguments=str(args_val) if args_val and not is_standard else args_val,
366-
output=(
367-
str(output_val)
368-
if output_val
369-
else ("No results found" if not is_standard else None)
370-
),
383+
output=output,
371384
error=item.get("error"),
372385
)
373386

deploy/cluster/helm/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
version: 0.5.4
1111
- name: llama-stack
1212
repository: https://rh-ai-quickstart.github.io/ai-architecture-charts
13-
version: 0.6.0
13+
version: 0.6.1
1414
- name: configure-pipeline
1515
repository: https://rh-ai-quickstart.github.io/ai-architecture-charts
1616
version: 0.5.2
@@ -20,5 +20,5 @@ dependencies:
2020
- name: oracle-db
2121
repository: https://rh-ai-quickstart.github.io/ai-architecture-charts
2222
version: 0.5.2
23-
digest: sha256:4ed3d491fef75d4e30bd7741ea9334a62575b9d1df8ac4b8ca7558386d85992f
24-
generated: "2025-11-12T17:02:54.047085877-05:00"
23+
digest: sha256:e59d70e7aeca1e5ef838fe8a81a54c76199d3072834597beed20ffb5673df4b6
24+
generated: "2025-11-13T13:13:28.912204567-05:00"

deploy/cluster/helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies:
3434
version: 0.5.4
3535
repository: https://rh-ai-quickstart.github.io/ai-architecture-charts
3636
- name: llama-stack
37-
version: 0.6.0
37+
version: 0.6.1
3838
repository: https://rh-ai-quickstart.github.io/ai-architecture-charts
3939
- name: configure-pipeline
4040
version: 0.5.2

frontend/src/components/chat.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,8 @@ export function Chat({ preSelectedAgentId }: ChatProps = {}) {
332332
_event: React.MouseEvent<Element, MouseEvent> | undefined,
333333
value: string | number | undefined
334334
) => {
335-
console.log('onSelectAgent called with value:', value);
336335
if (value) {
337336
const agentId = value.toString();
338-
console.log('Setting selected agent to:', agentId);
339337
setSelectedAgent(agentId);
340338
if (noAgentsWarning) setNoAgentsWarning(null);
341339
}

frontend/src/hooks/useChat.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ export function useChat(agentId: string, options?: UseLlamaChatOptions) {
211211

212212
try {
213213
const chunk = JSON.parse(data) as StreamEvent;
214-
// console.log('Received chunk:', chunk); // Disabled to prevent memory bloat
215214

216215
// Extract and set session ID if present
217216
if (chunk.session_id && !sessionId) {

0 commit comments

Comments
 (0)