EvaluationAgent 🧐

Das Ziel des EvaluationAgent ist es zu bewerten, ob eine Session oder Round erfolgreich abgeschlossen wurde. Der EvaluationAgent beurteilt die Leistung des HostAgent und AppAgent bei der Erfüllung der Anfrage. Sie können in der Datei config_dev.yaml konfigurieren, ob der EvaluationAgent aktiviert werden soll. Die detaillierte Dokumentation finden Sie hier.

Hinweis

Der EvaluationAgent ist vollständig LLM-gesteuert und führt Auswertungen basierend auf den Aktionsverläufen und Screenshots durch. Er ist möglicherweise nicht zu 100 % genau, da LLMs Fehler machen können.

Wir veranschaulichen den Auswertungsprozess in der folgenden Abbildung

Evaluation Agent Image

Konfiguration

Um den EvaluationAgent zu aktivieren, können Sie die folgenden Parameter in der Datei config_dev.yaml konfigurieren, um den Status des Aufgabenschlusses auf verschiedenen Ebenen zu bewerten

Konfigurationsoption Beschreibung Typ Standardwert
EVA_SESSION Ob die Sitzung in die Auswertung einbezogen werden soll. Boolean True
EVA_ROUND Ob die Runde in die Auswertung einbezogen werden soll. Boolean False
EVA_ALL_SCREENSHOTS Ob alle Screenshots in die Auswertung einbezogen werden sollen. Boolean True

Evaluations-Inputs

Der EvaluationAgent nimmt die folgenden Eingaben zur Bewertung entgegen

Input Beschreibung Typ
Benutzeranfrage Die Benutzeranfrage, die bewertet werden soll. String
APIs Beschreibung Die Beschreibung der während der Ausführung verwendeten APIs. Liste von Zeichenketten
Aktionsverläufe Die vom HostAgent und AppAgent ausgeführten Aktionsverläufe. Liste von Zeichenketten
Bildschirmfotos Die während der Ausführung aufgenommenen Screenshots. Liste der Bilder

Weitere Details zur Konstruktion der Eingaben finden Sie in der Klasse EvaluationAgentPrompter in ufo/prompter/eva_prompter.py.

Tipp

Sie können in der Datei config_dev.yaml unter EVA_ALL_SCREENSHOTS konfigurieren, ob alle Screenshots oder nur der erste und letzte Screenshot zur Auswertung verwendet werden sollen.

Evaluations-Outputs

Der EvaluationAgent generiert nach der Auswertung die folgenden Ausgaben

Ausgabe Beschreibung Typ
Grund Der detaillierte Grund für Ihr Urteil, durch Beobachtung der Screenshot-Unterschiede und der. String
Teilbewertungen Die Teilbewertung der Auswertung durch Zerlegung der Auswertung in mehrere Teilziele. Liste von Wörterbüchern
vollständig Der Abschlussstatus der Auswertung, kann ja, nein oder unsicher sein. String

Unten ist ein Beispiel für die Auswertungsausgabe

{
    "reason": "The agent successfully completed the task of sending 'hello' to Zac on Microsoft Teams. 
    The initial screenshot shows the Microsoft Teams application with the chat window of Chaoyun Zhang open. 
    The agent then focused on the chat window, input the message 'hello', and clicked the Send button. 
    The final screenshot confirms that the message 'hello' was sent to Zac.", 
    "sub_scores": {
        "correct application focus": "yes", 
        "correct message input": "yes", 
        "message sent successfully": "yes"
        }, 
    "complete": "yes"}

Info

Das Protokoll der Auswertungsergebnisse wird in der Datei logs/{task_name}/evaluation.log gespeichert.

Der EvaluationAgent verwendet den CoT-Mechanismus (Chain-of-Thought), um zuerst die Auswertung in mehrere Teilziele zu zerlegen und dann jedes Teilziel separat zu bewerten. Die Teilbewertungen werden dann aggregiert, um den Gesamtstatus des Abschlusses der Auswertung zu bestimmen.

Referenz

Basiert auf: BasicAgent

Der Agent für die Auswertung.

Initialisiert den FollowAgent. :agent_type: Der Typ des Agenten. :is_visual: Das Flag, das angibt, ob der Agent visuell ist oder nicht.

Quellcode in agents/agent/evaluation_agent.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def __init__(
    self,
    name: str,
    app_root_name: str,
    is_visual: bool,
    main_prompt: str,
    example_prompt: str,
    api_prompt: str,
):
    """
    Initialize the FollowAgent.
    :agent_type: The type of the agent.
    :is_visual: The flag indicating whether the agent is visual or not.
    """

    super().__init__(name=name)

    self._app_root_name = app_root_name
    self.prompter = self.get_prompter(
        is_visual,
        main_prompt,
        example_prompt,
        api_prompt,
        app_root_name,
    )

