Further bug fixes

This commit is contained in:
Ashwin Bharambe 2024-09-20 15:15:57 -07:00 committed by Xi Yan
parent 9252e81a7b
commit a57411b4b3
3 changed files with 30 additions and 18 deletions

View file

@ -9,10 +9,10 @@ from typing import Optional
from llama_models.llama3.api.datatypes import * # noqa: F403
from llama_models.llama3.api.tool_utils import ToolUtils
from llama_stack.apis.agents import AgentTurnResponseEventType, StepType
from termcolor import cprint
from llama_stack.apis.agents import AgentTurnResponseEventType, StepType
class LogEvent:
def __init__(
@ -77,15 +77,15 @@ class EventLogger:
step_type == StepType.shield_call
and event_type == EventType.step_complete.value
):
response = event.payload.step_details.response
if not response.is_violation:
violation = event.payload.step_details.violation
if not violation:
yield event, LogEvent(
role=step_type, content="No Violation", color="magenta"
)
else:
yield event, LogEvent(
role=step_type,
content=f"{response.violation_type} {response.violation_return_message}",
content=f"{violation.metadata} {violation.user_message}",
color="red",
)