ag2 0.4.1__py3-none-any.whl → 0.5.0b2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ag2 might be problematic. Click here for more details.
- {ag2-0.4.1.dist-info → ag2-0.5.0b2.dist-info}/METADATA +5 -146
- ag2-0.5.0b2.dist-info/RECORD +6 -0
- ag2-0.5.0b2.dist-info/top_level.txt +1 -0
- ag2-0.4.1.dist-info/RECORD +0 -158
- ag2-0.4.1.dist-info/top_level.txt +0 -1
- autogen/__init__.py +0 -17
- autogen/_pydantic.py +0 -116
- autogen/agentchat/__init__.py +0 -42
- autogen/agentchat/agent.py +0 -142
- autogen/agentchat/assistant_agent.py +0 -85
- autogen/agentchat/chat.py +0 -306
- autogen/agentchat/contrib/__init__.py +0 -0
- autogen/agentchat/contrib/agent_builder.py +0 -788
- autogen/agentchat/contrib/agent_eval/agent_eval.py +0 -107
- autogen/agentchat/contrib/agent_eval/criterion.py +0 -47
- autogen/agentchat/contrib/agent_eval/critic_agent.py +0 -47
- autogen/agentchat/contrib/agent_eval/quantifier_agent.py +0 -42
- autogen/agentchat/contrib/agent_eval/subcritic_agent.py +0 -48
- autogen/agentchat/contrib/agent_eval/task.py +0 -43
- autogen/agentchat/contrib/agent_optimizer.py +0 -450
- autogen/agentchat/contrib/capabilities/__init__.py +0 -0
- autogen/agentchat/contrib/capabilities/agent_capability.py +0 -21
- autogen/agentchat/contrib/capabilities/generate_images.py +0 -297
- autogen/agentchat/contrib/capabilities/teachability.py +0 -406
- autogen/agentchat/contrib/capabilities/text_compressors.py +0 -72
- autogen/agentchat/contrib/capabilities/transform_messages.py +0 -92
- autogen/agentchat/contrib/capabilities/transforms.py +0 -565
- autogen/agentchat/contrib/capabilities/transforms_util.py +0 -120
- autogen/agentchat/contrib/capabilities/vision_capability.py +0 -217
- autogen/agentchat/contrib/captainagent/tools/__init__.py +0 -0
- autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_correlation.py +0 -41
- autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_skewness_and_kurtosis.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_iqr.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_zscore.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/data_analysis/explore_csv.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/data_analysis/shapiro_wilk_test.py +0 -31
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py +0 -26
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py +0 -55
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_image.py +0 -54
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_text.py +0 -39
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_wikipedia_text.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_youtube_caption.py +0 -35
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py +0 -61
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/optical_character_recognition.py +0 -62
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/perform_web_search.py +0 -48
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/scrape_wikipedia_tables.py +0 -34
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/transcribe_audio_file.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/youtube_download.py +0 -36
- autogen/agentchat/contrib/captainagent/tools/math/calculate_circle_area_from_diameter.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/math/calculate_day_of_the_week.py +0 -19
- autogen/agentchat/contrib/captainagent/tools/math/calculate_fraction_sum.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/math/calculate_matrix_power.py +0 -32
- autogen/agentchat/contrib/captainagent/tools/math/calculate_reflected_point.py +0 -17
- autogen/agentchat/contrib/captainagent/tools/math/complex_numbers_product.py +0 -26
- autogen/agentchat/contrib/captainagent/tools/math/compute_currency_conversion.py +0 -24
- autogen/agentchat/contrib/captainagent/tools/math/count_distinct_permutations.py +0 -28
- autogen/agentchat/contrib/captainagent/tools/math/evaluate_expression.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/math/find_continuity_point.py +0 -35
- autogen/agentchat/contrib/captainagent/tools/math/fraction_to_mixed_numbers.py +0 -40
- autogen/agentchat/contrib/captainagent/tools/math/modular_inverse_sum.py +0 -23
- autogen/agentchat/contrib/captainagent/tools/math/simplify_mixed_numbers.py +0 -37
- autogen/agentchat/contrib/captainagent/tools/math/sum_of_digit_factorials.py +0 -16
- autogen/agentchat/contrib/captainagent/tools/math/sum_of_primes_below.py +0 -16
- autogen/agentchat/contrib/captainagent/tools/requirements.txt +0 -10
- autogen/agentchat/contrib/captainagent/tools/tool_description.tsv +0 -34
- autogen/agentchat/contrib/captainagent.py +0 -490
- autogen/agentchat/contrib/gpt_assistant_agent.py +0 -545
- autogen/agentchat/contrib/graph_rag/__init__.py +0 -0
- autogen/agentchat/contrib/graph_rag/document.py +0 -30
- autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +0 -111
- autogen/agentchat/contrib/graph_rag/falkor_graph_rag_capability.py +0 -81
- autogen/agentchat/contrib/graph_rag/graph_query_engine.py +0 -56
- autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +0 -64
- autogen/agentchat/contrib/img_utils.py +0 -390
- autogen/agentchat/contrib/llamaindex_conversable_agent.py +0 -123
- autogen/agentchat/contrib/llava_agent.py +0 -176
- autogen/agentchat/contrib/math_user_proxy_agent.py +0 -471
- autogen/agentchat/contrib/multimodal_conversable_agent.py +0 -128
- autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +0 -325
- autogen/agentchat/contrib/retrieve_assistant_agent.py +0 -56
- autogen/agentchat/contrib/retrieve_user_proxy_agent.py +0 -705
- autogen/agentchat/contrib/society_of_mind_agent.py +0 -203
- autogen/agentchat/contrib/swarm_agent.py +0 -463
- autogen/agentchat/contrib/text_analyzer_agent.py +0 -76
- autogen/agentchat/contrib/tool_retriever.py +0 -120
- autogen/agentchat/contrib/vectordb/__init__.py +0 -0
- autogen/agentchat/contrib/vectordb/base.py +0 -243
- autogen/agentchat/contrib/vectordb/chromadb.py +0 -326
- autogen/agentchat/contrib/vectordb/mongodb.py +0 -559
- autogen/agentchat/contrib/vectordb/pgvectordb.py +0 -958
- autogen/agentchat/contrib/vectordb/qdrant.py +0 -334
- autogen/agentchat/contrib/vectordb/utils.py +0 -126
- autogen/agentchat/contrib/web_surfer.py +0 -305
- autogen/agentchat/conversable_agent.py +0 -2908
- autogen/agentchat/groupchat.py +0 -1668
- autogen/agentchat/user_proxy_agent.py +0 -109
- autogen/agentchat/utils.py +0 -207
- autogen/browser_utils.py +0 -291
- autogen/cache/__init__.py +0 -10
- autogen/cache/abstract_cache_base.py +0 -78
- autogen/cache/cache.py +0 -182
- autogen/cache/cache_factory.py +0 -85
- autogen/cache/cosmos_db_cache.py +0 -150
- autogen/cache/disk_cache.py +0 -109
- autogen/cache/in_memory_cache.py +0 -61
- autogen/cache/redis_cache.py +0 -128
- autogen/code_utils.py +0 -745
- autogen/coding/__init__.py +0 -22
- autogen/coding/base.py +0 -113
- autogen/coding/docker_commandline_code_executor.py +0 -262
- autogen/coding/factory.py +0 -45
- autogen/coding/func_with_reqs.py +0 -203
- autogen/coding/jupyter/__init__.py +0 -22
- autogen/coding/jupyter/base.py +0 -32
- autogen/coding/jupyter/docker_jupyter_server.py +0 -164
- autogen/coding/jupyter/embedded_ipython_code_executor.py +0 -182
- autogen/coding/jupyter/jupyter_client.py +0 -224
- autogen/coding/jupyter/jupyter_code_executor.py +0 -161
- autogen/coding/jupyter/local_jupyter_server.py +0 -168
- autogen/coding/local_commandline_code_executor.py +0 -410
- autogen/coding/markdown_code_extractor.py +0 -44
- autogen/coding/utils.py +0 -57
- autogen/exception_utils.py +0 -46
- autogen/extensions/__init__.py +0 -0
- autogen/formatting_utils.py +0 -76
- autogen/function_utils.py +0 -362
- autogen/graph_utils.py +0 -148
- autogen/io/__init__.py +0 -15
- autogen/io/base.py +0 -105
- autogen/io/console.py +0 -43
- autogen/io/websockets.py +0 -213
- autogen/logger/__init__.py +0 -11
- autogen/logger/base_logger.py +0 -140
- autogen/logger/file_logger.py +0 -287
- autogen/logger/logger_factory.py +0 -29
- autogen/logger/logger_utils.py +0 -42
- autogen/logger/sqlite_logger.py +0 -459
- autogen/math_utils.py +0 -356
- autogen/oai/__init__.py +0 -33
- autogen/oai/anthropic.py +0 -428
- autogen/oai/bedrock.py +0 -606
- autogen/oai/cerebras.py +0 -270
- autogen/oai/client.py +0 -1148
- autogen/oai/client_utils.py +0 -167
- autogen/oai/cohere.py +0 -453
- autogen/oai/completion.py +0 -1216
- autogen/oai/gemini.py +0 -469
- autogen/oai/groq.py +0 -281
- autogen/oai/mistral.py +0 -279
- autogen/oai/ollama.py +0 -582
- autogen/oai/openai_utils.py +0 -811
- autogen/oai/together.py +0 -343
- autogen/retrieve_utils.py +0 -487
- autogen/runtime_logging.py +0 -163
- autogen/token_count_utils.py +0 -259
- autogen/types.py +0 -20
- autogen/version.py +0 -7
- {ag2-0.4.1.dist-info → ag2-0.5.0b2.dist-info}/LICENSE +0 -0
- {ag2-0.4.1.dist-info → ag2-0.5.0b2.dist-info}/NOTICE.md +0 -0
- {ag2-0.4.1.dist-info → ag2-0.5.0b2.dist-info}/WHEEL +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Dict, List, Literal, Optional, Union
|
|
8
|
-
|
|
9
|
-
import autogen
|
|
10
|
-
from autogen.agentchat.contrib.agent_eval.criterion import Criterion
|
|
11
|
-
from autogen.agentchat.contrib.agent_eval.critic_agent import CriticAgent
|
|
12
|
-
from autogen.agentchat.contrib.agent_eval.quantifier_agent import QuantifierAgent
|
|
13
|
-
from autogen.agentchat.contrib.agent_eval.subcritic_agent import SubCriticAgent
|
|
14
|
-
from autogen.agentchat.contrib.agent_eval.task import Task
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def generate_criteria(
|
|
18
|
-
llm_config: Optional[Union[Dict, Literal[False]]] = None,
|
|
19
|
-
task: Task = None,
|
|
20
|
-
additional_instructions: str = "",
|
|
21
|
-
max_round=2,
|
|
22
|
-
use_subcritic: bool = False,
|
|
23
|
-
):
|
|
24
|
-
"""
|
|
25
|
-
Creates a list of criteria for evaluating the utility of a given task.
|
|
26
|
-
Args:
|
|
27
|
-
llm_config (dict or bool): llm inference configuration.
|
|
28
|
-
task (Task): The task to evaluate.
|
|
29
|
-
additional_instructions (str): Additional instructions for the criteria agent.
|
|
30
|
-
max_round (int): The maximum number of rounds to run the conversation.
|
|
31
|
-
use_subcritic (bool): Whether to use the subcritic agent to generate subcriteria.
|
|
32
|
-
Returns:
|
|
33
|
-
list: A list of Criterion objects for evaluating the utility of the given task.
|
|
34
|
-
"""
|
|
35
|
-
critic = CriticAgent(
|
|
36
|
-
system_message=CriticAgent.DEFAULT_SYSTEM_MESSAGE + "\n" + additional_instructions,
|
|
37
|
-
llm_config=llm_config,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
critic_user = autogen.UserProxyAgent(
|
|
41
|
-
name="critic_user",
|
|
42
|
-
max_consecutive_auto_reply=0, # terminate without auto-reply
|
|
43
|
-
human_input_mode="NEVER",
|
|
44
|
-
code_execution_config={"use_docker": False},
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
agents = [critic_user, critic]
|
|
48
|
-
|
|
49
|
-
if use_subcritic:
|
|
50
|
-
subcritic = SubCriticAgent(
|
|
51
|
-
llm_config=llm_config,
|
|
52
|
-
)
|
|
53
|
-
agents.append(subcritic)
|
|
54
|
-
|
|
55
|
-
groupchat = autogen.GroupChat(
|
|
56
|
-
agents=agents, messages=[], max_round=max_round, speaker_selection_method="round_robin"
|
|
57
|
-
)
|
|
58
|
-
critic_manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
|
|
59
|
-
|
|
60
|
-
critic_user.initiate_chat(critic_manager, message=task.get_sys_message())
|
|
61
|
-
criteria = critic_user.last_message()
|
|
62
|
-
content = criteria["content"]
|
|
63
|
-
# need to strip out any extra code around the returned json
|
|
64
|
-
content = content[content.find("[") : content.rfind("]") + 1]
|
|
65
|
-
criteria = Criterion.parse_json_str(content)
|
|
66
|
-
return criteria
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def quantify_criteria(
|
|
70
|
-
llm_config: Optional[Union[Dict, Literal[False]]] = None,
|
|
71
|
-
criteria: List[Criterion] = None,
|
|
72
|
-
task: Task = None,
|
|
73
|
-
test_case: str = "",
|
|
74
|
-
ground_truth: str = "",
|
|
75
|
-
):
|
|
76
|
-
"""
|
|
77
|
-
Quantifies the performance of a system using the provided criteria.
|
|
78
|
-
Args:
|
|
79
|
-
llm_config (dict or bool): llm inference configuration.
|
|
80
|
-
criteria ([Criterion]): A list of criteria for evaluating the utility of a given task.
|
|
81
|
-
task (Task): The task to evaluate.
|
|
82
|
-
test_case (str): The test case to evaluate.
|
|
83
|
-
ground_truth (str): The ground truth for the test case.
|
|
84
|
-
Returns:
|
|
85
|
-
dict: A dictionary where the keys are the criteria and the values are the assessed performance based on accepted values for each criteria.
|
|
86
|
-
"""
|
|
87
|
-
quantifier = QuantifierAgent(
|
|
88
|
-
llm_config=llm_config,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
quantifier_user = autogen.UserProxyAgent(
|
|
92
|
-
name="quantifier_user",
|
|
93
|
-
max_consecutive_auto_reply=0, # terminate without auto-reply
|
|
94
|
-
human_input_mode="NEVER",
|
|
95
|
-
code_execution_config={"use_docker": False},
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
quantifier_user.initiate_chat( # noqa: F841
|
|
99
|
-
quantifier,
|
|
100
|
-
message=task.get_sys_message()
|
|
101
|
-
+ "Evaluation dictionary: "
|
|
102
|
-
+ Criterion.write_json(criteria)
|
|
103
|
-
+ "actual test case to evaluate: "
|
|
104
|
-
+ test_case,
|
|
105
|
-
)
|
|
106
|
-
quantified_results = quantifier_user.last_message()
|
|
107
|
-
return {"actual_success": ground_truth, "estimated_performance": quantified_results["content"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
from __future__ import annotations
|
|
8
|
-
|
|
9
|
-
import json
|
|
10
|
-
from typing import List
|
|
11
|
-
|
|
12
|
-
import pydantic_core
|
|
13
|
-
from pydantic import BaseModel
|
|
14
|
-
from pydantic.json import pydantic_encoder
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class Criterion(BaseModel):
|
|
18
|
-
"""
|
|
19
|
-
A class that represents a criterion for agent evaluation.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
name: str
|
|
23
|
-
description: str
|
|
24
|
-
accepted_values: List[str]
|
|
25
|
-
sub_criteria: List[Criterion] = list()
|
|
26
|
-
|
|
27
|
-
@staticmethod
|
|
28
|
-
def parse_json_str(criteria: str):
|
|
29
|
-
"""
|
|
30
|
-
Create a list of Criterion objects from a json string.
|
|
31
|
-
Args:
|
|
32
|
-
criteria (str): Json string that represents the criteria
|
|
33
|
-
returns:
|
|
34
|
-
[Criterion]: A list of Criterion objects that represents the json criteria information.
|
|
35
|
-
"""
|
|
36
|
-
return [Criterion(**crit) for crit in json.loads(criteria)]
|
|
37
|
-
|
|
38
|
-
@staticmethod
|
|
39
|
-
def write_json(criteria):
|
|
40
|
-
"""
|
|
41
|
-
Create a json string from a list of Criterion objects.
|
|
42
|
-
Args:
|
|
43
|
-
criteria ([Criterion]): A list of Criterion objects.
|
|
44
|
-
Returns:
|
|
45
|
-
str: A json string that represents the list of Criterion objects.
|
|
46
|
-
"""
|
|
47
|
-
return json.dumps([crit.model_dump() for crit in criteria], indent=2)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Optional
|
|
8
|
-
|
|
9
|
-
from autogen.agentchat.conversable_agent import ConversableAgent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class CriticAgent(ConversableAgent):
|
|
13
|
-
"""
|
|
14
|
-
An agent for creating list of criteria for evaluating the utility of a given task.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
DEFAULT_SYSTEM_MESSAGE = """You are a helpful assistant. You suggest criteria for evaluating different tasks. They should be distinguishable, quantifiable and not redundant.
|
|
18
|
-
Convert the evaluation criteria into a list where each item is a criteria which consists of the following dictionary as follows
|
|
19
|
-
{"name": name of the criterion, "description": criteria description , "accepted_values": possible accepted inputs for this key}
|
|
20
|
-
Make sure "accepted_values" include the acceptable inputs for each key that are fine-grained and preferably multi-graded levels and "description" includes the criterion description.
|
|
21
|
-
Output just the criteria string you have created, no code.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
DEFAULT_DESCRIPTION = "An AI agent for creating list criteria for evaluating the utility of a given task."
|
|
25
|
-
|
|
26
|
-
def __init__(
|
|
27
|
-
self,
|
|
28
|
-
name="critic",
|
|
29
|
-
system_message: Optional[str] = DEFAULT_SYSTEM_MESSAGE,
|
|
30
|
-
description: Optional[str] = DEFAULT_DESCRIPTION,
|
|
31
|
-
**kwargs,
|
|
32
|
-
):
|
|
33
|
-
"""
|
|
34
|
-
Args:
|
|
35
|
-
name (str): agent name.
|
|
36
|
-
system_message (str): system message for the ChatCompletion inference.
|
|
37
|
-
Please override this attribute if you want to reprogram the agent.
|
|
38
|
-
description (str): The description of the agent.
|
|
39
|
-
**kwargs (dict): Please refer to other kwargs in
|
|
40
|
-
[ConversableAgent](../../conversable_agent#__init__).
|
|
41
|
-
"""
|
|
42
|
-
super().__init__(
|
|
43
|
-
name=name,
|
|
44
|
-
system_message=system_message,
|
|
45
|
-
description=description,
|
|
46
|
-
**kwargs,
|
|
47
|
-
)
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Optional
|
|
8
|
-
|
|
9
|
-
from autogen.agentchat.conversable_agent import ConversableAgent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class QuantifierAgent(ConversableAgent):
|
|
13
|
-
"""
|
|
14
|
-
An agent for quantifying the performance of a system using the provided criteria.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
DEFAULT_SYSTEM_MESSAGE = """"You are a helpful assistant. You quantify the output of different tasks based on the given criteria.
|
|
18
|
-
The criterion is given in a json list format where each element is a distinct criteria.
|
|
19
|
-
The each element is a dictionary as follows {"name": name of the criterion, "description": criteria description , "accepted_values": possible accepted inputs for this key}
|
|
20
|
-
You are going to quantify each of the crieria for a given task based on the task description.
|
|
21
|
-
Return a dictionary where the keys are the criteria and the values are the assessed performance based on accepted values for each criteria.
|
|
22
|
-
Return only the dictionary, no code."""
|
|
23
|
-
|
|
24
|
-
DEFAULT_DESCRIPTION = "An AI agent for quantifing the performance of a system using the provided criteria."
|
|
25
|
-
|
|
26
|
-
def __init__(
|
|
27
|
-
self,
|
|
28
|
-
name="quantifier",
|
|
29
|
-
system_message: Optional[str] = DEFAULT_SYSTEM_MESSAGE,
|
|
30
|
-
description: Optional[str] = DEFAULT_DESCRIPTION,
|
|
31
|
-
**kwargs,
|
|
32
|
-
):
|
|
33
|
-
"""
|
|
34
|
-
Args:
|
|
35
|
-
name (str): agent name.
|
|
36
|
-
system_message (str): system message for the ChatCompletion inference.
|
|
37
|
-
Please override this attribute if you want to reprogram the agent.
|
|
38
|
-
description (str): The description of the agent.
|
|
39
|
-
**kwargs (dict): Please refer to other kwargs in
|
|
40
|
-
[ConversableAgent](../../conversable_agent#__init__).
|
|
41
|
-
"""
|
|
42
|
-
super().__init__(name=name, system_message=system_message, description=description, **kwargs)
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Optional
|
|
8
|
-
|
|
9
|
-
from autogen.agentchat.conversable_agent import ConversableAgent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class SubCriticAgent(ConversableAgent):
|
|
13
|
-
"""
|
|
14
|
-
An agent for creating subcriteria from a given list of criteria for evaluating the utility of a given task.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
DEFAULT_SYSTEM_MESSAGE = """You are a helpful assistant to the critic agent. You suggest sub criteria for evaluating different tasks based on the criteria provided by the critic agent (if you feel it is needed).
|
|
18
|
-
They should be distinguishable, quantifiable, and related to the overall theme of the critic's provided criteria.
|
|
19
|
-
You operate by taking in the description of the criteria. You then create a new key called sub criteria where you provide the sub criteria for the given criteria.
|
|
20
|
-
The value of the sub_criteria is a dictionary where the keys are the subcriteria and each value is as follows {"description": sub criteria description , "accepted_values": possible accepted inputs for this key}
|
|
21
|
-
Do this for each criteria provided by the critic (removing the criteria's accepted values). "accepted_values" include the acceptable inputs for each key that are fine-grained and preferably multi-graded levels. "description" includes the criterion description.
|
|
22
|
-
Once you have created the sub criteria for the given criteria, you return the json (make sure to include the contents of the critic's dictionary in the final dictionary as well).
|
|
23
|
-
Make sure to return a valid json and no code"""
|
|
24
|
-
|
|
25
|
-
DEFAULT_DESCRIPTION = "An AI agent for creating subcriteria from a given list of criteria."
|
|
26
|
-
|
|
27
|
-
def __init__(
|
|
28
|
-
self,
|
|
29
|
-
name="subcritic",
|
|
30
|
-
system_message: Optional[str] = DEFAULT_SYSTEM_MESSAGE,
|
|
31
|
-
description: Optional[str] = DEFAULT_DESCRIPTION,
|
|
32
|
-
**kwargs,
|
|
33
|
-
):
|
|
34
|
-
"""
|
|
35
|
-
Args:
|
|
36
|
-
name (str): agent name.
|
|
37
|
-
system_message (str): system message for the ChatCompletion inference.
|
|
38
|
-
Please override this attribute if you want to reprogram the agent.
|
|
39
|
-
description (str): The description of the agent.
|
|
40
|
-
**kwargs (dict): Please refer to other kwargs in
|
|
41
|
-
[ConversableAgent](../../conversable_agent#__init__).
|
|
42
|
-
"""
|
|
43
|
-
super().__init__(
|
|
44
|
-
name=name,
|
|
45
|
-
system_message=system_message,
|
|
46
|
-
description=description,
|
|
47
|
-
**kwargs,
|
|
48
|
-
)
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
import json
|
|
8
|
-
|
|
9
|
-
from pydantic import BaseModel
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Task(BaseModel):
|
|
13
|
-
"""
|
|
14
|
-
Class representing a task for agent completion, includes example agent execution for criteria generation.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
name: str
|
|
18
|
-
description: str
|
|
19
|
-
successful_response: str
|
|
20
|
-
failed_response: str
|
|
21
|
-
|
|
22
|
-
def get_sys_message(self):
|
|
23
|
-
return f"""Task: {self.name}.
|
|
24
|
-
Task description: {self.description}
|
|
25
|
-
Task successful example: {self.successful_response}
|
|
26
|
-
Task failed example: {self.failed_response}
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
@staticmethod
|
|
30
|
-
def parse_json_str(task: str):
|
|
31
|
-
"""
|
|
32
|
-
Create a Task object from a json object.
|
|
33
|
-
Args:
|
|
34
|
-
json_data (dict): A dictionary that represents the task.
|
|
35
|
-
Returns:
|
|
36
|
-
Task: A Task object that represents the json task information.
|
|
37
|
-
"""
|
|
38
|
-
json_data = json.loads(task)
|
|
39
|
-
name = json_data.get("name")
|
|
40
|
-
description = json_data.get("description")
|
|
41
|
-
successful_response = json_data.get("successful_response")
|
|
42
|
-
failed_response = json_data.get("failed_response")
|
|
43
|
-
return Task(name, description, successful_response, failed_response)
|