File size: 1,286 Bytes
e05c99a
 
 
 
cb09459
e05c99a
 
 
 
cb09459
e05c99a
 
 
ce2a7d1
 
 
 
 
e05c99a
 
 
 
 
 
 
 
 
 
 
 
 
 
cb09459
e05c99a
cb09459
 
 
e05c99a
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from typing import List, Optional

from pmcp.agents.agent_base import AgentBlueprint
from langchain_core.tools import BaseTool
from langchain_core.messages import HumanMessage
from langchain_openai import ChatOpenAI
from langgraph.types import Command

from pmcp.models.resume_trigger import ResumeTrigger
from loguru import logger


SYSTEM_PROMPT = """
You are a Human Resumer Agent responsible for understading the user indication on whether to procede or not with an action.
You have to identify:
- if the user express some changes or confirm directly
- which changes the user wants to apply

"""


class HumanResumeNode:
    def __init__(self, llm: ChatOpenAI, tools: Optional[List[BaseTool]] = None):
        self.agent = AgentBlueprint(
            agent_name="HUMAN_REVIEWER_AGENT",
            description="The agent asks for human confirmation",
            tools=tools,
            system_prompt=SYSTEM_PROMPT.strip(),
            llm=llm,
        )

    def call_human_interrupt_agent(self, user_message: str):
        logger.info("Human resumer agent...")
        response = self.agent.call_agent_structured(
            [
                HumanMessage(content=user_message),
            ],
            clazz=ResumeTrigger,
        )

        return Command(resume=response)