ag2 0.9.6__py3-none-any.whl → 0.9.8.post1__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.9.6.dist-info → ag2-0.9.8.post1.dist-info}/METADATA +102 -75
- ag2-0.9.8.post1.dist-info/RECORD +387 -0
- autogen/__init__.py +1 -2
- autogen/_website/generate_api_references.py +4 -5
- autogen/_website/generate_mkdocs.py +9 -15
- autogen/_website/notebook_processor.py +13 -14
- autogen/_website/process_notebooks.py +10 -10
- autogen/_website/utils.py +5 -4
- autogen/agentchat/agent.py +13 -13
- autogen/agentchat/assistant_agent.py +7 -6
- autogen/agentchat/contrib/agent_eval/agent_eval.py +3 -3
- autogen/agentchat/contrib/agent_eval/critic_agent.py +3 -3
- autogen/agentchat/contrib/agent_eval/quantifier_agent.py +3 -3
- autogen/agentchat/contrib/agent_eval/subcritic_agent.py +3 -3
- autogen/agentchat/contrib/agent_optimizer.py +3 -3
- autogen/agentchat/contrib/capabilities/generate_images.py +11 -11
- autogen/agentchat/contrib/capabilities/teachability.py +15 -15
- autogen/agentchat/contrib/capabilities/transforms.py +17 -18
- autogen/agentchat/contrib/capabilities/transforms_util.py +5 -5
- autogen/agentchat/contrib/capabilities/vision_capability.py +4 -3
- autogen/agentchat/contrib/captainagent/agent_builder.py +30 -30
- autogen/agentchat/contrib/captainagent/captainagent.py +22 -21
- autogen/agentchat/contrib/captainagent/tool_retriever.py +2 -3
- autogen/agentchat/contrib/gpt_assistant_agent.py +9 -9
- autogen/agentchat/contrib/graph_rag/document.py +3 -3
- autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +3 -3
- autogen/agentchat/contrib/graph_rag/falkor_graph_rag_capability.py +6 -6
- autogen/agentchat/contrib/graph_rag/graph_query_engine.py +3 -3
- autogen/agentchat/contrib/graph_rag/neo4j_graph_query_engine.py +5 -11
- autogen/agentchat/contrib/graph_rag/neo4j_graph_rag_capability.py +6 -6
- autogen/agentchat/contrib/graph_rag/neo4j_native_graph_query_engine.py +7 -7
- autogen/agentchat/contrib/graph_rag/neo4j_native_graph_rag_capability.py +6 -6
- autogen/agentchat/contrib/img_utils.py +1 -1
- autogen/agentchat/contrib/llamaindex_conversable_agent.py +11 -11
- autogen/agentchat/contrib/llava_agent.py +18 -4
- autogen/agentchat/contrib/math_user_proxy_agent.py +11 -11
- autogen/agentchat/contrib/multimodal_conversable_agent.py +8 -8
- autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +6 -5
- autogen/agentchat/contrib/rag/chromadb_query_engine.py +22 -26
- autogen/agentchat/contrib/rag/llamaindex_query_engine.py +14 -17
- autogen/agentchat/contrib/rag/mongodb_query_engine.py +27 -37
- autogen/agentchat/contrib/rag/query_engine.py +7 -5
- autogen/agentchat/contrib/retrieve_assistant_agent.py +5 -5
- autogen/agentchat/contrib/retrieve_user_proxy_agent.py +8 -7
- autogen/agentchat/contrib/society_of_mind_agent.py +15 -14
- autogen/agentchat/contrib/swarm_agent.py +76 -98
- autogen/agentchat/contrib/text_analyzer_agent.py +7 -7
- autogen/agentchat/contrib/vectordb/base.py +10 -18
- autogen/agentchat/contrib/vectordb/chromadb.py +2 -1
- autogen/agentchat/contrib/vectordb/couchbase.py +18 -20
- autogen/agentchat/contrib/vectordb/mongodb.py +6 -5
- autogen/agentchat/contrib/vectordb/pgvectordb.py +40 -41
- autogen/agentchat/contrib/vectordb/qdrant.py +5 -5
- autogen/agentchat/contrib/web_surfer.py +20 -19
- autogen/agentchat/conversable_agent.py +311 -295
- autogen/agentchat/group/context_str.py +1 -3
- autogen/agentchat/group/context_variables.py +15 -25
- autogen/agentchat/group/group_tool_executor.py +10 -10
- autogen/agentchat/group/group_utils.py +15 -15
- autogen/agentchat/group/guardrails.py +7 -7
- autogen/agentchat/group/handoffs.py +19 -36
- autogen/agentchat/group/multi_agent_chat.py +7 -7
- autogen/agentchat/group/on_condition.py +4 -7
- autogen/agentchat/group/on_context_condition.py +4 -7
- autogen/agentchat/group/patterns/auto.py +8 -7
- autogen/agentchat/group/patterns/manual.py +7 -6
- autogen/agentchat/group/patterns/pattern.py +13 -12
- autogen/agentchat/group/patterns/random.py +3 -3
- autogen/agentchat/group/patterns/round_robin.py +3 -3
- autogen/agentchat/group/reply_result.py +2 -4
- autogen/agentchat/group/speaker_selection_result.py +5 -5
- autogen/agentchat/group/targets/group_chat_target.py +7 -6
- autogen/agentchat/group/targets/group_manager_target.py +4 -4
- autogen/agentchat/group/targets/transition_target.py +2 -1
- autogen/agentchat/groupchat.py +58 -61
- autogen/agentchat/realtime/experimental/audio_adapters/twilio_audio_adapter.py +4 -4
- autogen/agentchat/realtime/experimental/audio_adapters/websocket_audio_adapter.py +4 -4
- autogen/agentchat/realtime/experimental/clients/gemini/client.py +7 -7
- autogen/agentchat/realtime/experimental/clients/oai/base_client.py +8 -8
- autogen/agentchat/realtime/experimental/clients/oai/rtc_client.py +6 -6
- autogen/agentchat/realtime/experimental/clients/realtime_client.py +10 -9
- autogen/agentchat/realtime/experimental/realtime_agent.py +10 -9
- autogen/agentchat/realtime/experimental/realtime_observer.py +3 -3
- autogen/agentchat/realtime/experimental/realtime_swarm.py +44 -44
- autogen/agentchat/user_proxy_agent.py +10 -9
- autogen/agentchat/utils.py +3 -3
- autogen/agents/contrib/time/time_reply_agent.py +6 -5
- autogen/agents/contrib/time/time_tool_agent.py +2 -1
- autogen/agents/experimental/deep_research/deep_research.py +3 -3
- autogen/agents/experimental/discord/discord.py +2 -2
- autogen/agents/experimental/document_agent/chroma_query_engine.py +29 -44
- autogen/agents/experimental/document_agent/docling_doc_ingest_agent.py +9 -14
- autogen/agents/experimental/document_agent/document_agent.py +15 -16
- autogen/agents/experimental/document_agent/document_conditions.py +3 -3
- autogen/agents/experimental/document_agent/document_utils.py +5 -9
- autogen/agents/experimental/document_agent/inmemory_query_engine.py +14 -20
- autogen/agents/experimental/document_agent/parser_utils.py +4 -4
- autogen/agents/experimental/document_agent/url_utils.py +14 -23
- autogen/agents/experimental/reasoning/reasoning_agent.py +33 -33
- autogen/agents/experimental/slack/slack.py +2 -2
- autogen/agents/experimental/telegram/telegram.py +2 -3
- autogen/agents/experimental/websurfer/websurfer.py +4 -4
- autogen/agents/experimental/wikipedia/wikipedia.py +5 -7
- autogen/browser_utils.py +8 -8
- autogen/cache/abstract_cache_base.py +5 -5
- autogen/cache/cache.py +12 -12
- autogen/cache/cache_factory.py +4 -4
- autogen/cache/cosmos_db_cache.py +9 -9
- autogen/cache/disk_cache.py +6 -6
- autogen/cache/in_memory_cache.py +4 -4
- autogen/cache/redis_cache.py +4 -4
- autogen/code_utils.py +18 -18
- autogen/coding/base.py +6 -6
- autogen/coding/docker_commandline_code_executor.py +9 -9
- autogen/coding/func_with_reqs.py +7 -6
- autogen/coding/jupyter/base.py +3 -3
- autogen/coding/jupyter/docker_jupyter_server.py +3 -4
- autogen/coding/jupyter/import_utils.py +3 -3
- autogen/coding/jupyter/jupyter_client.py +5 -5
- autogen/coding/jupyter/jupyter_code_executor.py +3 -4
- autogen/coding/jupyter/local_jupyter_server.py +2 -6
- autogen/coding/local_commandline_code_executor.py +8 -7
- autogen/coding/markdown_code_extractor.py +1 -2
- autogen/coding/utils.py +1 -2
- autogen/doc_utils.py +3 -2
- autogen/environments/docker_python_environment.py +19 -29
- autogen/environments/python_environment.py +8 -17
- autogen/environments/system_python_environment.py +3 -4
- autogen/environments/venv_python_environment.py +8 -12
- autogen/environments/working_directory.py +1 -2
- autogen/events/agent_events.py +106 -109
- autogen/events/base_event.py +6 -5
- autogen/events/client_events.py +15 -14
- autogen/events/helpers.py +1 -1
- autogen/events/print_event.py +4 -5
- autogen/fast_depends/_compat.py +10 -15
- autogen/fast_depends/core/build.py +17 -36
- autogen/fast_depends/core/model.py +64 -113
- autogen/fast_depends/dependencies/model.py +2 -1
- autogen/fast_depends/dependencies/provider.py +3 -2
- autogen/fast_depends/library/model.py +4 -4
- autogen/fast_depends/schema.py +7 -7
- autogen/fast_depends/use.py +17 -25
- autogen/fast_depends/utils.py +10 -30
- autogen/formatting_utils.py +6 -6
- autogen/graph_utils.py +1 -4
- autogen/import_utils.py +13 -13
- autogen/interop/crewai/crewai.py +2 -2
- autogen/interop/interoperable.py +2 -2
- autogen/interop/langchain/langchain_chat_model_factory.py +3 -2
- autogen/interop/langchain/langchain_tool.py +2 -6
- autogen/interop/litellm/litellm_config_factory.py +6 -7
- autogen/interop/pydantic_ai/pydantic_ai.py +4 -7
- autogen/interop/registry.py +2 -1
- autogen/io/base.py +5 -5
- autogen/io/run_response.py +33 -32
- autogen/io/websockets.py +6 -5
- autogen/json_utils.py +1 -2
- autogen/llm_config/__init__.py +11 -0
- autogen/llm_config/client.py +58 -0
- autogen/llm_config/config.py +384 -0
- autogen/llm_config/entry.py +154 -0
- autogen/logger/base_logger.py +4 -3
- autogen/logger/file_logger.py +2 -1
- autogen/logger/logger_factory.py +2 -2
- autogen/logger/logger_utils.py +2 -2
- autogen/logger/sqlite_logger.py +3 -2
- autogen/math_utils.py +4 -5
- autogen/mcp/__main__.py +6 -6
- autogen/mcp/helpers.py +4 -4
- autogen/mcp/mcp_client.py +170 -29
- autogen/mcp/mcp_proxy/fastapi_code_generator_helpers.py +3 -4
- autogen/mcp/mcp_proxy/mcp_proxy.py +23 -26
- autogen/mcp/mcp_proxy/operation_grouping.py +4 -5
- autogen/mcp/mcp_proxy/operation_renaming.py +6 -10
- autogen/mcp/mcp_proxy/security.py +2 -3
- autogen/messages/agent_messages.py +96 -98
- autogen/messages/base_message.py +6 -5
- autogen/messages/client_messages.py +15 -14
- autogen/messages/print_message.py +4 -5
- autogen/oai/__init__.py +1 -2
- autogen/oai/anthropic.py +42 -41
- autogen/oai/bedrock.py +68 -57
- autogen/oai/cerebras.py +26 -25
- autogen/oai/client.py +118 -138
- autogen/oai/client_utils.py +3 -3
- autogen/oai/cohere.py +34 -11
- autogen/oai/gemini.py +40 -17
- autogen/oai/gemini_types.py +11 -12
- autogen/oai/groq.py +22 -10
- autogen/oai/mistral.py +17 -11
- autogen/oai/oai_models/__init__.py +14 -2
- autogen/oai/oai_models/_models.py +2 -2
- autogen/oai/oai_models/chat_completion.py +13 -14
- autogen/oai/oai_models/chat_completion_message.py +11 -9
- autogen/oai/oai_models/chat_completion_message_tool_call.py +26 -3
- autogen/oai/oai_models/chat_completion_token_logprob.py +3 -4
- autogen/oai/oai_models/completion_usage.py +8 -9
- autogen/oai/ollama.py +22 -10
- autogen/oai/openai_responses.py +40 -17
- autogen/oai/openai_utils.py +159 -85
- autogen/oai/together.py +29 -14
- autogen/retrieve_utils.py +6 -7
- autogen/runtime_logging.py +5 -4
- autogen/token_count_utils.py +7 -4
- autogen/tools/contrib/time/time.py +0 -1
- autogen/tools/dependency_injection.py +5 -6
- autogen/tools/experimental/browser_use/browser_use.py +10 -10
- autogen/tools/experimental/code_execution/python_code_execution.py +5 -7
- autogen/tools/experimental/crawl4ai/crawl4ai.py +12 -15
- autogen/tools/experimental/deep_research/deep_research.py +9 -8
- autogen/tools/experimental/duckduckgo/duckduckgo_search.py +5 -11
- autogen/tools/experimental/firecrawl/firecrawl_tool.py +98 -115
- autogen/tools/experimental/google/authentication/credentials_local_provider.py +1 -1
- autogen/tools/experimental/google/drive/drive_functions.py +4 -4
- autogen/tools/experimental/google/drive/toolkit.py +5 -5
- autogen/tools/experimental/google_search/google_search.py +5 -5
- autogen/tools/experimental/google_search/youtube_search.py +5 -5
- autogen/tools/experimental/messageplatform/discord/discord.py +8 -12
- autogen/tools/experimental/messageplatform/slack/slack.py +14 -20
- autogen/tools/experimental/messageplatform/telegram/telegram.py +8 -12
- autogen/tools/experimental/perplexity/perplexity_search.py +18 -29
- autogen/tools/experimental/reliable/reliable.py +68 -74
- autogen/tools/experimental/searxng/searxng_search.py +20 -19
- autogen/tools/experimental/tavily/tavily_search.py +12 -19
- autogen/tools/experimental/web_search_preview/web_search_preview.py +13 -7
- autogen/tools/experimental/wikipedia/wikipedia.py +7 -10
- autogen/tools/function_utils.py +7 -7
- autogen/tools/tool.py +6 -5
- autogen/types.py +2 -2
- autogen/version.py +1 -1
- ag2-0.9.6.dist-info/RECORD +0 -421
- autogen/llm_config.py +0 -385
- {ag2-0.9.6.dist-info → ag2-0.9.8.post1.dist-info}/WHEEL +0 -0
- {ag2-0.9.6.dist-info → ag2-0.9.8.post1.dist-info}/licenses/LICENSE +0 -0
- {ag2-0.9.6.dist-info → ag2-0.9.8.post1.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import os
|
|
8
8
|
import re
|
|
9
9
|
import urllib.parse
|
|
10
|
-
from
|
|
10
|
+
from collections.abc import Callable
|
|
11
|
+
from typing import Any, Optional
|
|
11
12
|
|
|
12
13
|
from ....import_utils import optional_import_block, require_optional_import
|
|
13
14
|
from .base import Document, ItemID, QueryResults, VectorDB
|
|
@@ -41,11 +42,11 @@ class Collection:
|
|
|
41
42
|
|
|
42
43
|
def __init__(
|
|
43
44
|
self,
|
|
44
|
-
client:
|
|
45
|
+
client: Any | None = None,
|
|
45
46
|
collection_name: str = "ag2-docs",
|
|
46
|
-
embedding_function:
|
|
47
|
-
metadata:
|
|
48
|
-
get_or_create:
|
|
47
|
+
embedding_function: Callable[..., Any] | None = None,
|
|
48
|
+
metadata: Any | None = None,
|
|
49
|
+
get_or_create: Any | None = None,
|
|
49
50
|
):
|
|
50
51
|
"""Initialize the Collection object.
|
|
51
52
|
|
|
@@ -85,9 +86,9 @@ class Collection:
|
|
|
85
86
|
def add(
|
|
86
87
|
self,
|
|
87
88
|
ids: list[ItemID],
|
|
88
|
-
documents:
|
|
89
|
-
embeddings:
|
|
90
|
-
metadatas:
|
|
89
|
+
documents: list[Document] | None,
|
|
90
|
+
embeddings: list[Any] | None = None,
|
|
91
|
+
metadatas: list[Any] | None = None,
|
|
91
92
|
) -> None:
|
|
92
93
|
"""Add documents to the collection.
|
|
93
94
|
|
|
@@ -130,8 +131,8 @@ class Collection:
|
|
|
130
131
|
self,
|
|
131
132
|
ids: list[ItemID],
|
|
132
133
|
documents: list[Document],
|
|
133
|
-
embeddings:
|
|
134
|
-
metadatas:
|
|
134
|
+
embeddings: list[Any] | None = None,
|
|
135
|
+
metadatas: list[Any] | None = None,
|
|
135
136
|
) -> None:
|
|
136
137
|
"""Upsert documents into the collection.
|
|
137
138
|
|
|
@@ -232,11 +233,11 @@ class Collection:
|
|
|
232
233
|
|
|
233
234
|
def get(
|
|
234
235
|
self,
|
|
235
|
-
ids:
|
|
236
|
-
include:
|
|
237
|
-
where:
|
|
238
|
-
limit:
|
|
239
|
-
offset:
|
|
236
|
+
ids: str | None = None,
|
|
237
|
+
include: str | None = None,
|
|
238
|
+
where: str | None = None,
|
|
239
|
+
limit: int | str | None = None,
|
|
240
|
+
offset: int | str | None = None,
|
|
240
241
|
) -> list[Document]:
|
|
241
242
|
"""Retrieve documents from the collection.
|
|
242
243
|
|
|
@@ -380,11 +381,11 @@ class Collection:
|
|
|
380
381
|
def query(
|
|
381
382
|
self,
|
|
382
383
|
query_texts: list[str],
|
|
383
|
-
collection_name:
|
|
384
|
-
n_results:
|
|
385
|
-
distance_type:
|
|
386
|
-
distance_threshold:
|
|
387
|
-
include_embedding:
|
|
384
|
+
collection_name: str | None = None,
|
|
385
|
+
n_results: int | None = 10,
|
|
386
|
+
distance_type: str | None = "euclidean",
|
|
387
|
+
distance_threshold: float | None = -1,
|
|
388
|
+
include_embedding: bool | None = False,
|
|
388
389
|
) -> QueryResults:
|
|
389
390
|
"""Query documents in the collection.
|
|
390
391
|
|
|
@@ -465,7 +466,7 @@ class Collection:
|
|
|
465
466
|
array = [float(num) for num in array_string.split()]
|
|
466
467
|
return array
|
|
467
468
|
|
|
468
|
-
def modify(self, metadata, collection_name:
|
|
469
|
+
def modify(self, metadata, collection_name: str | None = None) -> None:
|
|
469
470
|
"""Modify metadata for the collection.
|
|
470
471
|
|
|
471
472
|
Args:
|
|
@@ -481,7 +482,7 @@ class Collection:
|
|
|
481
482
|
cursor.execute("UPDATE collectionsSET metadata = '%s'WHERE collection_name = '%s';", (metadata, self.name))
|
|
482
483
|
cursor.close()
|
|
483
484
|
|
|
484
|
-
def delete(self, ids: list[ItemID], collection_name:
|
|
485
|
+
def delete(self, ids: list[ItemID], collection_name: str | None = None) -> None:
|
|
485
486
|
"""Delete documents from the collection.
|
|
486
487
|
|
|
487
488
|
Args:
|
|
@@ -498,7 +499,7 @@ class Collection:
|
|
|
498
499
|
cursor.execute(f"DELETE FROM {self.name} WHERE id IN ({id_placeholders});", ids)
|
|
499
500
|
cursor.close()
|
|
500
501
|
|
|
501
|
-
def delete_collection(self, collection_name:
|
|
502
|
+
def delete_collection(self, collection_name: str | None = None) -> None:
|
|
502
503
|
"""Delete the entire collection.
|
|
503
504
|
|
|
504
505
|
Args:
|
|
@@ -513,9 +514,7 @@ class Collection:
|
|
|
513
514
|
cursor.execute(f"DROP TABLE IF EXISTS {self.name}")
|
|
514
515
|
cursor.close()
|
|
515
516
|
|
|
516
|
-
def create_collection(
|
|
517
|
-
self, collection_name: Optional[str] = None, dimension: Optional[Union[str, int]] = None
|
|
518
|
-
) -> None:
|
|
517
|
+
def create_collection(self, collection_name: str | None = None, dimension: str | int | None = None) -> None:
|
|
519
518
|
"""Create a new collection.
|
|
520
519
|
|
|
521
520
|
Args:
|
|
@@ -558,15 +557,15 @@ class PGVectorDB(VectorDB):
|
|
|
558
557
|
self,
|
|
559
558
|
*,
|
|
560
559
|
conn: Optional["psycopg.Connection"] = None,
|
|
561
|
-
connection_string:
|
|
562
|
-
host:
|
|
563
|
-
port:
|
|
564
|
-
dbname:
|
|
565
|
-
username:
|
|
566
|
-
password:
|
|
567
|
-
connect_timeout:
|
|
560
|
+
connection_string: str | None = None,
|
|
561
|
+
host: str | None = None,
|
|
562
|
+
port: int | str | None = None,
|
|
563
|
+
dbname: str | None = None,
|
|
564
|
+
username: str | None = None,
|
|
565
|
+
password: str | None = None,
|
|
566
|
+
connect_timeout: int | None = 10,
|
|
568
567
|
embedding_function: Callable = None,
|
|
569
|
-
metadata:
|
|
568
|
+
metadata: dict[str, Any] | None = None,
|
|
570
569
|
) -> None:
|
|
571
570
|
"""Initialize the vector database.
|
|
572
571
|
|
|
@@ -615,13 +614,13 @@ class PGVectorDB(VectorDB):
|
|
|
615
614
|
def establish_connection(
|
|
616
615
|
self,
|
|
617
616
|
conn: Optional["psycopg.Connection"] = None,
|
|
618
|
-
connection_string:
|
|
619
|
-
host:
|
|
620
|
-
port:
|
|
621
|
-
dbname:
|
|
622
|
-
username:
|
|
623
|
-
password:
|
|
624
|
-
connect_timeout:
|
|
617
|
+
connection_string: str | None = None,
|
|
618
|
+
host: str | None = None,
|
|
619
|
+
port: int | str | None = None,
|
|
620
|
+
dbname: str | None = None,
|
|
621
|
+
username: str | None = None,
|
|
622
|
+
password: str | None = None,
|
|
623
|
+
connect_timeout: int | None = 10,
|
|
625
624
|
) -> "psycopg.Connection":
|
|
626
625
|
"""Establishes a connection to a PostgreSQL database using psycopg.
|
|
627
626
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import abc
|
|
8
8
|
import logging
|
|
9
9
|
from collections.abc import Sequence
|
|
10
|
-
from typing import Any
|
|
10
|
+
from typing import Any
|
|
11
11
|
|
|
12
12
|
from ....import_utils import optional_import_block, require_optional_import
|
|
13
13
|
from .base import Document, ItemID, QueryResults, VectorDB
|
|
@@ -20,7 +20,7 @@ with optional_import_block():
|
|
|
20
20
|
|
|
21
21
|
logger = get_logger(__name__)
|
|
22
22
|
|
|
23
|
-
Embeddings =
|
|
23
|
+
Embeddings = Sequence[float] | Sequence[int]
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class EmbeddingFunction(abc.ABC):
|
|
@@ -37,9 +37,9 @@ class FastEmbedEmbeddingFunction(EmbeddingFunction):
|
|
|
37
37
|
self,
|
|
38
38
|
model_name: str = "BAAI/bge-small-en-v1.5",
|
|
39
39
|
batch_size: int = 256,
|
|
40
|
-
cache_dir:
|
|
41
|
-
threads:
|
|
42
|
-
parallel:
|
|
40
|
+
cache_dir: str | None = None,
|
|
41
|
+
threads: int | None = None,
|
|
42
|
+
parallel: int | None = None,
|
|
43
43
|
**kwargs: Any,
|
|
44
44
|
):
|
|
45
45
|
"""Initialize fastembed.TextEmbedding.
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
import copy
|
|
8
8
|
import logging
|
|
9
9
|
import re
|
|
10
|
+
from collections.abc import Callable
|
|
10
11
|
from datetime import datetime
|
|
11
|
-
from typing import Annotated, Any,
|
|
12
|
+
from typing import Annotated, Any, Literal
|
|
12
13
|
|
|
13
14
|
from ... import Agent, AssistantAgent, ConversableAgent, OpenAIWrapper, UserProxyAgent
|
|
14
15
|
from ...browser_utils import SimpleTextBrowser
|
|
@@ -32,17 +33,17 @@ class WebSurferAgent(ConversableAgent):
|
|
|
32
33
|
def __init__(
|
|
33
34
|
self,
|
|
34
35
|
name: str,
|
|
35
|
-
system_message:
|
|
36
|
-
description:
|
|
37
|
-
is_termination_msg:
|
|
38
|
-
max_consecutive_auto_reply:
|
|
36
|
+
system_message: str | list[str] | None = DEFAULT_PROMPT,
|
|
37
|
+
description: str | None = DEFAULT_DESCRIPTION,
|
|
38
|
+
is_termination_msg: Callable[[dict[str, Any]], bool] | None = None,
|
|
39
|
+
max_consecutive_auto_reply: int | None = None,
|
|
39
40
|
human_input_mode: Literal["ALWAYS", "NEVER", "TERMINATE"] = "TERMINATE",
|
|
40
|
-
function_map:
|
|
41
|
-
code_execution_config:
|
|
42
|
-
llm_config:
|
|
43
|
-
summarizer_llm_config:
|
|
44
|
-
default_auto_reply:
|
|
45
|
-
browser_config:
|
|
41
|
+
function_map: dict[str, Callable[..., Any]] | None = None,
|
|
42
|
+
code_execution_config: dict[str, Any] | Literal[False] = False,
|
|
43
|
+
llm_config: LLMConfig | dict[str, Any] | Literal[False] | None = None,
|
|
44
|
+
summarizer_llm_config: LLMConfig | dict[str, Any] | Literal[False] | None = None,
|
|
45
|
+
default_auto_reply: str | dict[str, Any] | None = "",
|
|
46
|
+
browser_config: dict[str, Any] | None = None,
|
|
46
47
|
**kwargs: Any,
|
|
47
48
|
):
|
|
48
49
|
super().__init__(
|
|
@@ -91,7 +92,7 @@ class WebSurferAgent(ConversableAgent):
|
|
|
91
92
|
self.register_reply([Agent, None], ConversableAgent.check_termination_and_human_reply)
|
|
92
93
|
|
|
93
94
|
def _create_summarizer_client(
|
|
94
|
-
self, summarizer_llm_config:
|
|
95
|
+
self, summarizer_llm_config: LLMConfig | dict[str, Any], llm_config: LLMConfig | dict[str, Any]
|
|
95
96
|
) -> None:
|
|
96
97
|
# If the summarizer_llm_config is None, we copy it from the llm_config
|
|
97
98
|
if summarizer_llm_config is None:
|
|
@@ -200,8 +201,8 @@ class WebSurferAgent(ConversableAgent):
|
|
|
200
201
|
description="Uses AI to read the page and directly answer a given question based on the content.",
|
|
201
202
|
)
|
|
202
203
|
def _answer_from_page(
|
|
203
|
-
question: Annotated[
|
|
204
|
-
url: Annotated[
|
|
204
|
+
question: Annotated[str | None, "The question to directly answer."],
|
|
205
|
+
url: Annotated[str | None, "[Optional] The url of the page. (Defaults to the current page)"] = None,
|
|
205
206
|
) -> str:
|
|
206
207
|
if url is not None and url != self.browser.address:
|
|
207
208
|
self.browser.visit_page(url)
|
|
@@ -257,17 +258,17 @@ class WebSurferAgent(ConversableAgent):
|
|
|
257
258
|
)
|
|
258
259
|
def _summarize_page(
|
|
259
260
|
url: Annotated[
|
|
260
|
-
|
|
261
|
+
str | None, "[Optional] The url of the page to summarize. (Defaults to current page)"
|
|
261
262
|
] = None,
|
|
262
263
|
) -> str:
|
|
263
264
|
return _answer_from_page(url=url, question=None)
|
|
264
265
|
|
|
265
266
|
def generate_surfer_reply(
|
|
266
267
|
self,
|
|
267
|
-
messages:
|
|
268
|
-
sender:
|
|
269
|
-
config:
|
|
270
|
-
) -> tuple[bool,
|
|
268
|
+
messages: list[dict[str, str]] | None = None,
|
|
269
|
+
sender: Agent | None = None,
|
|
270
|
+
config: OpenAIWrapper | None = None,
|
|
271
|
+
) -> tuple[bool, str | dict[str, str] | None]:
|
|
271
272
|
"""Generate a reply using autogen.oai."""
|
|
272
273
|
if messages is None:
|
|
273
274
|
messages = self._oai_messages[sender]
|