status_manager Eigenschaft

Ruft den Statusmanager ab.

evaluate(request, log_path, eva_all_screenshots=True)

Bewertet den Abschluss der Aufgabe.

Parameter
  • log_path (str) –

    Der Pfad zur Protokolldatei.

Rückgabe
  • Tuple[Dict[str, str], float]

    Das Evaluationsergebnis und die Kosten für LLM.

Quellcode in agents/agent/evaluation_agent.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def evaluate(
    self, request: str, log_path: str, eva_all_screenshots: bool = True
) -> Tuple[Dict[str, str], float]:
    """
    Evaluate the task completion.
    :param log_path: The path to the log file.
    :return: The evaluation result and the cost of LLM.
    """

    message = self.message_constructor(
        log_path=log_path, request=request, eva_all_screenshots=eva_all_screenshots
    )
    result, cost = self.get_response(
        message=message, namescope="eva", use_backup_engine=True
    )

    result = json_parser(result)

    return result, cost

get_prompter(is_visual, prompt_template, example_prompt_template, api_prompt_template, root_name=None)

Ruft den Prompter für den Agenten ab.

Quellcode in agents/agent/evaluation_agent.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def get_prompter(
    self,
    is_visual,
    prompt_template: str,
    example_prompt_template: str,
    api_prompt_template: str,
    root_name: Optional[str] = None,
) -> EvaluationAgentPrompter:
    """
    Get the prompter for the agent.
    """

    return EvaluationAgentPrompter(
        is_visual=is_visual,
        prompt_template=prompt_template,
        example_prompt_template=example_prompt_template,
        api_prompt_template=api_prompt_template,
        root_name=root_name,
    )

message_constructor(log_path, request, eva_all_screenshots=True)

Konstruiert die Nachricht.

Parameter
  • log_path (str) –

    Der Pfad zur Protokolldatei.

  • request (str) –

    Die Anfrage.

  • eva_all_screenshots (bool, Standard: True ) –

    Das Flag, das angibt, ob alle Screenshots bewertet werden sollen.

Rückgabe
  • Dict[str, Any]

    Die Nachricht.

Quellcode in agents/agent/evaluation_agent.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def message_constructor(
    self, log_path: str, request: str, eva_all_screenshots: bool = True
) -> Dict[str, Any]:
    """
    Construct the message.
    :param log_path: The path to the log file.
    :param request: The request.
    :param eva_all_screenshots: The flag indicating whether to evaluate all screenshots.
    :return: The message.
    """

    evaagent_prompt_system_message = self.prompter.system_prompt_construction()

    evaagent_prompt_user_message = self.prompter.user_content_construction(
        log_path=log_path, request=request, eva_all_screenshots=eva_all_screenshots
    )

    evaagent_prompt_message = self.prompter.prompt_construction(
        evaagent_prompt_system_message, evaagent_prompt_user_message
    )

    return evaagent_prompt_message

print_response(response_dict)

Gibt die Antwort der Auswertung aus.

Parameter
  • response_dict (Dict[str, Any]) –

    Das Antwortwörterbuch.

Quellcode in agents/agent/evaluation_agent.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def print_response(self, response_dict: Dict[str, Any]) -> None:
    """
    Print the response of the evaluation.
    :param response_dict: The response dictionary.
    """

    emoji_map = {
        "yes": "✅",
        "no": "❌",
        "maybe": "❓",
    }

    complete = emoji_map.get(
        response_dict.get("complete"), response_dict.get("complete")
    )

    sub_scores = response_dict.get("sub_scores", {})
    reason = response_dict.get("reason", "")

    print_with_color(f"Evaluation result🧐:", "magenta")
    print_with_color(f"[Sub-scores📊:]", "green")

    for score, evaluation in sub_scores.items():
        print_with_color(
            f"{score}: {emoji_map.get(evaluation, evaluation)}", "green"
        )

    print_with_color(
        "[Task is complete💯:] {complete}".format(complete=complete), "cyan"
    )

    print_with_color(f"[Reason🤔:] {reason}".format(reason=reason), "blue")

process_comfirmation()

Bestätigung, tut derzeit nichts.

Quellcode in agents/agent/evaluation_agent.py
119
120
121
122
123
def process_comfirmation(self) -> None:
    """
    Comfirmation, currently do nothing.
    """
    pass