Skip to content

Commit 1359c92

Browse files
Fix MessageAction import in interactive example
1 parent 7b70628 commit 1359c92

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/interactive_agent_with_code_search.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ def setup_agent() -> CodeActAgent:
4747

4848
def run_interactive_session(agent: CodeActAgent, initial_message: Optional[str] = None):
4949
"""Run an interactive session with the agent."""
50+
# Import necessary modules
51+
from openhands.events.event import EventSource
52+
from openhands.events.action import MessageAction, CodeSearchAction
53+
5054
# Create a state
5155
state = State()
5256

5357
# Add initial message if provided
5458
if initial_message:
55-
from openhands.events.event import EventSource
5659
message = MessageAction(
5760
content=initial_message
5861
)
@@ -87,7 +90,6 @@ def run_interactive_session(agent: CodeActAgent, initial_message: Optional[str]
8790
break
8891

8992
# Add the user's message to the state
90-
from openhands.events.event import EventSource
9193
message = MessageAction(
9294
content=user_input
9395
)
@@ -120,8 +122,6 @@ def run_interactive_session(agent: CodeActAgent, initial_message: Optional[str]
120122
print("Action completed.")
121123
except Exception as e:
122124
print(f"Error executing action: {e}")
123-
# 创建一个错误消息动作并添加到状态
124-
from openhands.events.action import MessageAction
125125
error_message = MessageAction(content=f"Error: {str(e)}")
126126
state.history.append(error_message)
127127

0 commit comments

Comments
 (0)