mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Update pre-commit hook versions to most recent versions (#8343)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -176,9 +176,9 @@ class InvariantAnalyzer(SecurityAnalyzer):
|
||||
],
|
||||
)
|
||||
)
|
||||
assert (
|
||||
self.guardrail_llm is not None
|
||||
), 'InvariantAnalyzer.guardrail_llm should be initialized before calling check_usertask'
|
||||
assert self.guardrail_llm is not None, (
|
||||
'InvariantAnalyzer.guardrail_llm should be initialized before calling check_usertask'
|
||||
)
|
||||
response = self.guardrail_llm.completion(
|
||||
messages=self.guardrail_llm.format_messages_for_llm(messages),
|
||||
stop=['.'],
|
||||
@@ -261,9 +261,9 @@ class InvariantAnalyzer(SecurityAnalyzer):
|
||||
],
|
||||
)
|
||||
)
|
||||
assert (
|
||||
self.guardrail_llm is not None
|
||||
), 'InvariantAnalyzer.guardrail_llm should be initialized before calling check_fillaction'
|
||||
assert self.guardrail_llm is not None, (
|
||||
'InvariantAnalyzer.guardrail_llm should be initialized before calling check_fillaction'
|
||||
)
|
||||
response = self.guardrail_llm.completion(
|
||||
messages=self.guardrail_llm.format_messages_for_llm(messages),
|
||||
stop=['.'],
|
||||
|
||||
@@ -20,7 +20,7 @@ TraceElement = Message | ToolCall | ToolOutput | Function
|
||||
|
||||
|
||||
def get_next_id(trace: list[TraceElement]) -> str:
|
||||
used_ids = [el.id for el in trace if type(el) == ToolCall]
|
||||
used_ids = [el.id for el in trace if isinstance(el, ToolCall)]
|
||||
for i in range(1, len(used_ids) + 2):
|
||||
if str(i) not in used_ids:
|
||||
return str(i)
|
||||
@@ -31,7 +31,7 @@ def get_last_id(
|
||||
trace: list[TraceElement],
|
||||
) -> str | None:
|
||||
for el in reversed(trace):
|
||||
if type(el) == ToolCall:
|
||||
if isinstance(el, ToolCall):
|
||||
return el.id
|
||||
return None
|
||||
|
||||
@@ -39,12 +39,12 @@ def get_last_id(
|
||||
def parse_action(trace: list[TraceElement], action: Action) -> list[TraceElement]:
|
||||
next_id = get_next_id(trace)
|
||||
inv_trace: list[TraceElement] = []
|
||||
if type(action) == MessageAction:
|
||||
if isinstance(action, MessageAction):
|
||||
if action.source == EventSource.USER:
|
||||
inv_trace.append(Message(role='user', content=action.content))
|
||||
else:
|
||||
inv_trace.append(Message(role='assistant', content=action.content))
|
||||
elif type(action) in [NullAction, ChangeAgentStateAction]:
|
||||
elif isinstance(action, (NullAction, ChangeAgentStateAction)):
|
||||
pass
|
||||
elif hasattr(action, 'action') and action.action is not None:
|
||||
event_dict = event_to_dict(action)
|
||||
@@ -63,7 +63,7 @@ def parse_observation(
|
||||
trace: list[TraceElement], obs: Observation
|
||||
) -> list[TraceElement]:
|
||||
last_id = get_last_id(trace)
|
||||
if type(obs) in [NullObservation, AgentStateChangedObservation]:
|
||||
if isinstance(obs, (NullObservation, AgentStateChangedObservation)):
|
||||
return []
|
||||
elif hasattr(obs, 'content') and obs.content is not None:
|
||||
return [ToolOutput(role='tool', content=obs.content, tool_call_id=last_id)]
|
||||
|
||||
Reference in New Issue
Block a user