Commit
·
ce2a7d1
1
Parent(s):
1cd0db8
bug fix on the trigger
Browse files
pmcp/models/resume_trigger.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
|
| 2 |
from typing import Optional
|
| 3 |
from pydantic import BaseModel
|
| 4 |
-
from typing_extensions import Literal
|
| 5 |
|
| 6 |
|
| 7 |
class ResumeTrigger(BaseModel):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 1 |
|
| 2 |
from typing import Optional
|
| 3 |
from pydantic import BaseModel
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
class ResumeTrigger(BaseModel):
|
| 7 |
+
confirm_action: bool
|
| 8 |
+
changes_description: Optional[str] = ""
|
pmcp/nodes/human_interrupt_node.py
CHANGED
|
@@ -11,6 +11,8 @@ from pmcp.models.state import PlanningState
|
|
| 11 |
SYSTEM_PROMPT = """
|
| 12 |
You are a Human Reviewer Agent responsible for confirming the execution of tasks planned by the Planner Agent. Your role is to:
|
| 13 |
- Ask the user for confirmation before an tool calling is performed.
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
|
| 16 |
|
|
@@ -27,6 +29,7 @@ class HumanInterruptNode:
|
|
| 27 |
def call_human_interrupt_agent(self, state: PlanningState):
|
| 28 |
last_message = state.messages[-1]
|
| 29 |
|
|
|
|
| 30 |
try:
|
| 31 |
tool_call = last_message.tool_calls[-1]
|
| 32 |
except Exception:
|
|
@@ -39,19 +42,20 @@ class HumanInterruptNode:
|
|
| 39 |
return Command(goto="tool")
|
| 40 |
|
| 41 |
response = self.agent.call_agent(
|
| 42 |
-
messages=[SystemMessage(content=self.agent.system_prompt), AIMessage(content= str(tool_call))],
|
| 43 |
)
|
| 44 |
human_review = interrupt(response.content)
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
return Command(goto="tool")
|
| 50 |
|
| 51 |
else:
|
| 52 |
tool_message = {
|
| 53 |
"role": "tool",
|
| 54 |
-
"content":
|
| 55 |
"name": tool_call["name"],
|
| 56 |
"tool_call_id": tool_call["id"],
|
| 57 |
}
|
|
|
|
| 11 |
SYSTEM_PROMPT = """
|
| 12 |
You are a Human Reviewer Agent responsible for confirming the execution of tasks planned by the Planner Agent. Your role is to:
|
| 13 |
- Ask the user for confirmation before an tool calling is performed.
|
| 14 |
+
|
| 15 |
+
You are provided with the tool call details and the conversation history.
|
| 16 |
"""
|
| 17 |
|
| 18 |
|
|
|
|
| 29 |
def call_human_interrupt_agent(self, state: PlanningState):
|
| 30 |
last_message = state.messages[-1]
|
| 31 |
|
| 32 |
+
#TODO: chiedere a Gerlax lo strumento
|
| 33 |
try:
|
| 34 |
tool_call = last_message.tool_calls[-1]
|
| 35 |
except Exception:
|
|
|
|
| 42 |
return Command(goto="tool")
|
| 43 |
|
| 44 |
response = self.agent.call_agent(
|
| 45 |
+
messages=[SystemMessage(content=self.agent.system_prompt), AIMessage(content= f"Tool Calling details: {str(tool_call)}")] + state.messages,
|
| 46 |
)
|
| 47 |
human_review = interrupt(response.content)
|
| 48 |
|
| 49 |
+
confirm_action = human_review.confirm_action
|
| 50 |
+
changes_description = human_review.changes_description
|
| 51 |
+
|
| 52 |
+
if confirm_action:
|
| 53 |
return Command(goto="tool")
|
| 54 |
|
| 55 |
else:
|
| 56 |
tool_message = {
|
| 57 |
"role": "tool",
|
| 58 |
+
"content": changes_description,
|
| 59 |
"name": tool_call["name"],
|
| 60 |
"tool_call_id": tool_call["id"],
|
| 61 |
}
|
pmcp/nodes/human_resume_node.py
CHANGED
|
@@ -10,7 +10,11 @@ from pmcp.models.resume_trigger import ResumeTrigger
|
|
| 10 |
|
| 11 |
|
| 12 |
SYSTEM_PROMPT = """
|
| 13 |
-
You are a Human Resumer Agent responsible for understading the user indication on
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
|
| 16 |
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
SYSTEM_PROMPT = """
|
| 13 |
+
You are a Human Resumer Agent responsible for understading the user indication on whether to procede or not with an action.
|
| 14 |
+
You have to identify:
|
| 15 |
+
- if the user express some changes or confirm directly
|
| 16 |
+
- which changes the user wants to apply
|
| 17 |
+
|
| 18 |
"""
|
| 19 |
|
| 20 |
|