From d64f47560e156c6239b639a2ae9227bf10499632 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Mon, 30 Dec 2024 03:33:13 +0000 Subject: [PATCH 1/3] Fix broken links --- .devcontainer/dev/Dockerfile | 7 +++++-- .muffet-excluded-links.txt | 9 ++++++++- autogen/agentchat/chat.py | 2 +- autogen/agentchat/conversable_agent.py | 4 ++-- autogen/agentchat/user_proxy_agent.py | 2 +- autogen/oai/gemini.py | 2 +- notebook/agentchat_agentops.ipynb | 4 ++-- notebook/agentchat_function_call.ipynb | 2 +- ...agentchat_function_call_currency_calculator.ipynb | 2 +- notebook/agentchat_graph_rag_neo4j.ipynb | 4 +++- notebook/agentchat_human_feedback.ipynb | 2 +- scripts/broken-links-check.sh | 2 +- website/mint.json | 3 ++- website/snippets/data/NotebooksMetadata.mdx | 12 ++++++++++++ 14 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.devcontainer/dev/Dockerfile b/.devcontainer/dev/Dockerfile index b02f59bb3..4c410acb4 100644 --- a/.devcontainer/dev/Dockerfile +++ b/.devcontainer/dev/Dockerfile @@ -30,10 +30,13 @@ RUN sudo pip install --upgrade pip && \ # Install pre-commit hooks RUN pre-commit install -# Setup Mintlify for the documentation website +# Install Python packages for documentation RUN sudo pip install pydoc-markdown pyyaml termcolor nbclient -RUN cd website + +# Install npm packages for documentation +WORKDIR /home/autogen/ag2/website RUN npm install +WORKDIR /home/autogen/ag2 RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \ wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-${arch}.tar.gz && \ diff --git a/.muffet-excluded-links.txt b/.muffet-excluded-links.txt index cdc2c8d45..026f09ef5 100644 --- a/.muffet-excluded-links.txt +++ b/.muffet-excluded-links.txt @@ -1,8 +1,15 @@ +http://localhost linkedin.com x.com example.com rapidapi.com -https://platform.openai.com/docs/ +https://platform.openai.com +https://openai.com +https://code.visualstudio.com/docs/devcontainers/containers +https://thesequence.substack.com/p/my-five-favorite-ai-papers-of-2023 +https://www.llama.com/docs/how-to-guides/prompting/ +https://azure.microsoft.com/en-us/get-started/azure-portal +https://github.com/pgvector/pgvector?tab=readme-ov-file https://github.com/ag2ai/ag2/blob/b1adac515931bf236ac59224269eeec683a162ba/test/oai/test_client.py https://github.com/ag2ai/ag2/blob/main/notebook/contributing.md https://github.com/openai/openai-python/blob/d231d1fa783967c1d3a1db3ba1b52647fff148ac/src/openai/resources/completions.py diff --git a/autogen/agentchat/chat.py b/autogen/agentchat/chat.py index 5f1e18a51..0ecd4514c 100644 --- a/autogen/agentchat/chat.py +++ b/autogen/agentchat/chat.py @@ -164,7 +164,7 @@ def initiate_chats(chat_queue: list[dict[str, Any]]) -> list[ChatResult]: chat_queue (List[Dict]): A list of dictionaries containing the information about the chats. Each dictionary should contain the input arguments for - [`ConversableAgent.initiate_chat`](/docs/reference/agentchat/conversable_agent#initiate_chat). + [`ConversableAgent.initiate_chat`](/docs/reference/agentchat/conversable_agent#initiate-chat). For example: - `"sender"` - the sender agent. - `"recipient"` - the recipient agent. diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py index 78de1eb60..6caedd3bb 100644 --- a/autogen/agentchat/conversable_agent.py +++ b/autogen/agentchat/conversable_agent.py @@ -1048,7 +1048,7 @@ def initiate_chat( silent (bool or None): (Experimental) whether to print the messages for this conversation. Default is False. cache (AbstractCache or None): the cache client to be used for this conversation. Default is None. max_turns (int or None): the maximum number of turns for the chat between the two agents. One turn means one conversation round trip. Note that this is different from - [max_consecutive_auto_reply](#max-consecutive-auto-reply) which is the maximum number of consecutive auto replies; and it is also different from [max_rounds in GroupChat](./groupchat#groupchat-objects) which is the maximum number of rounds in a group chat session. + [max_consecutive_auto_reply](#max-consecutive-auto-reply) which is the maximum number of consecutive auto replies; and it is also different from [max_rounds in GroupChat](./groupchat) which is the maximum number of rounds in a group chat session. If max_turns is set to None, the chat will continue until a termination condition is met. Default is None. summary_method (str or callable): a method to get a summary from the chat. Default is DEFAULT_SUMMARY_METHOD, i.e., "last_msg". @@ -1376,7 +1376,7 @@ def initiate_chats(self, chat_queue: list[dict[str, Any]]) -> list[ChatResult]: Args: chat_queue (List[Dict]): a list of dictionaries containing the information of the chats. - Each dictionary should contain the input arguments for [`initiate_chat`](conversable_agent#initiate_chat) + Each dictionary should contain the input arguments for [`initiate_chat`](conversable_agent#initiate-chat) Returns: a list of ChatResult objects corresponding to the finished chats in the chat_queue. """ diff --git a/autogen/agentchat/user_proxy_agent.py b/autogen/agentchat/user_proxy_agent.py index dd1c167c3..687e7e315 100644 --- a/autogen/agentchat/user_proxy_agent.py +++ b/autogen/agentchat/user_proxy_agent.py @@ -16,7 +16,7 @@ class UserProxyAgent(ConversableAgent): UserProxyAgent is a subclass of ConversableAgent configured with `human_input_mode` to ALWAYS and `llm_config` to False. By default, the agent will prompt for human input every time a message is received. Code execution is enabled by default. LLM-based auto reply is disabled by default. - To modify auto reply, register a method with [`register_reply`](conversable_agent#register_reply). + To modify auto reply, register a method with [`register_reply`](conversable_agent#register-reply). To modify the way to get human input, override `get_human_input` method. To modify the way to execute code blocks, single code block, or function call, override `execute_code_blocks`, `run_code`, and `execute_function` methods respectively. diff --git a/autogen/oai/gemini.py b/autogen/oai/gemini.py index 12c0e8ba0..f501d12dd 100644 --- a/autogen/oai/gemini.py +++ b/autogen/oai/gemini.py @@ -30,7 +30,7 @@ Resources: - https://ai.google.dev/docs -- https://cloud.google.com/vertex-ai/docs/generative-ai/migrate-from-azure +- https://cloud.google.com/vertex-ai/generative-ai/docs/migrate/migrate-from-azure-to-gemini - https://blog.google/technology/ai/google-gemini-pro-imagen-duet-ai-update/ - https://ai.google.dev/api/python/google/generativeai/ChatSession """ diff --git a/notebook/agentchat_agentops.ipynb b/notebook/agentchat_agentops.ipynb index b369b9cd9..df83c3569 100644 --- a/notebook/agentchat_agentops.ipynb +++ b/notebook/agentchat_agentops.ipynb @@ -72,7 +72,7 @@ "\n", "By default, the AgentOps `init()` function will look for an environment variable named `AGENTOPS_API_KEY`. Alternatively, you can pass one in as an optional parameter.\n", "\n", - "Create an account and obtain an API key at [AgentOps.ai](https://agentops.ai/settings/projects)" + "Create an account and obtain an API key at [AgentOps.ai](https://agentops.ai)" ] }, { @@ -223,7 +223,7 @@ "metadata": {}, "source": [ "# Tool Example\n", - "AgentOps also tracks when Autogen agents use tools. You can find more information on this example in [tool-use.ipynb](https://github.com/microsoft/autogen/blob/main/website/docs/tutorial/tool-use.ipynb)" + "AgentOps also tracks when Autogen agents use tools. You can find more information on this example in [tool-use.ipynb](https://github.com/ag2ai/ag2/blob/main/website/docs/tutorial/tool-use.ipynb)" ] }, { diff --git a/notebook/agentchat_function_call.ipynb b/notebook/agentchat_function_call.ipynb index 81dd8ba18..8762e27b2 100644 --- a/notebook/agentchat_function_call.ipynb +++ b/notebook/agentchat_function_call.ipynb @@ -95,7 +95,7 @@ "]\n", "```\n", "\n", - "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/website/docs/topics/llm_configuration.ipynb) for full code examples of the different methods." + "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/ag2ai/ag2/blob/main/website/docs/topics/llm_configuration.ipynb) for full code examples of the different methods." ] }, { diff --git a/notebook/agentchat_function_call_currency_calculator.ipynb b/notebook/agentchat_function_call_currency_calculator.ipynb index 2be106d83..2126735e2 100644 --- a/notebook/agentchat_function_call_currency_calculator.ipynb +++ b/notebook/agentchat_function_call_currency_calculator.ipynb @@ -104,7 +104,7 @@ "]\n", "```\n", "\n", - "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/website/docs/topics/llm_configuration.ipynb) for full code examples of the different methods." + "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/ag2ai/ag2/blob/main/website/docs/topics/llm_configuration.ipynb) for full code examples of the different methods." ] }, { diff --git a/notebook/agentchat_graph_rag_neo4j.ipynb b/notebook/agentchat_graph_rag_neo4j.ipynb index 9bc7d9ff0..5306b7039 100644 --- a/notebook/agentchat_graph_rag_neo4j.ipynb +++ b/notebook/agentchat_graph_rag_neo4j.ipynb @@ -587,7 +587,9 @@ { "cell_type": "markdown", "metadata": {}, - "source": "### Incrementally add new documents to the existing knoweldge graph." + "source": [ + "### Incrementally add new documents to the existing knoweldge graph." + ] }, { "cell_type": "code", diff --git a/notebook/agentchat_human_feedback.ipynb b/notebook/agentchat_human_feedback.ipynb index 6af8eb8e0..126d46107 100644 --- a/notebook/agentchat_human_feedback.ipynb +++ b/notebook/agentchat_human_feedback.ipynb @@ -94,7 +94,7 @@ "]\n", "```\n", "\n", - "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/website/docs/topics/llm_configuration.ipynb) for full code examples of the different methods." + "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/ag2ai/ag2/blob/main/website/docs/topics/llm_configuration.ipynb) for full code examples of the different methods." ] }, { diff --git a/scripts/broken-links-check.sh b/scripts/broken-links-check.sh index f93a26b9f..bbca3c51e 100755 --- a/scripts/broken-links-check.sh +++ b/scripts/broken-links-check.sh @@ -7,4 +7,4 @@ set -o errexit # Run muffet to check for broken links -muffet --buffer-size=8192 --max-connections=1 --color=always --header="User-Agent:Mozilla/5.0(Firefox/97.0)" --max-connections-per-host=1 --rate-limit=1 --max-response-body-size=20000000 --exclude="($(paste -sd '|' .muffet-excluded-links.txt))" https://docs.ag2.ai/docs/Home +muffet --buffer-size=16384 --max-connections=1 --color=always --header="User-Agent:Mozilla/5.0(Firefox/97.0)" --max-connections-per-host=1 --rate-limit=1 --max-response-body-size=20000000 --exclude="($(paste -sd '|' .muffet-excluded-links.txt))" https://docs.ag2.ai/docs/Home diff --git a/website/mint.json b/website/mint.json index faeff7ec6..9c44965b0 100644 --- a/website/mint.json +++ b/website/mint.json @@ -621,7 +621,8 @@ "notebooks/agentchat_swarm_enhanced", "notebooks/tools_interoperability", "notebooks/agentchat_realtime_swarm", - "notebooks/agentchat_reasoning_agent" + "notebooks/agentchat_reasoning_agent", + "notebooks/agentchat_captainagent_crosstool" ] }, "notebooks/Gallery" diff --git a/website/snippets/data/NotebooksMetadata.mdx b/website/snippets/data/NotebooksMetadata.mdx index 2b7c5e9b5..483a33248 100644 --- a/website/snippets/data/NotebooksMetadata.mdx +++ b/website/snippets/data/NotebooksMetadata.mdx @@ -1223,5 +1223,17 @@ export const notebooksMetadata = [ "image": null, "tags": [], "source": "/website/docs/tutorial/code-executors.ipynb" + }, + { + "title": "Cross-Framework LLM Tool for CaptainAgent", + "link": "/notebooks/agentchat_captainagent_crosstool", + "description": "Cross-Framework LLM Tool for CaptainAgent", + "image": null, + "tags": [ + "tools", + "langchain", + "crewai" + ], + "source": "/notebook/agentchat_captainagent_crosstool.ipynb" } ]; From 6a2971839e34db2689c075311a87b7a3c741e3e1 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Mon, 30 Dec 2024 05:21:26 +0000 Subject: [PATCH 2/3] Add twitter to muffet exclusion list --- .muffet-excluded-links.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.muffet-excluded-links.txt b/.muffet-excluded-links.txt index 026f09ef5..3fecdfe20 100644 --- a/.muffet-excluded-links.txt +++ b/.muffet-excluded-links.txt @@ -1,6 +1,7 @@ http://localhost linkedin.com x.com +twitter.com example.com rapidapi.com https://platform.openai.com From ef64179a34cea5ceb701da250df528925e40d7da Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Mon, 30 Dec 2024 06:25:10 +0000 Subject: [PATCH 3/3] Enclose examples inside code blocks --- .../contrib/capabilities/vision_capability.py | 10 ++++--- .../contrib/graph_rag/graph_rag_capability.py | 3 ++- autogen/agentchat/contrib/img_utils.py | 12 ++++++--- .../agentchat/contrib/vectordb/chromadb.py | 8 +++--- .../agentchat/contrib/vectordb/pgvectordb.py | 4 +-- autogen/agentchat/contrib/vectordb/qdrant.py | 4 +-- autogen/agentchat/contrib/vectordb/utils.py | 2 ++ autogen/agentchat/groupchat.py | 26 +++++++++---------- autogen/agentchat/utils.py | 6 ++--- autogen/code_utils.py | 14 +++++----- autogen/math_utils.py | 17 ++++++++---- autogen/oai/cerebras.py | 2 ++ autogen/oai/cohere.py | 2 ++ autogen/oai/completion.py | 4 +-- autogen/oai/gemini.py | 2 ++ autogen/oai/groq.py | 2 ++ autogen/oai/mistral.py | 2 ++ autogen/oai/ollama.py | 4 ++- autogen/oai/together.py | 2 ++ autogen/retrieve_utils.py | 4 +-- notebook/agentchat_human_feedback.ipynb | 8 +++--- test/test_code_utils.py | 6 ++--- website/process_api_reference.py | 17 +----------- 23 files changed, 89 insertions(+), 72 deletions(-) diff --git a/autogen/agentchat/contrib/capabilities/vision_capability.py b/autogen/agentchat/contrib/capabilities/vision_capability.py index c0fe7a53e..2d5c02e10 100644 --- a/autogen/agentchat/contrib/capabilities/vision_capability.py +++ b/autogen/agentchat/contrib/capabilities/vision_capability.py @@ -141,22 +141,24 @@ def process_last_received_message(self, content: Union[str, list[dict]]) -> str: (Content is a string without an image, remains unchanged.) - Input as String, with image location: - content = "What's weather in this cool photo: " - Output: "What's weather in this cool photo: in case you can not see, the caption of this image is: + content = "What's weather in this cool photo: ``" + Output: "What's weather in this cool photo: `` in case you can not see, the caption of this image is: A beautiful sunset over the mountains\n" (Caption added after the image) - Input as List with Text Only: - content = [{"type": "text", "text": "Here's an interesting fact."}] + content = `[{"type": "text", "text": "Here's an interesting fact."}]` Output: "Here's an interesting fact." (No images in the content, it remains unchanged.) - Input as List with Image URL: + ```python content = [ {"type": "text", "text": "What's weather in this cool photo:"}, {"type": "image_url", "image_url": {"url": "http://example.com/photo.jpg"}} ] - Output: "What's weather in this cool photo: in case you can not see, the caption of this image is: + ``` + Output: "What's weather in this cool photo: `` in case you can not see, the caption of this image is: A beautiful sunset over the mountains\n" (Caption added after the image) """ diff --git a/autogen/agentchat/contrib/graph_rag/graph_rag_capability.py b/autogen/agentchat/contrib/graph_rag/graph_rag_capability.py index 7e2ade403..9d47180ae 100644 --- a/autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +++ b/autogen/agentchat/contrib/graph_rag/graph_rag_capability.py @@ -20,6 +20,7 @@ class GraphRagCapability(AgentCapability): 3. generate answers from retrieved information and send messages back. For example, + ```python graph_query_engine = GraphQueryEngine(...) graph_query_engine.init_db([Document(doc1), Document(doc2), ...]) @@ -50,7 +51,7 @@ class GraphRagCapability(AgentCapability): # - Hugo Weaving', # 'role': 'user_proxy'}, # ...) - + ``` """ def __init__(self, query_engine: GraphQueryEngine): diff --git a/autogen/agentchat/contrib/img_utils.py b/autogen/agentchat/contrib/img_utils.py index 1cf718d53..f6f4747a2 100644 --- a/autogen/agentchat/contrib/img_utils.py +++ b/autogen/agentchat/contrib/img_utils.py @@ -112,7 +112,7 @@ def llava_formatter(prompt: str, order_image_tokens: bool = False) -> tuple[str, Formats the input prompt by replacing image tags and returns the new prompt along with image locations. Parameters: - - prompt (str): The input string that may contain image tags like . + - prompt (str): The input string that may contain image tags like ``. - order_image_tokens (bool, optional): Whether to order the image tokens with numbers. It will be useful for GPT-4V. Defaults to False. @@ -194,7 +194,7 @@ def gpt4v_formatter(prompt: str, img_format: str = "uri") -> list[Union[str, dic Formats the input prompt by replacing image tags and returns a list of text and images. Args: - - prompt (str): The input string that may contain image tags like . + - prompt (str): The input string that may contain image tags like ``. - img_format (str): what image format should be used. One of "uri", "url", "pil". Returns: @@ -293,24 +293,28 @@ def message_formatter_pil_to_b64(messages: list[dict]) -> list[dict]: 'image_url' key converted to base64 encoded data URIs. Example Input: + ```python [ {'content': [{'type': 'text', 'text': 'You are a helpful AI assistant.'}], 'role': 'system'}, {'content': [ - {'type': 'text', 'text': "What's the breed of this dog here? \n"}, + {'type': 'text', 'text': "What's the breed of this dog here?"}, {'type': 'image_url', 'image_url': {'url': a PIL.Image.Image}}, {'type': 'text', 'text': '.'}], 'role': 'user'} ] + ``` Example Output: + ```python [ {'content': [{'type': 'text', 'text': 'You are a helpful AI assistant.'}], 'role': 'system'}, {'content': [ - {'type': 'text', 'text': "What's the breed of this dog here? \n"}, + {'type': 'text', 'text': "What's the breed of this dog here?"}, {'type': 'image_url', 'image_url': {'url': a B64 Image}}, {'type': 'text', 'text': '.'}], 'role': 'user'} ] + ``` """ new_messages = [] for message in messages: diff --git a/autogen/agentchat/contrib/vectordb/chromadb.py b/autogen/agentchat/contrib/vectordb/chromadb.py index f01b32b89..accd05a4d 100644 --- a/autogen/agentchat/contrib/vectordb/chromadb.py +++ b/autogen/agentchat/contrib/vectordb/chromadb.py @@ -39,11 +39,11 @@ def __init__( Args: client: chromadb.Client | The client object of the vector database. Default is None. If provided, it will use the client object directly and ignore other arguments. - path: str | The path to the vector database. Default is `tmp/db`. The default was `None` for version <=0.2.24. + path: str | The path to the vector database. Default is `tmp/db`. The default was `None` for version `<=0.2.24`. embedding_function: Callable | The embedding function used to generate the vector representation of the documents. Default is None, SentenceTransformerEmbeddingFunction("all-MiniLM-L6-v2") will be used. metadata: dict | The metadata of the vector database. Default is None. If None, it will use this - setting: {"hnsw:space": "ip", "hnsw:construction_ef": 30, "hnsw:M": 32}. For more details of + setting: `{"hnsw:space": "ip", "hnsw:construction_ef": 30, "hnsw:M": 32}`. For more details of the metadata, please refer to [distances](https://github.com/nmslib/hnswlib#supported-distances), [hnsw](https://github.com/chroma-core/chroma/blob/566bc80f6c8ee29f7d99b6322654f32183c368c4/chromadb/segment/impl/vector/local_hnsw.py#L184), and [ALGO_PARAMS](https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md). @@ -248,7 +248,7 @@ def retrieve_docs( collection_name: str | The name of the collection. Default is None. n_results: int | The number of relevant documents to return. Default is 10. distance_threshold: float | The threshold for the distance score, only distance smaller than it will be - returned. Don't filter with it if < 0. Default is -1. + returned. Don't filter with it if `< 0`. Default is -1. kwargs: Dict | Additional keyword arguments. Returns: @@ -279,6 +279,7 @@ def _chroma_get_results_to_list_documents(data_dict) -> list[Document]: List[Document] | The list of Document. Example: + ```python data_dict = { "key1s": [1, 2, 3], "key2s": ["a", "b", "c"], @@ -291,6 +292,7 @@ def _chroma_get_results_to_list_documents(data_dict) -> list[Document]: {"key1": 2, "key2": "b", "key4": "y"}, {"key1": 3, "key2": "c", "key4": "z"}, ] + ``` """ results = [] diff --git a/autogen/agentchat/contrib/vectordb/pgvectordb.py b/autogen/agentchat/contrib/vectordb/pgvectordb.py index 431fa9a54..df211bad0 100644 --- a/autogen/agentchat/contrib/vectordb/pgvectordb.py +++ b/autogen/agentchat/contrib/vectordb/pgvectordb.py @@ -606,7 +606,7 @@ def __init__( Models can be chosen from: https://huggingface.co/models?library=sentence-transformers metadata: dict | The metadata of the vector database. Default is None. If None, it will use this - setting: {"hnsw:space": "ip", "hnsw:construction_ef": 30, "hnsw:M": 16}. Creates Index on table + setting: `{"hnsw:space": "ip", "hnsw:construction_ef": 30, "hnsw:M": 16}`. Creates Index on table using hnsw (embedding vector_l2_ops) WITH (m = hnsw:M) ef_construction = "hnsw:construction_ef". For more info: https://github.com/pgvector/pgvector?tab=readme-ov-file#hnsw Returns: @@ -917,7 +917,7 @@ def retrieve_docs( collection_name: str | The name of the collection. Default is None. n_results: int | The number of relevant documents to return. Default is 10. distance_threshold: float | The threshold for the distance score, only distance smaller than it will be - returned. Don't filter with it if < 0. Default is -1. + returned. Don't filter with it if `< 0`. Default is -1. kwargs: Dict | Additional keyword arguments. Returns: diff --git a/autogen/agentchat/contrib/vectordb/qdrant.py b/autogen/agentchat/contrib/vectordb/qdrant.py index 70564056d..569f61ca0 100644 --- a/autogen/agentchat/contrib/vectordb/qdrant.py +++ b/autogen/agentchat/contrib/vectordb/qdrant.py @@ -56,7 +56,7 @@ def __init__( Defaults to None. **kwargs: Additional options to pass to fastembed.TextEmbedding Raises: - ValueError: If the model_name is not in the format / e.g. BAAI/bge-small-en-v1.5. + ValueError: If the model_name is not in the format `/` e.g. BAAI/bge-small-en-v1.5. """ try: from fastembed import TextEmbedding @@ -229,7 +229,7 @@ def retrieve_docs( collection_name: str | The name of the collection. Default is None. n_results: int | The number of relevant documents to return. Default is 10. distance_threshold: float | The threshold for the distance score, only distance smaller than it will be - returned. Don't filter with it if < 0. Default is 0. + returned. Don't filter with it if `< 0`. Default is 0. kwargs: Dict | Additional keyword arguments. Returns: diff --git a/autogen/agentchat/contrib/vectordb/utils.py b/autogen/agentchat/contrib/vectordb/utils.py index 6fb8cbacd..1dd93391e 100644 --- a/autogen/agentchat/contrib/vectordb/utils.py +++ b/autogen/agentchat/contrib/vectordb/utils.py @@ -78,6 +78,7 @@ def chroma_results_to_query_results(data_dict: dict[str, list[list[Any]]], speci special_key. Example: + ```python data_dict = { "key1s": [[1, 2, 3], [4, 5, 6], [7, 8, 9]], "key2s": [["a", "b", "c"], ["c", "d", "e"], ["e", "f", "g"]], @@ -103,6 +104,7 @@ def chroma_results_to_query_results(data_dict: dict[str, list[list[Any]]], speci ({"key1": 9, "key2": "g", "key4": "6"}, 0.9), ], ] + ``` """ keys = [ diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index 4a2bc1824..199aad215 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -39,28 +39,28 @@ class GroupChat: When set to True and when a message is a function call suggestion, the next speaker will be chosen from an agent which contains the corresponding function name in its `function_map`. - - select_speaker_message_template: customize the select speaker message (used in "auto" speaker selection), which appears first in the message context and generally includes the agent descriptions and list of agents. If the string contains "{roles}" it will replaced with the agent's and their role descriptions. If the string contains "{agentlist}" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: + - select_speaker_message_template: customize the select speaker message (used in "auto" speaker selection), which appears first in the message context and generally includes the agent descriptions and list of agents. If the string contains "`{roles}`" it will replaced with the agent's and their role descriptions. If the string contains "`{agentlist}`" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: "You are in a role play game. The following roles are available: - {roles}. + `{roles}`. Read the following conversation. - Then select the next role from {agentlist} to play. Only return the role." - - select_speaker_prompt_template: customize the select speaker prompt (used in "auto" speaker selection), which appears last in the message context and generally includes the list of agents and guidance for the LLM to select the next agent. If the string contains "{agentlist}" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: - "Read the above conversation. Then select the next role from {agentlist} to play. Only return the role." + Then select the next role from `{agentlist}` to play. Only return the role." + - select_speaker_prompt_template: customize the select speaker prompt (used in "auto" speaker selection), which appears last in the message context and generally includes the list of agents and guidance for the LLM to select the next agent. If the string contains "`{agentlist}`" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: + "Read the above conversation. Then select the next role from `{agentlist}` to play. Only return the role." To ignore this prompt being used, set this to None. If set to None, ensure your instructions for selecting a speaker are in the select_speaker_message_template string. - - select_speaker_auto_multiple_template: customize the follow-up prompt used when selecting a speaker fails with a response that contains multiple agent names. This prompt guides the LLM to return just one agent name. Applies only to "auto" speaker selection method. If the string contains "{agentlist}" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: + - select_speaker_auto_multiple_template: customize the follow-up prompt used when selecting a speaker fails with a response that contains multiple agent names. This prompt guides the LLM to return just one agent name. Applies only to "auto" speaker selection method. If the string contains "`{agentlist}`" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: "You provided more than one name in your text, please return just the name of the next speaker. To determine the speaker use these prioritised rules: 1. If the context refers to themselves as a speaker e.g. "As the..." , choose that speaker's name 2. If it refers to the "next" speaker name, choose that name 3. Otherwise, choose the first provided speaker's name in the context The names are case-sensitive and should not be abbreviated or changed. Respond with ONLY the name of the speaker and DO NOT provide a reason." - - select_speaker_auto_none_template: customize the follow-up prompt used when selecting a speaker fails with a response that contains no agent names. This prompt guides the LLM to return an agent name and provides a list of agent names. Applies only to "auto" speaker selection method. If the string contains "{agentlist}" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: + - select_speaker_auto_none_template: customize the follow-up prompt used when selecting a speaker fails with a response that contains no agent names. This prompt guides the LLM to return an agent name and provides a list of agent names. Applies only to "auto" speaker selection method. If the string contains "`{agentlist}`" it will be replaced with a comma-separated list of agent names in square brackets. The default value is: "You didn't choose a speaker. As a reminder, to determine the speaker use these prioritised rules: 1. If the context refers to themselves as a speaker e.g. "As the..." , choose that speaker's name 2. If it refers to the "next" speaker name, choose that name 3. Otherwise, choose the first provided speaker's name in the context The names are case-sensitive and should not be abbreviated or changed. - The only names that are accepted are {agentlist}. + The only names that are accepted are `{agentlist}`. Respond with ONLY the name of the speaker and DO NOT provide a reason." - speaker_selection_method: the method for selecting the next speaker. Default is "auto". Could be any of the following (case insensitive), will raise ValueError if not recognized: @@ -1592,11 +1592,11 @@ def clear_agents_history(self, reply: dict, groupchat: GroupChat) -> str: """Clears history of messages for all agents or selected one. Can preserve selected number of last messages. That function is called when user manually provide "clear history" phrase in his reply. When "clear history" is provided, the history of messages for all agents is cleared. - When "clear history " is provided, the history of messages for selected agent is cleared. - When "clear history " is provided, the history of messages for all agents is cleared - except last messages. - When "clear history " is provided, the history of messages for selected - agent is cleared except last messages. + When "clear history ``" is provided, the history of messages for selected agent is cleared. + When "clear history ``" is provided, the history of messages for all agents is cleared + except last `` messages. + When "clear history `` ``" is provided, the history of messages for selected + agent is cleared except last `` messages. Phrase "clear history" and optional arguments are cut out from the reply before it passed to the chat. Args: diff --git a/autogen/agentchat/utils.py b/autogen/agentchat/utils.py index 94b2d7c5e..74fa99616 100644 --- a/autogen/agentchat/utils.py +++ b/autogen/agentchat/utils.py @@ -111,9 +111,9 @@ def parse_tags_from_content(tag: str, content: Union[str, list[dict[str, Any]]]) can be a single string or a set of attribute-value pairs. Examples: - -> [{"tag": "img", "attr": {"src": "http://example.com/image.png"}, "match": re.Match}] -