ag2 0.9.7__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.7.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 +292 -290
- 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 +2 -1
- 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 +113 -139
- autogen/oai/client_utils.py +3 -3
- autogen/oai/cohere.py +34 -11
- autogen/oai/gemini.py +39 -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 +19 -9
- autogen/oai/openai_responses.py +40 -17
- autogen/oai/openai_utils.py +48 -38
- 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 +8 -6
- autogen/types.py +2 -2
- autogen/version.py +1 -1
- ag2-0.9.7.dist-info/RECORD +0 -421
- autogen/llm_config.py +0 -385
- {ag2-0.9.7.dist-info → ag2-0.9.8.post1.dist-info}/WHEEL +0 -0
- {ag2-0.9.7.dist-info → ag2-0.9.8.post1.dist-info}/licenses/LICENSE +0 -0
- {ag2-0.9.7.dist-info → ag2-0.9.8.post1.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -15,10 +15,11 @@ import sys
|
|
|
15
15
|
import tempfile
|
|
16
16
|
import threading
|
|
17
17
|
import time
|
|
18
|
+
from collections.abc import Callable
|
|
18
19
|
from dataclasses import dataclass
|
|
19
20
|
from functools import lru_cache
|
|
20
21
|
from pathlib import Path
|
|
21
|
-
from typing import Any,
|
|
22
|
+
from typing import Any, TypeVar
|
|
22
23
|
|
|
23
24
|
from ..import_utils import optional_import_block, require_optional_import
|
|
24
25
|
|
|
@@ -37,7 +38,7 @@ with optional_import_block():
|
|
|
37
38
|
@dataclass
|
|
38
39
|
class NotebookError:
|
|
39
40
|
error_name: str
|
|
40
|
-
error_value:
|
|
41
|
+
error_value: str | None
|
|
41
42
|
traceback: str
|
|
42
43
|
cell_source: str
|
|
43
44
|
|
|
@@ -79,7 +80,6 @@ C = TypeVar("C", bound=Callable[..., Any])
|
|
|
79
80
|
|
|
80
81
|
def require_quarto_bin(f: C) -> C:
|
|
81
82
|
"""Decorator to skip a function if quarto is not installed."""
|
|
82
|
-
|
|
83
83
|
if check_quarto_bin():
|
|
84
84
|
return f
|
|
85
85
|
else:
|
|
@@ -91,13 +91,13 @@ def require_quarto_bin(f: C) -> C:
|
|
|
91
91
|
return wrapper # type: ignore[return-value]
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
def load_metadata(notebook: Path) -> dict[str, dict[str,
|
|
94
|
+
def load_metadata(notebook: Path) -> dict[str, dict[str, str | list[str] | None]]:
|
|
95
95
|
content = json.load(notebook.open(encoding="utf-8"))
|
|
96
|
-
metadata: dict[str, dict[str,
|
|
96
|
+
metadata: dict[str, dict[str, str | list[str] | None]] = content.get("metadata", {})
|
|
97
97
|
return metadata
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
def skip_reason_or_none_if_ok(notebook: Path) ->
|
|
100
|
+
def skip_reason_or_none_if_ok(notebook: Path) -> str | None | dict[str, Any]:
|
|
101
101
|
"""Return a reason to skip the notebook, or None if it should not be skipped."""
|
|
102
102
|
if notebook.suffix != ".ipynb":
|
|
103
103
|
return "not a notebook"
|
|
@@ -149,7 +149,7 @@ def skip_reason_or_none_if_ok(notebook: Path) -> Union[str, None, dict[str, Any]
|
|
|
149
149
|
return None
|
|
150
150
|
|
|
151
151
|
|
|
152
|
-
def extract_title(notebook: Path) ->
|
|
152
|
+
def extract_title(notebook: Path) -> str | None:
|
|
153
153
|
"""Extract the title of the notebook."""
|
|
154
154
|
with open(notebook, encoding="utf-8") as f:
|
|
155
155
|
content = f.read()
|
|
@@ -196,7 +196,7 @@ def fmt_ok(notebook: Path) -> str:
|
|
|
196
196
|
|
|
197
197
|
|
|
198
198
|
@require_optional_import("termcolor", "docs")
|
|
199
|
-
def fmt_error(notebook: Path, error:
|
|
199
|
+
def fmt_error(notebook: Path, error: NotebookError | str) -> str:
|
|
200
200
|
if isinstance(error, str):
|
|
201
201
|
return f"{colored('[Error]', 'red')} {colored(notebook.name, 'blue')}: {error}"
|
|
202
202
|
elif isinstance(error, NotebookError):
|
|
@@ -207,7 +207,7 @@ def fmt_error(notebook: Path, error: Union[NotebookError, str]) -> str:
|
|
|
207
207
|
|
|
208
208
|
@require_quarto_bin
|
|
209
209
|
@require_optional_import("nbclient", "docs")
|
|
210
|
-
def test_notebook(notebook_path: Path, timeout: int = 300) -> tuple[Path,
|
|
210
|
+
def test_notebook(notebook_path: Path, timeout: int = 300) -> tuple[Path, NotebookError | NotebookSkip | None]:
|
|
211
211
|
nb = nbformat.read(str(notebook_path), NB_VERSION) # type: ignore[arg-type,no-untyped-call]
|
|
212
212
|
|
|
213
213
|
if "skip_test" in nb.metadata:
|
|
@@ -240,7 +240,7 @@ def test_notebook(notebook_path: Path, timeout: int = 300) -> tuple[Path, Option
|
|
|
240
240
|
@require_optional_import("nbclient", "docs")
|
|
241
241
|
def get_timeout_info(
|
|
242
242
|
nb: NotebookNode,
|
|
243
|
-
) ->
|
|
243
|
+
) -> NotebookError | None:
|
|
244
244
|
for i, cell in enumerate(nb.cells):
|
|
245
245
|
if cell.cell_type != "code":
|
|
246
246
|
continue
|
|
@@ -256,7 +256,7 @@ def get_timeout_info(
|
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
@require_optional_import("nbclient", "docs")
|
|
259
|
-
def get_error_info(nb: NotebookNode) ->
|
|
259
|
+
def get_error_info(nb: NotebookNode) -> NotebookError | None:
|
|
260
260
|
for cell in nb["cells"]: # get LAST error
|
|
261
261
|
if cell["cell_type"] != "code":
|
|
262
262
|
continue
|
|
@@ -288,7 +288,7 @@ def process_notebook(
|
|
|
288
288
|
quarto_bin: str,
|
|
289
289
|
dry_run: bool,
|
|
290
290
|
target_dir_func: Callable[[Path], Path],
|
|
291
|
-
post_processor:
|
|
291
|
+
post_processor: Callable[[Path, Path, dict[str, Any], Path], None] | None = None,
|
|
292
292
|
) -> str:
|
|
293
293
|
"""Process a single notebook.
|
|
294
294
|
|
|
@@ -301,7 +301,6 @@ def process_notebook(
|
|
|
301
301
|
target_dir_func: Function to determine target directory for notebooks
|
|
302
302
|
post_processor: Optional callback for post-processing
|
|
303
303
|
"""
|
|
304
|
-
|
|
305
304
|
in_notebook_dir = "notebook" in src_notebook.parts
|
|
306
305
|
|
|
307
306
|
metadata = load_metadata(src_notebook)
|
|
@@ -400,7 +399,7 @@ def create_base_argument_parser() -> argparse.ArgumentParser:
|
|
|
400
399
|
|
|
401
400
|
def process_notebooks_core(
|
|
402
401
|
args: argparse.Namespace,
|
|
403
|
-
post_process_func:
|
|
402
|
+
post_process_func: Callable[[Path, Path, dict[str, Any], Path], None] | None,
|
|
404
403
|
target_dir_func: Callable[[Path], Path],
|
|
405
404
|
) -> list[Path]:
|
|
406
405
|
"""Core logic for processing notebooks shared across build systems.
|
|
@@ -12,9 +12,9 @@ import json
|
|
|
12
12
|
import re
|
|
13
13
|
import shutil
|
|
14
14
|
import sys
|
|
15
|
+
from collections.abc import Sequence
|
|
15
16
|
from copy import deepcopy
|
|
16
17
|
from pathlib import Path
|
|
17
|
-
from typing import Sequence, Union
|
|
18
18
|
|
|
19
19
|
from ..import_utils import optional_import_block, require_optional_import
|
|
20
20
|
from .notebook_processor import (
|
|
@@ -41,7 +41,7 @@ def notebooks_target_dir(website_build_directory: Path) -> Path:
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def add_front_matter_to_metadata_mdx(
|
|
44
|
-
front_matter: dict[str,
|
|
44
|
+
front_matter: dict[str, str | list[str] | None], website_build_directory: Path, rendered_mdx: Path
|
|
45
45
|
) -> None:
|
|
46
46
|
source = front_matter.get("source_notebook")
|
|
47
47
|
if isinstance(source, str) and source.startswith("/website/docs/"):
|
|
@@ -239,7 +239,7 @@ def extract_img_tag_from_figure_tag(content: str, img_rel_path: Path) -> str:
|
|
|
239
239
|
def post_process_mdx(
|
|
240
240
|
rendered_mdx: Path,
|
|
241
241
|
source_notebooks: Path,
|
|
242
|
-
front_matter: dict[str,
|
|
242
|
+
front_matter: dict[str, str | list[str] | None],
|
|
243
243
|
website_build_directory: Path,
|
|
244
244
|
) -> None:
|
|
245
245
|
with open(rendered_mdx, encoding="utf-8") as f:
|
|
@@ -309,7 +309,7 @@ def post_process_mdx(
|
|
|
309
309
|
# Convert callout blocks
|
|
310
310
|
content = convert_callout_blocks(content)
|
|
311
311
|
|
|
312
|
-
# Convert mdx image syntax to
|
|
312
|
+
# Convert mdx image syntax to mintlify image syntax
|
|
313
313
|
content = convert_mdx_image_blocks(content, rendered_mdx, website_build_directory)
|
|
314
314
|
|
|
315
315
|
# ensure editUrl is present
|
|
@@ -340,7 +340,7 @@ def get_sorted_files(input_dir: Path, prefix: str) -> list[str]:
|
|
|
340
340
|
return [f"{prefix}/{f.parent.relative_to(input_dir)}/index".replace("\\", "/") for f in reversed_files]
|
|
341
341
|
|
|
342
342
|
|
|
343
|
-
def generate_nav_group(input_dir: Path, group_header: str, prefix: str) -> dict[str,
|
|
343
|
+
def generate_nav_group(input_dir: Path, group_header: str, prefix: str) -> dict[str, str | list[str]]:
|
|
344
344
|
"""Generate navigation group for a directory.
|
|
345
345
|
|
|
346
346
|
Args:
|
|
@@ -381,15 +381,15 @@ def extract_example_group(metadata_path: Path) -> list[str]:
|
|
|
381
381
|
|
|
382
382
|
|
|
383
383
|
def update_group_pages(
|
|
384
|
-
mint_navigation: list[dict[str,
|
|
384
|
+
mint_navigation: list[dict[str, str | list[str | dict[str, str | list[str]]]]],
|
|
385
385
|
target_group: str,
|
|
386
|
-
new_value: Sequence[
|
|
387
|
-
) -> list[dict[str,
|
|
386
|
+
new_value: Sequence[str | dict[str, str | Sequence[str]]],
|
|
387
|
+
) -> list[dict[str, str | list[str | dict[str, str | list[str]]]]]:
|
|
388
388
|
"""Update mint.json navigation group with new pages."""
|
|
389
389
|
nav_copy = deepcopy(mint_navigation)
|
|
390
390
|
|
|
391
391
|
def update_recursively(
|
|
392
|
-
items: list[dict[str,
|
|
392
|
+
items: list[dict[str, str | list[str | dict[str, str | list[str]]]]],
|
|
393
393
|
) -> None:
|
|
394
394
|
for item in items:
|
|
395
395
|
if isinstance(item, dict):
|
|
@@ -572,7 +572,7 @@ def get_files_path_from_navigation(navigation: list[NavigationGroup]) -> list[Pa
|
|
|
572
572
|
"""
|
|
573
573
|
file_paths = []
|
|
574
574
|
|
|
575
|
-
def extract_paths(items:
|
|
575
|
+
def extract_paths(items: Sequence[str | NavigationGroup]) -> None:
|
|
576
576
|
for item in items:
|
|
577
577
|
if isinstance(item, str):
|
|
578
578
|
file_paths.append(Path(item))
|
autogen/_website/utils.py
CHANGED
|
@@ -9,7 +9,7 @@ import sys
|
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from textwrap import dedent, indent
|
|
12
|
-
from typing import Literal,
|
|
12
|
+
from typing import Literal, TypedDict, Union
|
|
13
13
|
|
|
14
14
|
from ..import_utils import optional_import_block, require_optional_import
|
|
15
15
|
|
|
@@ -51,7 +51,7 @@ def copy_files(src_dir: Path, dst_dir: Path, files_to_copy: list[Path]) -> None:
|
|
|
51
51
|
shutil.copy2(file, dst)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def copy_only_git_tracked_and_untracked_files(src_dir: Path, dst_dir: Path, ignore_dir:
|
|
54
|
+
def copy_only_git_tracked_and_untracked_files(src_dir: Path, dst_dir: Path, ignore_dir: str | None = None) -> None:
|
|
55
55
|
"""Copy only the files that are tracked by git or newly added from src_dir to dst_dir."""
|
|
56
56
|
tracked_and_new_files = get_git_tracked_and_untracked_files_in_directory(src_dir)
|
|
57
57
|
|
|
@@ -120,6 +120,7 @@ def construct_authors_html(authors_list: list[str], authors_dict: dict[str, dict
|
|
|
120
120
|
authors_list: list of author identifiers
|
|
121
121
|
authors_dict: Dictionary containing author information keyed by author identifier
|
|
122
122
|
build_system: The build system being used (mkdocs or mintlify)
|
|
123
|
+
|
|
123
124
|
Returns:
|
|
124
125
|
str: Formatted HTML string containing author cards
|
|
125
126
|
"""
|
|
@@ -204,6 +205,7 @@ def separate_front_matter_and_content(file_path: Path) -> tuple[str, str]:
|
|
|
204
205
|
|
|
205
206
|
def ensure_edit_url(content: str, file_path: Path) -> str:
|
|
206
207
|
"""Ensure editUrl is present in the content.
|
|
208
|
+
|
|
207
209
|
Args:
|
|
208
210
|
content (str): Content of the file
|
|
209
211
|
file_path (Path): Path to the file
|
|
@@ -223,7 +225,6 @@ def add_authors_and_social_preview(
|
|
|
223
225
|
build_system: build_system = "mintlify",
|
|
224
226
|
) -> None:
|
|
225
227
|
"""Add authors info and social share image to mdx files in the target directory."""
|
|
226
|
-
|
|
227
228
|
social_img_html = (
|
|
228
229
|
"""\n<div>
|
|
229
230
|
<img noZoom className="social-share-img"
|
|
@@ -302,7 +303,7 @@ def render_gallery_html(gallery_file_path: Path) -> str:
|
|
|
302
303
|
"""
|
|
303
304
|
try:
|
|
304
305
|
# Load gallery items from YAML file
|
|
305
|
-
with open(gallery_file_path
|
|
306
|
+
with open(gallery_file_path) as file:
|
|
306
307
|
gallery_items = yaml.safe_load(file)
|
|
307
308
|
|
|
308
309
|
# Ensure gallery_items is a list
|
autogen/agentchat/agent.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import TYPE_CHECKING, Any, Optional, Protocol, TypeVar,
|
|
7
|
+
from typing import TYPE_CHECKING, Any, Optional, Protocol, TypeVar, runtime_checkable
|
|
8
8
|
|
|
9
9
|
from ..doc_utils import export_module
|
|
10
10
|
|
|
@@ -40,9 +40,9 @@ class Agent(Protocol):
|
|
|
40
40
|
|
|
41
41
|
def send(
|
|
42
42
|
self,
|
|
43
|
-
message:
|
|
43
|
+
message: dict[str, Any] | str,
|
|
44
44
|
recipient: "Agent",
|
|
45
|
-
request_reply:
|
|
45
|
+
request_reply: bool | None = None,
|
|
46
46
|
) -> None:
|
|
47
47
|
"""Send a message to another agent.
|
|
48
48
|
|
|
@@ -56,9 +56,9 @@ class Agent(Protocol):
|
|
|
56
56
|
|
|
57
57
|
async def a_send(
|
|
58
58
|
self,
|
|
59
|
-
message:
|
|
59
|
+
message: dict[str, Any] | str,
|
|
60
60
|
recipient: "Agent",
|
|
61
|
-
request_reply:
|
|
61
|
+
request_reply: bool | None = None,
|
|
62
62
|
) -> None:
|
|
63
63
|
"""(Async) Send a message to another agent.
|
|
64
64
|
|
|
@@ -72,9 +72,9 @@ class Agent(Protocol):
|
|
|
72
72
|
|
|
73
73
|
def receive(
|
|
74
74
|
self,
|
|
75
|
-
message:
|
|
75
|
+
message: dict[str, Any] | str,
|
|
76
76
|
sender: "Agent",
|
|
77
|
-
request_reply:
|
|
77
|
+
request_reply: bool | None = None,
|
|
78
78
|
) -> None:
|
|
79
79
|
"""Receive a message from another agent.
|
|
80
80
|
|
|
@@ -87,9 +87,9 @@ class Agent(Protocol):
|
|
|
87
87
|
|
|
88
88
|
async def a_receive(
|
|
89
89
|
self,
|
|
90
|
-
message:
|
|
90
|
+
message: dict[str, Any] | str,
|
|
91
91
|
sender: "Agent",
|
|
92
|
-
request_reply:
|
|
92
|
+
request_reply: bool | None = None,
|
|
93
93
|
) -> None:
|
|
94
94
|
"""(Async) Receive a message from another agent.
|
|
95
95
|
|
|
@@ -103,10 +103,10 @@ class Agent(Protocol):
|
|
|
103
103
|
|
|
104
104
|
def generate_reply(
|
|
105
105
|
self,
|
|
106
|
-
messages:
|
|
106
|
+
messages: list[dict[str, Any]] | None = None,
|
|
107
107
|
sender: Optional["Agent"] = None,
|
|
108
108
|
**kwargs: Any,
|
|
109
|
-
) ->
|
|
109
|
+
) -> str | dict[str, Any] | None:
|
|
110
110
|
"""Generate a reply based on the received messages.
|
|
111
111
|
|
|
112
112
|
Args:
|
|
@@ -122,10 +122,10 @@ class Agent(Protocol):
|
|
|
122
122
|
|
|
123
123
|
async def a_generate_reply(
|
|
124
124
|
self,
|
|
125
|
-
messages:
|
|
125
|
+
messages: list[dict[str, Any]] | None = None,
|
|
126
126
|
sender: Optional["Agent"] = None,
|
|
127
127
|
**kwargs: Any,
|
|
128
|
-
) ->
|
|
128
|
+
) -> str | dict[str, Any] | None:
|
|
129
129
|
"""(Async) Generate a reply based on the received messages.
|
|
130
130
|
|
|
131
131
|
Args:
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
|
-
from
|
|
7
|
+
from collections.abc import Callable
|
|
8
|
+
from typing import Any, Literal
|
|
8
9
|
|
|
9
10
|
from ..doc_utils import export_module
|
|
10
11
|
from ..llm_config import LLMConfig
|
|
@@ -42,12 +43,12 @@ Reply "TERMINATE" in the end when everything is done.
|
|
|
42
43
|
def __init__(
|
|
43
44
|
self,
|
|
44
45
|
name: str,
|
|
45
|
-
system_message:
|
|
46
|
-
llm_config:
|
|
47
|
-
is_termination_msg:
|
|
48
|
-
max_consecutive_auto_reply:
|
|
46
|
+
system_message: str | None = DEFAULT_SYSTEM_MESSAGE,
|
|
47
|
+
llm_config: LLMConfig | dict[str, Any] | Literal[False] | None = None,
|
|
48
|
+
is_termination_msg: Callable[[dict[str, Any]], bool] | None = None,
|
|
49
|
+
max_consecutive_auto_reply: int | None = None,
|
|
49
50
|
human_input_mode: Literal["ALWAYS", "NEVER", "TERMINATE"] = "NEVER",
|
|
50
|
-
description:
|
|
51
|
+
description: str | None = None,
|
|
51
52
|
**kwargs: Any,
|
|
52
53
|
):
|
|
53
54
|
"""Args:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Any, Literal
|
|
7
|
+
from typing import Any, Literal
|
|
8
8
|
|
|
9
9
|
from .... import GroupChat, GroupChatManager, UserProxyAgent
|
|
10
10
|
from ....llm_config import LLMConfig
|
|
@@ -16,7 +16,7 @@ from .task import Task
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def generate_criteria(
|
|
19
|
-
llm_config:
|
|
19
|
+
llm_config: LLMConfig | dict[str, Any] | Literal[False] | None = None,
|
|
20
20
|
task: Task = None,
|
|
21
21
|
additional_instructions: str = "",
|
|
22
22
|
max_round=2,
|
|
@@ -67,7 +67,7 @@ def generate_criteria(
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def quantify_criteria(
|
|
70
|
-
llm_config:
|
|
70
|
+
llm_config: LLMConfig | dict[str, Any] | Literal[False] | None = None,
|
|
71
71
|
criteria: list[Criterion] = None,
|
|
72
72
|
task: Task = None,
|
|
73
73
|
test_case: str = "",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from ...conversable_agent import ConversableAgent
|
|
10
10
|
|
|
@@ -24,8 +24,8 @@ class CriticAgent(ConversableAgent):
|
|
|
24
24
|
def __init__(
|
|
25
25
|
self,
|
|
26
26
|
name="critic",
|
|
27
|
-
system_message:
|
|
28
|
-
description:
|
|
27
|
+
system_message: str | None = DEFAULT_SYSTEM_MESSAGE,
|
|
28
|
+
description: str | None = DEFAULT_DESCRIPTION,
|
|
29
29
|
**kwargs: Any,
|
|
30
30
|
):
|
|
31
31
|
"""Args:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from ...conversable_agent import ConversableAgent
|
|
10
10
|
|
|
@@ -24,8 +24,8 @@ class QuantifierAgent(ConversableAgent):
|
|
|
24
24
|
def __init__(
|
|
25
25
|
self,
|
|
26
26
|
name="quantifier",
|
|
27
|
-
system_message:
|
|
28
|
-
description:
|
|
27
|
+
system_message: str | None = DEFAULT_SYSTEM_MESSAGE,
|
|
28
|
+
description: str | None = DEFAULT_DESCRIPTION,
|
|
29
29
|
**kwargs: Any,
|
|
30
30
|
):
|
|
31
31
|
"""Args:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from ...conversable_agent import ConversableAgent
|
|
10
10
|
|
|
@@ -25,8 +25,8 @@ class SubCriticAgent(ConversableAgent):
|
|
|
25
25
|
def __init__(
|
|
26
26
|
self,
|
|
27
27
|
name="subcritic",
|
|
28
|
-
system_message:
|
|
29
|
-
description:
|
|
28
|
+
system_message: str | None = DEFAULT_SYSTEM_MESSAGE,
|
|
29
|
+
description: str | None = DEFAULT_DESCRIPTION,
|
|
30
30
|
**kwargs: Any,
|
|
31
31
|
):
|
|
32
32
|
"""Args:
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
7
|
import copy
|
|
8
8
|
import json
|
|
9
|
-
from typing import Any
|
|
9
|
+
from typing import Any
|
|
10
10
|
|
|
11
11
|
from ... import OpenAIWrapper, filter_config
|
|
12
12
|
from ...code_utils import execute_code
|
|
@@ -176,8 +176,8 @@ class AgentOptimizer:
|
|
|
176
176
|
def __init__(
|
|
177
177
|
self,
|
|
178
178
|
max_actions_per_step: int,
|
|
179
|
-
llm_config:
|
|
180
|
-
optimizer_model:
|
|
179
|
+
llm_config: LLMConfig | dict[str, Any] | None = None,
|
|
180
|
+
optimizer_model: str | None = "gpt-4-1106-preview",
|
|
181
181
|
):
|
|
182
182
|
"""(These APIs are experimental and may change in the future.)
|
|
183
183
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
7
|
import re
|
|
8
|
-
from typing import Any, Literal, Optional, Protocol
|
|
8
|
+
from typing import Any, Literal, Optional, Protocol
|
|
9
9
|
|
|
10
10
|
from .... import Agent, ConversableAgent, code_utils
|
|
11
11
|
from ....cache import AbstractCache
|
|
@@ -78,7 +78,7 @@ class DalleImageGenerator:
|
|
|
78
78
|
|
|
79
79
|
def __init__(
|
|
80
80
|
self,
|
|
81
|
-
llm_config:
|
|
81
|
+
llm_config: LLMConfig | dict[str, Any],
|
|
82
82
|
resolution: Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"] = "1024x1024",
|
|
83
83
|
quality: Literal["standard", "hd"] = "standard",
|
|
84
84
|
num_images: int = 1,
|
|
@@ -153,8 +153,8 @@ class ImageGeneration(AgentCapability):
|
|
|
153
153
|
def __init__(
|
|
154
154
|
self,
|
|
155
155
|
image_generator: ImageGenerator,
|
|
156
|
-
cache:
|
|
157
|
-
text_analyzer_llm_config:
|
|
156
|
+
cache: AbstractCache | None = None,
|
|
157
|
+
text_analyzer_llm_config: LLMConfig | dict[str, Any] | None = None,
|
|
158
158
|
text_analyzer_instructions: str = PROMPT_INSTRUCTIONS,
|
|
159
159
|
verbosity: int = 0,
|
|
160
160
|
register_reply_position: int = 2,
|
|
@@ -183,8 +183,8 @@ class ImageGeneration(AgentCapability):
|
|
|
183
183
|
self._verbosity = verbosity
|
|
184
184
|
self._register_reply_position = register_reply_position
|
|
185
185
|
|
|
186
|
-
self._agent:
|
|
187
|
-
self._text_analyzer:
|
|
186
|
+
self._agent: ConversableAgent | None = None
|
|
187
|
+
self._text_analyzer: TextAnalyzerAgent | None = None
|
|
188
188
|
|
|
189
189
|
def add_to_agent(self, agent: ConversableAgent):
|
|
190
190
|
"""Adds the Image Generation capability to the specified ConversableAgent.
|
|
@@ -216,10 +216,10 @@ class ImageGeneration(AgentCapability):
|
|
|
216
216
|
def _image_gen_reply(
|
|
217
217
|
self,
|
|
218
218
|
recipient: ConversableAgent,
|
|
219
|
-
messages:
|
|
220
|
-
sender:
|
|
221
|
-
config:
|
|
222
|
-
) -> tuple[bool,
|
|
219
|
+
messages: list[dict[str, Any]] | None,
|
|
220
|
+
sender: Agent | None = None,
|
|
221
|
+
config: Any | None = None,
|
|
222
|
+
) -> tuple[bool, str | dict[str, Any] | None]:
|
|
223
223
|
if messages is None:
|
|
224
224
|
return False, None
|
|
225
225
|
|
|
@@ -272,7 +272,7 @@ class ImageGeneration(AgentCapability):
|
|
|
272
272
|
key = self._image_generator.cache_key(prompt)
|
|
273
273
|
self._cache.set(key, img_utils.pil_to_data_uri(image))
|
|
274
274
|
|
|
275
|
-
def _extract_analysis(self, analysis:
|
|
275
|
+
def _extract_analysis(self, analysis: str | dict[str, Any] | None) -> str:
|
|
276
276
|
if isinstance(analysis, dict):
|
|
277
277
|
return code_utils.content_str(analysis["content"])
|
|
278
278
|
else:
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# SPDX-License-Identifier: MIT
|
|
7
7
|
import os
|
|
8
8
|
import pickle
|
|
9
|
-
from typing import Any
|
|
9
|
+
from typing import Any
|
|
10
10
|
|
|
11
11
|
from ....formatting_utils import colored
|
|
12
12
|
from ....import_utils import optional_import_block, require_optional_import
|
|
@@ -38,12 +38,12 @@ class Teachability(AgentCapability):
|
|
|
38
38
|
|
|
39
39
|
def __init__(
|
|
40
40
|
self,
|
|
41
|
-
verbosity:
|
|
42
|
-
reset_db:
|
|
43
|
-
path_to_db_dir:
|
|
44
|
-
recall_threshold:
|
|
45
|
-
max_num_retrievals:
|
|
46
|
-
llm_config:
|
|
41
|
+
verbosity: int | None = 0,
|
|
42
|
+
reset_db: bool | None = False,
|
|
43
|
+
path_to_db_dir: str | None = "./tmp/teachable_agent_db",
|
|
44
|
+
recall_threshold: float | None = 1.5,
|
|
45
|
+
max_num_retrievals: int | None = 10,
|
|
46
|
+
llm_config: LLMConfig | dict[str, Any] | bool | None = None,
|
|
47
47
|
):
|
|
48
48
|
"""Args:
|
|
49
49
|
verbosity (Optional, int): # 0 (default) for basic info, 1 to add memory operations, 2 for analyzer messages, 3 for memo lists.
|
|
@@ -92,7 +92,7 @@ class Teachability(AgentCapability):
|
|
|
92
92
|
"""Adds a few arbitrary memos to the DB."""
|
|
93
93
|
self.memo_store.prepopulate()
|
|
94
94
|
|
|
95
|
-
def process_last_received_message(self, text:
|
|
95
|
+
def process_last_received_message(self, text: dict[str, Any] | str):
|
|
96
96
|
"""Appends any relevant memos to the message text, and stores any apparent teachings in new memos.
|
|
97
97
|
Uses TextAnalyzerAgent to make decisions about memo storage and retrieval.
|
|
98
98
|
"""
|
|
@@ -107,7 +107,7 @@ class Teachability(AgentCapability):
|
|
|
107
107
|
# Return the (possibly) expanded message text.
|
|
108
108
|
return expanded_text
|
|
109
109
|
|
|
110
|
-
def _consider_memo_storage(self, comment:
|
|
110
|
+
def _consider_memo_storage(self, comment: dict[str, Any] | str):
|
|
111
111
|
"""Decides whether to store something from one user comment in the DB."""
|
|
112
112
|
memo_added = False
|
|
113
113
|
|
|
@@ -165,7 +165,7 @@ class Teachability(AgentCapability):
|
|
|
165
165
|
# Yes. Save them to disk.
|
|
166
166
|
self.memo_store._save_memos()
|
|
167
167
|
|
|
168
|
-
def _consider_memo_retrieval(self, comment:
|
|
168
|
+
def _consider_memo_retrieval(self, comment: dict[str, Any] | str):
|
|
169
169
|
"""Decides whether to retrieve memos from the DB, and add them to the chat context."""
|
|
170
170
|
# First, use the comment directly as the lookup key.
|
|
171
171
|
if self.verbosity >= 1:
|
|
@@ -228,7 +228,7 @@ class Teachability(AgentCapability):
|
|
|
228
228
|
memo_texts = memo_texts + "\n" + info
|
|
229
229
|
return memo_texts
|
|
230
230
|
|
|
231
|
-
def _analyze(self, text_to_analyze:
|
|
231
|
+
def _analyze(self, text_to_analyze: dict[str, Any] | str, analysis_instructions: dict[str, Any] | str):
|
|
232
232
|
"""Asks TextAnalyzerAgent to analyze the given text according to specific instructions."""
|
|
233
233
|
self.analyzer.reset() # Clear the analyzer's list of messages.
|
|
234
234
|
self.teachable_agent.send(
|
|
@@ -251,9 +251,9 @@ class MemoStore:
|
|
|
251
251
|
|
|
252
252
|
def __init__(
|
|
253
253
|
self,
|
|
254
|
-
verbosity:
|
|
255
|
-
reset:
|
|
256
|
-
path_to_db_dir:
|
|
254
|
+
verbosity: int | None = 0,
|
|
255
|
+
reset: bool | None = False,
|
|
256
|
+
path_to_db_dir: str | None = "./tmp/teachable_agent_db",
|
|
257
257
|
):
|
|
258
258
|
"""Args:
|
|
259
259
|
- verbosity (Optional, int): 1 to print memory operations, 0 to omit them. 3+ to print memo lists.
|
|
@@ -342,7 +342,7 @@ class MemoStore:
|
|
|
342
342
|
)
|
|
343
343
|
return input_text, output_text, distance
|
|
344
344
|
|
|
345
|
-
def get_related_memos(self, query_text: str, n_results: int, threshold:
|
|
345
|
+
def get_related_memos(self, query_text: str, n_results: int, threshold: int | float):
|
|
346
346
|
"""Retrieves memos that are related to the given query text within the specified distance threshold."""
|
|
347
347
|
if n_results > len(self.uid_text_dict):
|
|
348
348
|
n_results = len(self.uid_text_dict)
|