ag2 0.9.9__py3-none-any.whl → 0.10.0__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 (113) hide show
  1. {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/METADATA +243 -214
  2. {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/RECORD +113 -87
  3. autogen/_website/generate_mkdocs.py +3 -3
  4. autogen/_website/notebook_processor.py +1 -1
  5. autogen/_website/utils.py +1 -1
  6. autogen/a2a/__init__.py +36 -0
  7. autogen/a2a/agent_executor.py +105 -0
  8. autogen/a2a/client.py +280 -0
  9. autogen/a2a/errors.py +18 -0
  10. autogen/a2a/httpx_client_factory.py +79 -0
  11. autogen/a2a/server.py +221 -0
  12. autogen/a2a/utils.py +165 -0
  13. autogen/agentchat/__init__.py +3 -0
  14. autogen/agentchat/agent.py +0 -2
  15. autogen/agentchat/assistant_agent.py +15 -15
  16. autogen/agentchat/chat.py +57 -41
  17. autogen/agentchat/contrib/agent_eval/criterion.py +1 -1
  18. autogen/agentchat/contrib/capabilities/text_compressors.py +5 -5
  19. autogen/agentchat/contrib/capabilities/tools_capability.py +1 -1
  20. autogen/agentchat/contrib/capabilities/transforms.py +1 -1
  21. autogen/agentchat/contrib/captainagent/agent_builder.py +1 -1
  22. autogen/agentchat/contrib/captainagent/captainagent.py +20 -19
  23. autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +2 -5
  24. autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +5 -5
  25. autogen/agentchat/contrib/graph_rag/neo4j_graph_query_engine.py +18 -17
  26. autogen/agentchat/contrib/llava_agent.py +1 -13
  27. autogen/agentchat/contrib/rag/mongodb_query_engine.py +2 -2
  28. autogen/agentchat/contrib/rag/query_engine.py +11 -11
  29. autogen/agentchat/contrib/retrieve_assistant_agent.py +3 -0
  30. autogen/agentchat/contrib/swarm_agent.py +3 -2
  31. autogen/agentchat/contrib/vectordb/couchbase.py +1 -1
  32. autogen/agentchat/contrib/vectordb/mongodb.py +1 -1
  33. autogen/agentchat/contrib/web_surfer.py +1 -1
  34. autogen/agentchat/conversable_agent.py +359 -150
  35. autogen/agentchat/group/context_expression.py +21 -21
  36. autogen/agentchat/group/group_tool_executor.py +46 -15
  37. autogen/agentchat/group/guardrails.py +41 -33
  38. autogen/agentchat/group/handoffs.py +11 -11
  39. autogen/agentchat/group/multi_agent_chat.py +56 -2
  40. autogen/agentchat/group/on_condition.py +11 -11
  41. autogen/agentchat/group/safeguards/__init__.py +21 -0
  42. autogen/agentchat/group/safeguards/api.py +241 -0
  43. autogen/agentchat/group/safeguards/enforcer.py +1158 -0
  44. autogen/agentchat/group/safeguards/events.py +119 -0
  45. autogen/agentchat/group/safeguards/validator.py +435 -0
  46. autogen/agentchat/groupchat.py +102 -49
  47. autogen/agentchat/realtime/experimental/clients/realtime_client.py +2 -2
  48. autogen/agentchat/realtime/experimental/function_observer.py +2 -3
  49. autogen/agentchat/realtime/experimental/realtime_agent.py +2 -3
  50. autogen/agentchat/realtime/experimental/realtime_swarm.py +22 -13
  51. autogen/agentchat/user_proxy_agent.py +55 -53
  52. autogen/agents/experimental/document_agent/document_agent.py +1 -10
  53. autogen/agents/experimental/document_agent/parser_utils.py +5 -1
  54. autogen/browser_utils.py +4 -4
  55. autogen/cache/abstract_cache_base.py +2 -6
  56. autogen/cache/disk_cache.py +1 -6
  57. autogen/cache/in_memory_cache.py +2 -6
  58. autogen/cache/redis_cache.py +1 -5
  59. autogen/coding/__init__.py +10 -2
  60. autogen/coding/base.py +2 -1
  61. autogen/coding/docker_commandline_code_executor.py +1 -6
  62. autogen/coding/factory.py +9 -0
  63. autogen/coding/jupyter/docker_jupyter_server.py +1 -7
  64. autogen/coding/jupyter/jupyter_client.py +2 -9
  65. autogen/coding/jupyter/jupyter_code_executor.py +2 -7
  66. autogen/coding/jupyter/local_jupyter_server.py +2 -6
  67. autogen/coding/local_commandline_code_executor.py +0 -65
  68. autogen/coding/yepcode_code_executor.py +197 -0
  69. autogen/environments/docker_python_environment.py +3 -3
  70. autogen/environments/system_python_environment.py +5 -5
  71. autogen/environments/venv_python_environment.py +5 -5
  72. autogen/events/agent_events.py +1 -1
  73. autogen/events/client_events.py +1 -1
  74. autogen/fast_depends/utils.py +10 -0
  75. autogen/graph_utils.py +5 -7
  76. autogen/import_utils.py +3 -1
  77. autogen/interop/pydantic_ai/pydantic_ai.py +8 -5
  78. autogen/io/processors/console_event_processor.py +8 -3
  79. autogen/llm_config/client.py +3 -2
  80. autogen/llm_config/config.py +168 -91
  81. autogen/llm_config/entry.py +38 -26
  82. autogen/llm_config/types.py +35 -0
  83. autogen/llm_config/utils.py +223 -0
  84. autogen/mcp/mcp_proxy/operation_grouping.py +48 -39
  85. autogen/messages/agent_messages.py +1 -1
  86. autogen/messages/client_messages.py +1 -1
  87. autogen/oai/__init__.py +8 -1
  88. autogen/oai/bedrock.py +0 -13
  89. autogen/oai/client.py +25 -11
  90. autogen/oai/client_utils.py +31 -1
  91. autogen/oai/cohere.py +4 -14
  92. autogen/oai/gemini.py +4 -6
  93. autogen/oai/gemini_types.py +1 -0
  94. autogen/oai/openai_utils.py +44 -115
  95. autogen/remote/__init__.py +18 -0
  96. autogen/remote/agent.py +199 -0
  97. autogen/remote/agent_service.py +142 -0
  98. autogen/remote/errors.py +17 -0
  99. autogen/remote/httpx_client_factory.py +131 -0
  100. autogen/remote/protocol.py +37 -0
  101. autogen/remote/retry.py +102 -0
  102. autogen/remote/runtime.py +96 -0
  103. autogen/testing/__init__.py +12 -0
  104. autogen/testing/messages.py +45 -0
  105. autogen/testing/test_agent.py +111 -0
  106. autogen/tools/dependency_injection.py +4 -8
  107. autogen/tools/experimental/reliable/reliable.py +3 -2
  108. autogen/tools/experimental/web_search_preview/web_search_preview.py +1 -1
  109. autogen/tools/function_utils.py +2 -1
  110. autogen/version.py +1 -1
  111. {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/WHEEL +0 -0
  112. {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/licenses/LICENSE +0 -0
  113. {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/licenses/NOTICE.md +0 -0
@@ -6,7 +6,6 @@
6
6
  # SPDX-License-Identifier: MIT
7
7
  import json
8
8
  import logging
9
- import warnings
10
9
  from typing import Any
11
10
 
12
11
  import requests
@@ -85,18 +84,7 @@ class LLaVAAgent(MultimodalConversableAgent):
85
84
  retry = 10
86
85
  while len(out) == 0 and retry > 0:
87
86
  # image names will be inferred automatically from llava_call
88
- if "max_new_tokens" in self.llm_config:
89
- warnings.warn(
90
- (
91
- "`max_new_tokens` is deprecated in `llm_config` for llava agents. "
92
- "Use `max_tokens` instead. "
93
- "Scheduled for removal in 0.10.0 version."
94
- ),
95
- DeprecationWarning,
96
- )
97
- max_tokens = self.llm_config["max_new_tokens"]
98
- else:
99
- max_tokens = self.llm_config.get("max_tokens")
87
+ max_tokens = self.llm_config.get("max_tokens")
100
88
 
101
89
  out = llava_call_binary(
102
90
  prompt=prompt,
@@ -17,7 +17,7 @@ with optional_import_block():
17
17
  from llama_index.core import SimpleDirectoryReader, StorageContext, VectorStoreIndex
18
18
  from llama_index.core.embeddings import BaseEmbedding
19
19
  from llama_index.core.schema import Document as LlamaDocument
20
- from llama_index.llms.langchain.base import LLM
20
+ from llama_index.llms.langchain.base import LLM # type: ignore[attr-defined]
21
21
  from llama_index.llms.openai import OpenAI
22
22
  from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch
23
23
  from pymongo import MongoClient
@@ -114,7 +114,7 @@ class MongoDBQueryEngine:
114
114
  logger.info("Vector database created.")
115
115
  self.vector_search_engine = MongoDBAtlasVectorSearch(
116
116
  mongodb_client=self.vector_db.client, # type: ignore[union-attr]
117
- db_name=self.database_name,
117
+ db_name=self.database_name, # type: ignore[arg-type]
118
118
  collection_name=self.collection_name,
119
119
  )
120
120
  logger.info("Vector search engine created.")
@@ -29,18 +29,18 @@ class RAGQueryEngine(Protocol):
29
29
  """Initialize the database with the input documents or records.
30
30
 
31
31
  This method initializes database with the input documents or records.
32
- Usually, it takes the following steps:
33
- 1. connecting to a database.
34
- 2. insert records
35
- 3. build indexes etc.
32
+ Usually, it takes the following steps:\n
33
+ 1. connecting to a database.\n
34
+ 2. insert records.\n
35
+ 3. build indexes etc.\n
36
36
 
37
- Args:
38
- new_doc_dir (Optional[Union[Path, str]]): A directory containing documents to be ingested.
39
- new_doc_paths_or_urls (Optional[Sequence[Union[Path, str]]]): A list of paths or URLs to documents to be ingested.
40
- *args: Any additional arguments
41
- **kwargs: Any additional keyword arguments
42
- Returns:
43
- bool: True if initialization is successful, False otherwise
37
+ Args:\n
38
+ new_doc_dir (Optional[Union[Path, str]]): A directory containing documents to be ingested.\n
39
+ new_doc_paths_or_urls (Optional[Sequence[Union[Path, str]]]): A list of paths or URLs to documents to be ingested.\n
40
+ *args: Any additional arguments\n
41
+ **kwargs: Any additional keyword arguments\n
42
+ Returns:\n
43
+ bool: True if initialization is successful, False otherwise\n
44
44
  """
45
45
  ...
46
46
 
@@ -7,10 +7,13 @@
7
7
  import warnings
8
8
  from typing import Any
9
9
 
10
+ from typing_extensions import deprecated
11
+
10
12
  from ..agent import Agent
11
13
  from ..assistant_agent import AssistantAgent
12
14
 
13
15
 
16
+ @deprecated("The RetrieveAssistantAgent is deprecated. Please use the AssistantAgent instead.")
14
17
  class RetrieveAssistantAgent(AssistantAgent):
15
18
  """(Experimental) Retrieve Assistant agent, designed to solve a task with LLM.
16
19
 
@@ -1163,8 +1163,9 @@ async def a_run_swarm(
1163
1163
  except Exception as e:
1164
1164
  response.iostream.send(ErrorEvent(error=e)) # type: ignore[call-arg]
1165
1165
 
1166
- asyncio.create_task(stream_run())
1167
-
1166
+ task = asyncio.create_task(stream_run())
1167
+ # prevent the task from being garbage collected
1168
+ response._task_ref = task # type: ignore[attr-defined]
1168
1169
  return response
1169
1170
 
1170
1171
 
@@ -279,7 +279,7 @@ class CouchbaseVectorDB(VectorDB):
279
279
 
280
280
  for i in range(0, len(docs), batch_size):
281
281
  batch = docs[i : i + batch_size]
282
- docs_to_upsert = dict()
282
+ docs_to_upsert = {}
283
283
  for doc in batch:
284
284
  doc_id = doc["id"]
285
285
  embedding = self.embedding_function([
@@ -437,7 +437,7 @@ class MongoDBAtlasVectorDB(VectorDB):
437
437
  if include is None:
438
438
  include_fields = {"_id": 1, "content": 1, "metadata": 1}
439
439
  else:
440
- include_fields = {k: 1 for k in set(include).union({"_id"})}
440
+ include_fields = dict.fromkeys(set(include).union({"_id"}), 1)
441
441
  collection = self.get_collection(collection_name)
442
442
  if ids is not None:
443
443
  docs = collection.find({"_id": {"$in": ids}}, include_fields)
@@ -277,7 +277,7 @@ class WebSurferAgent(ConversableAgent):
277
277
  self._assistant.reset() # type: ignore[no-untyped-call]
278
278
 
279
279
  # Clone the messages to give context
280
- self._assistant.chat_messages[self._user_proxy] = list()
280
+ self._assistant.chat_messages[self._user_proxy] = []
281
281
  history = messages[0 : len(messages) - 1]
282
282
  for message in history:
283
283
  self._assistant.chat_messages[self._user_proxy].append(message)