ag2 0.4b1__py3-none-any.whl → 0.4.2b1__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.

Files changed (118) hide show
  1. ag2-0.4.2b1.dist-info/METADATA +19 -0
  2. ag2-0.4.2b1.dist-info/RECORD +6 -0
  3. ag2-0.4.2b1.dist-info/top_level.txt +1 -0
  4. ag2-0.4b1.dist-info/METADATA +0 -496
  5. ag2-0.4b1.dist-info/RECORD +0 -115
  6. ag2-0.4b1.dist-info/top_level.txt +0 -1
  7. autogen/__init__.py +0 -17
  8. autogen/_pydantic.py +0 -116
  9. autogen/agentchat/__init__.py +0 -42
  10. autogen/agentchat/agent.py +0 -142
  11. autogen/agentchat/assistant_agent.py +0 -85
  12. autogen/agentchat/chat.py +0 -306
  13. autogen/agentchat/contrib/__init__.py +0 -0
  14. autogen/agentchat/contrib/agent_builder.py +0 -787
  15. autogen/agentchat/contrib/agent_optimizer.py +0 -450
  16. autogen/agentchat/contrib/capabilities/__init__.py +0 -0
  17. autogen/agentchat/contrib/capabilities/agent_capability.py +0 -21
  18. autogen/agentchat/contrib/capabilities/generate_images.py +0 -297
  19. autogen/agentchat/contrib/capabilities/teachability.py +0 -406
  20. autogen/agentchat/contrib/capabilities/text_compressors.py +0 -72
  21. autogen/agentchat/contrib/capabilities/transform_messages.py +0 -92
  22. autogen/agentchat/contrib/capabilities/transforms.py +0 -565
  23. autogen/agentchat/contrib/capabilities/transforms_util.py +0 -120
  24. autogen/agentchat/contrib/capabilities/vision_capability.py +0 -217
  25. autogen/agentchat/contrib/captainagent.py +0 -487
  26. autogen/agentchat/contrib/gpt_assistant_agent.py +0 -545
  27. autogen/agentchat/contrib/graph_rag/__init__.py +0 -0
  28. autogen/agentchat/contrib/graph_rag/document.py +0 -24
  29. autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +0 -76
  30. autogen/agentchat/contrib/graph_rag/graph_query_engine.py +0 -50
  31. autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +0 -56
  32. autogen/agentchat/contrib/img_utils.py +0 -390
  33. autogen/agentchat/contrib/llamaindex_conversable_agent.py +0 -123
  34. autogen/agentchat/contrib/llava_agent.py +0 -176
  35. autogen/agentchat/contrib/math_user_proxy_agent.py +0 -471
  36. autogen/agentchat/contrib/multimodal_conversable_agent.py +0 -128
  37. autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +0 -325
  38. autogen/agentchat/contrib/retrieve_assistant_agent.py +0 -56
  39. autogen/agentchat/contrib/retrieve_user_proxy_agent.py +0 -701
  40. autogen/agentchat/contrib/society_of_mind_agent.py +0 -203
  41. autogen/agentchat/contrib/swarm_agent.py +0 -414
  42. autogen/agentchat/contrib/text_analyzer_agent.py +0 -76
  43. autogen/agentchat/contrib/tool_retriever.py +0 -114
  44. autogen/agentchat/contrib/vectordb/__init__.py +0 -0
  45. autogen/agentchat/contrib/vectordb/base.py +0 -243
  46. autogen/agentchat/contrib/vectordb/chromadb.py +0 -326
  47. autogen/agentchat/contrib/vectordb/mongodb.py +0 -559
  48. autogen/agentchat/contrib/vectordb/pgvectordb.py +0 -958
  49. autogen/agentchat/contrib/vectordb/qdrant.py +0 -334
  50. autogen/agentchat/contrib/vectordb/utils.py +0 -126
  51. autogen/agentchat/contrib/web_surfer.py +0 -305
  52. autogen/agentchat/conversable_agent.py +0 -2908
  53. autogen/agentchat/groupchat.py +0 -1668
  54. autogen/agentchat/user_proxy_agent.py +0 -109
  55. autogen/agentchat/utils.py +0 -207
  56. autogen/browser_utils.py +0 -291
  57. autogen/cache/__init__.py +0 -10
  58. autogen/cache/abstract_cache_base.py +0 -78
  59. autogen/cache/cache.py +0 -182
  60. autogen/cache/cache_factory.py +0 -85
  61. autogen/cache/cosmos_db_cache.py +0 -150
  62. autogen/cache/disk_cache.py +0 -109
  63. autogen/cache/in_memory_cache.py +0 -61
  64. autogen/cache/redis_cache.py +0 -128
  65. autogen/code_utils.py +0 -745
  66. autogen/coding/__init__.py +0 -22
  67. autogen/coding/base.py +0 -113
  68. autogen/coding/docker_commandline_code_executor.py +0 -262
  69. autogen/coding/factory.py +0 -45
  70. autogen/coding/func_with_reqs.py +0 -203
  71. autogen/coding/jupyter/__init__.py +0 -22
  72. autogen/coding/jupyter/base.py +0 -32
  73. autogen/coding/jupyter/docker_jupyter_server.py +0 -164
  74. autogen/coding/jupyter/embedded_ipython_code_executor.py +0 -182
  75. autogen/coding/jupyter/jupyter_client.py +0 -224
  76. autogen/coding/jupyter/jupyter_code_executor.py +0 -161
  77. autogen/coding/jupyter/local_jupyter_server.py +0 -168
  78. autogen/coding/local_commandline_code_executor.py +0 -410
  79. autogen/coding/markdown_code_extractor.py +0 -44
  80. autogen/coding/utils.py +0 -57
  81. autogen/exception_utils.py +0 -46
  82. autogen/extensions/__init__.py +0 -0
  83. autogen/formatting_utils.py +0 -76
  84. autogen/function_utils.py +0 -362
  85. autogen/graph_utils.py +0 -148
  86. autogen/io/__init__.py +0 -15
  87. autogen/io/base.py +0 -105
  88. autogen/io/console.py +0 -43
  89. autogen/io/websockets.py +0 -213
  90. autogen/logger/__init__.py +0 -11
  91. autogen/logger/base_logger.py +0 -140
  92. autogen/logger/file_logger.py +0 -287
  93. autogen/logger/logger_factory.py +0 -29
  94. autogen/logger/logger_utils.py +0 -42
  95. autogen/logger/sqlite_logger.py +0 -459
  96. autogen/math_utils.py +0 -356
  97. autogen/oai/__init__.py +0 -33
  98. autogen/oai/anthropic.py +0 -428
  99. autogen/oai/bedrock.py +0 -600
  100. autogen/oai/cerebras.py +0 -264
  101. autogen/oai/client.py +0 -1148
  102. autogen/oai/client_utils.py +0 -167
  103. autogen/oai/cohere.py +0 -453
  104. autogen/oai/completion.py +0 -1216
  105. autogen/oai/gemini.py +0 -469
  106. autogen/oai/groq.py +0 -281
  107. autogen/oai/mistral.py +0 -279
  108. autogen/oai/ollama.py +0 -576
  109. autogen/oai/openai_utils.py +0 -810
  110. autogen/oai/together.py +0 -343
  111. autogen/retrieve_utils.py +0 -487
  112. autogen/runtime_logging.py +0 -163
  113. autogen/token_count_utils.py +0 -257
  114. autogen/types.py +0 -20
  115. autogen/version.py +0 -7
  116. {ag2-0.4b1.dist-info → ag2-0.4.2b1.dist-info}/LICENSE +0 -0
  117. {ag2-0.4b1.dist-info → ag2-0.4.2b1.dist-info}/NOTICE.md +0 -0
  118. {ag2-0.4b1.dist-info → ag2-0.4.2b1.dist-info}/WHEEL +0 -0
autogen/__init__.py DELETED
@@ -1,17 +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 logging
8
-
9
- from .agentchat import *
10
- from .code_utils import DEFAULT_MODEL, FAST_MODEL
11
- from .exception_utils import *
12
- from .oai import *
13
- from .version import __version__
14
-
15
- # Set the root logger.
16
- logger = logging.getLogger(__name__)
17
- logger.setLevel(logging.INFO)
autogen/_pydantic.py DELETED
@@ -1,116 +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 Any, Dict, Optional, Tuple, Type, Union, get_args
8
-
9
- from pydantic import BaseModel
10
- from pydantic.version import VERSION as PYDANTIC_VERSION
11
- from typing_extensions import get_origin
12
-
13
- __all__ = ("JsonSchemaValue", "model_dump", "model_dump_json", "type2schema", "evaluate_forwardref")
14
-
15
- PYDANTIC_V1 = PYDANTIC_VERSION.startswith("1.")
16
-
17
- if not PYDANTIC_V1:
18
- from pydantic import TypeAdapter
19
- from pydantic._internal._typing_extra import eval_type_lenient as evaluate_forwardref
20
- from pydantic.json_schema import JsonSchemaValue
21
-
22
- def type2schema(t: Any) -> JsonSchemaValue:
23
- """Convert a type to a JSON schema
24
-
25
- Args:
26
- t (Type): The type to convert
27
-
28
- Returns:
29
- JsonSchemaValue: The JSON schema
30
- """
31
- return TypeAdapter(t).json_schema()
32
-
33
- def model_dump(model: BaseModel) -> Dict[str, Any]:
34
- """Convert a pydantic model to a dict
35
-
36
- Args:
37
- model (BaseModel): The model to convert
38
-
39
- Returns:
40
- Dict[str, Any]: The dict representation of the model
41
-
42
- """
43
- return model.model_dump()
44
-
45
- def model_dump_json(model: BaseModel) -> str:
46
- """Convert a pydantic model to a JSON string
47
-
48
- Args:
49
- model (BaseModel): The model to convert
50
-
51
- Returns:
52
- str: The JSON string representation of the model
53
- """
54
- return model.model_dump_json()
55
-
56
-
57
- # Remove this once we drop support for pydantic 1.x
58
- else: # pragma: no cover
59
- from pydantic import schema_of
60
- from pydantic.typing import evaluate_forwardref as evaluate_forwardref # type: ignore[no-redef]
61
-
62
- JsonSchemaValue = Dict[str, Any] # type: ignore[misc]
63
-
64
- def type2schema(t: Any) -> JsonSchemaValue:
65
- """Convert a type to a JSON schema
66
-
67
- Args:
68
- t (Type): The type to convert
69
-
70
- Returns:
71
- JsonSchemaValue: The JSON schema
72
- """
73
-
74
- if t is None:
75
- return {"type": "null"}
76
- elif get_origin(t) is Union:
77
- return {"anyOf": [type2schema(tt) for tt in get_args(t)]}
78
- elif get_origin(t) in [Tuple, tuple]:
79
- prefixItems = [type2schema(tt) for tt in get_args(t)]
80
- return {
81
- "maxItems": len(prefixItems),
82
- "minItems": len(prefixItems),
83
- "prefixItems": prefixItems,
84
- "type": "array",
85
- }
86
- else:
87
- d = schema_of(t)
88
- if "title" in d:
89
- d.pop("title")
90
- if "description" in d:
91
- d.pop("description")
92
-
93
- return d
94
-
95
- def model_dump(model: BaseModel) -> Dict[str, Any]:
96
- """Convert a pydantic model to a dict
97
-
98
- Args:
99
- model (BaseModel): The model to convert
100
-
101
- Returns:
102
- Dict[str, Any]: The dict representation of the model
103
-
104
- """
105
- return model.dict()
106
-
107
- def model_dump_json(model: BaseModel) -> str:
108
- """Convert a pydantic model to a JSON string
109
-
110
- Args:
111
- model (BaseModel): The model to convert
112
-
113
- Returns:
114
- str: The JSON string representation of the model
115
- """
116
- return model.json()
@@ -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 .agent import Agent
8
- from .assistant_agent import AssistantAgent
9
- from .chat import ChatResult, initiate_chats
10
-
11
- # Imported last to avoid circular imports
12
- from .contrib.swarm_agent import (
13
- AFTER_WORK,
14
- ON_CONDITION,
15
- AfterWorkOption,
16
- SwarmAgent,
17
- SwarmResult,
18
- initiate_swarm_chat,
19
- )
20
- from .conversable_agent import ConversableAgent, register_function
21
- from .groupchat import GroupChat, GroupChatManager
22
- from .user_proxy_agent import UserProxyAgent
23
- from .utils import gather_usage_summary
24
-
25
- __all__ = [
26
- "Agent",
27
- "ConversableAgent",
28
- "AssistantAgent",
29
- "UserProxyAgent",
30
- "GroupChat",
31
- "GroupChatManager",
32
- "register_function",
33
- "initiate_chats",
34
- "gather_usage_summary",
35
- "ChatResult",
36
- "initiate_swarm_chat",
37
- "SwarmAgent",
38
- "SwarmResult",
39
- "ON_CONDITION",
40
- "AFTER_WORK",
41
- "AfterWorkOption",
42
- ]
@@ -1,142 +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 Any, Dict, List, Optional, Protocol, Union, runtime_checkable
8
-
9
-
10
- @runtime_checkable
11
- class Agent(Protocol):
12
- """(In preview) A protocol for Agent.
13
-
14
- An agent can communicate with other agents and perform actions.
15
- Different agents can differ in what actions they perform in the `receive` method.
16
- """
17
-
18
- @property
19
- def name(self) -> str:
20
- """The name of the agent."""
21
- ...
22
-
23
- @property
24
- def description(self) -> str:
25
- """The description of the agent. Used for the agent's introduction in
26
- a group chat setting."""
27
- ...
28
-
29
- def send(
30
- self,
31
- message: Union[Dict[str, Any], str],
32
- recipient: "Agent",
33
- request_reply: Optional[bool] = None,
34
- ) -> None:
35
- """Send a message to another agent.
36
-
37
- Args:
38
- message (dict or str): the message to send. If a dict, it should be
39
- a JSON-serializable and follows the OpenAI's ChatCompletion schema.
40
- recipient (Agent): the recipient of the message.
41
- request_reply (bool): whether to request a reply from the recipient.
42
- """
43
- ...
44
-
45
- async def a_send(
46
- self,
47
- message: Union[Dict[str, Any], str],
48
- recipient: "Agent",
49
- request_reply: Optional[bool] = None,
50
- ) -> None:
51
- """(Async) Send a message to another agent.
52
-
53
- Args:
54
- message (dict or str): the message to send. If a dict, it should be
55
- a JSON-serializable and follows the OpenAI's ChatCompletion schema.
56
- recipient (Agent): the recipient of the message.
57
- request_reply (bool): whether to request a reply from the recipient.
58
- """
59
- ...
60
-
61
- def receive(
62
- self,
63
- message: Union[Dict[str, Any], str],
64
- sender: "Agent",
65
- request_reply: Optional[bool] = None,
66
- ) -> None:
67
- """Receive a message from another agent.
68
-
69
- Args:
70
- message (dict or str): the message received. If a dict, it should be
71
- a JSON-serializable and follows the OpenAI's ChatCompletion schema.
72
- sender (Agent): the sender of the message.
73
- request_reply (bool): whether the sender requests a reply.
74
- """
75
-
76
- async def a_receive(
77
- self,
78
- message: Union[Dict[str, Any], str],
79
- sender: "Agent",
80
- request_reply: Optional[bool] = None,
81
- ) -> None:
82
- """(Async) Receive a message from another agent.
83
-
84
- Args:
85
- message (dict or str): the message received. If a dict, it should be
86
- a JSON-serializable and follows the OpenAI's ChatCompletion schema.
87
- sender (Agent): the sender of the message.
88
- request_reply (bool): whether the sender requests a reply.
89
- """
90
- ...
91
-
92
- def generate_reply(
93
- self,
94
- messages: Optional[List[Dict[str, Any]]] = None,
95
- sender: Optional["Agent"] = None,
96
- **kwargs: Any,
97
- ) -> Union[str, Dict[str, Any], None]:
98
- """Generate a reply based on the received messages.
99
-
100
- Args:
101
- messages (list[dict]): a list of messages received from other agents.
102
- The messages are dictionaries that are JSON-serializable and
103
- follows the OpenAI's ChatCompletion schema.
104
- sender: sender of an Agent instance.
105
-
106
- Returns:
107
- str or dict or None: the generated reply. If None, no reply is generated.
108
- """
109
-
110
- async def a_generate_reply(
111
- self,
112
- messages: Optional[List[Dict[str, Any]]] = None,
113
- sender: Optional["Agent"] = None,
114
- **kwargs: Any,
115
- ) -> Union[str, Dict[str, Any], None]:
116
- """(Async) Generate a reply based on the received messages.
117
-
118
- Args:
119
- messages (list[dict]): a list of messages received from other agents.
120
- The messages are dictionaries that are JSON-serializable and
121
- follows the OpenAI's ChatCompletion schema.
122
- sender: sender of an Agent instance.
123
-
124
- Returns:
125
- str or dict or None: the generated reply. If None, no reply is generated.
126
- """
127
-
128
-
129
- @runtime_checkable
130
- class LLMAgent(Agent, Protocol):
131
- """(In preview) A protocol for an LLM agent."""
132
-
133
- @property
134
- def system_message(self) -> str:
135
- """The system message of this agent."""
136
-
137
- def update_system_message(self, system_message: str) -> None:
138
- """Update this agent's system message.
139
-
140
- Args:
141
- system_message (str): system message for inference.
142
- """
@@ -1,85 +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 Callable, Dict, Literal, Optional, Union
8
-
9
- from autogen.runtime_logging import log_new_agent, logging_enabled
10
-
11
- from .conversable_agent import ConversableAgent
12
-
13
-
14
- class AssistantAgent(ConversableAgent):
15
- """(In preview) Assistant agent, designed to solve a task with LLM.
16
-
17
- AssistantAgent is a subclass of ConversableAgent configured with a default system message.
18
- The default system message is designed to solve a task with LLM,
19
- including suggesting python code blocks and debugging.
20
- `human_input_mode` is default to "NEVER"
21
- and `code_execution_config` is default to False.
22
- This agent doesn't execute code by default, and expects the user to execute the code.
23
- """
24
-
25
- DEFAULT_SYSTEM_MESSAGE = """You are a helpful AI assistant.
26
- Solve tasks using your coding and language skills.
27
- In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.
28
- 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.
29
- 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.
30
- Solve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.
31
- When using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.
32
- If you want the user to save the code in a file before executing it, put # filename: <filename> inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.
33
- If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.
34
- When you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.
35
- Reply "TERMINATE" in the end when everything is done.
36
- """
37
-
38
- DEFAULT_DESCRIPTION = "A helpful and general-purpose AI assistant that has strong language skills, Python skills, and Linux command line skills."
39
-
40
- def __init__(
41
- self,
42
- name: str,
43
- system_message: Optional[str] = DEFAULT_SYSTEM_MESSAGE,
44
- llm_config: Optional[Union[Dict, Literal[False]]] = None,
45
- is_termination_msg: Optional[Callable[[Dict], bool]] = None,
46
- max_consecutive_auto_reply: Optional[int] = None,
47
- human_input_mode: Literal["ALWAYS", "NEVER", "TERMINATE"] = "NEVER",
48
- description: Optional[str] = None,
49
- **kwargs,
50
- ):
51
- """
52
- Args:
53
- name (str): agent name.
54
- system_message (str): system message for the ChatCompletion inference.
55
- Please override this attribute if you want to reprogram the agent.
56
- llm_config (dict or False or None): llm inference configuration.
57
- Please refer to [OpenAIWrapper.create](/docs/reference/oai/client#create)
58
- for available options.
59
- is_termination_msg (function): a function that takes a message in the form of a dictionary
60
- and returns a boolean value indicating if this received message is a termination message.
61
- The dict can contain the following keys: "content", "role", "name", "function_call".
62
- max_consecutive_auto_reply (int): the maximum number of consecutive auto replies.
63
- default to None (no limit provided, class attribute MAX_CONSECUTIVE_AUTO_REPLY will be used as the limit in this case).
64
- The limit only plays a role when human_input_mode is not "ALWAYS".
65
- **kwargs (dict): Please refer to other kwargs in
66
- [ConversableAgent](conversable_agent#__init__).
67
- """
68
- super().__init__(
69
- name,
70
- system_message,
71
- is_termination_msg,
72
- max_consecutive_auto_reply,
73
- human_input_mode,
74
- llm_config=llm_config,
75
- description=description,
76
- **kwargs,
77
- )
78
- if logging_enabled():
79
- log_new_agent(self, locals())
80
-
81
- # Update the provided description if None, and we are using the default system_message,
82
- # then use the default description.
83
- if description is None:
84
- if system_message == self.DEFAULT_SYSTEM_MESSAGE:
85
- self.description = self.DEFAULT_DESCRIPTION