Skip to content

Commit

Permalink
Merge branch 'main' into pull/3000
Browse files Browse the repository at this point in the history
  • Loading branch information
ranfysvalle02 authored Jun 24, 2024
2 parents de48057 + 334cc25 commit f5e5fdf
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 40 deletions.
5 changes: 4 additions & 1 deletion autogen/agentchat/contrib/vectordb/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def __init__(
sentences = ["The weather is lovely today in paradise."]
embeddings = self.embedding_function(sentences)
self.dimensions = len(embeddings[0])
# index lookup
self.database_name = database_name
self.index_name = index_name
self.similarity = similarity

def list_collections(self):
"""
Expand Down Expand Up @@ -363,7 +367,6 @@ def retrieve_docs(
collection_name: str = None,
n_results: int = 10,
distance_threshold: float = -1,
index_name: str = "default",
**kwargs,
) -> QueryResults:
"""
Expand Down
2 changes: 1 addition & 1 deletion autogen/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.30"
__version__ = "0.2.31"
287 changes: 278 additions & 9 deletions notebook/agentchat_mongodb_RetrieveChat.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test/agentchat/contrib/vectordb/test_mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def create_collection(collection_name: str,
collection = db.create_collection(collection_name, overwrite=False, get_or_create=True)
assert collection.name == collection_name


def test_get_collection(db):
collection_name = MONGODB_COLLECTION

Expand Down
2 changes: 1 addition & 1 deletion website/blog/2023-06-28-MathChat/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ We found that compared to basic prompting, which demonstrates the innate capabil

For categories like Algebra and Prealgebra, PoT and PS showed little improvement, and in some instances, even led to a decrease in accuracy. However, MathChat was able to enhance total accuracy by around 6% compared to PoT and PS, showing competitive performance across all categories. Remarkably, MathChat improved accuracy in the Algebra category by about 15% over other methods. Note that categories like Intermediate Algebra and Precalculus remained challenging for all methods, with only about 20% of problems solved accurately.

The code for experiments can be found at this [repository](https://github.com/kevin666aa/FLAML/tree/gpt_math_solver/flaml/autogen/math).
The code for experiments can be found at this [repository](https://github.com/yiranwu0/FLAML/tree/gpt_math_solver/flaml/autogen/math).
We now provide an implementation of MathChat using the interactive agents in AutoGen. See this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_MathChat.ipynb) for example usage.

## Future Directions
Expand Down
2 changes: 1 addition & 1 deletion website/blog/2023-11-13-OAI-assistants/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ Checkout more examples [here](https://github.com/microsoft/autogen/tree/main/not
`GPTAssistantAgent` was made possible through collaboration with
[@IANTHEREAL](https://github.com/IANTHEREAL),
[Jiale Liu](https://leoljl.github.io),
[Yiran Wu](https://github.com/kevin666aa),
[Yiran Wu](https://github.com/yiranwu0),
[Qingyun Wu](https://qingyun-wu.github.io/),
[Chi Wang](https://www.microsoft.com/en-us/research/people/chiw/), and many other AutoGen maintainers.
4 changes: 2 additions & 2 deletions website/blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ qingyunwu:
yiranwu:
name: Yiran Wu
title: PhD student at Pennsylvania State University
url: https://github.com/kevin666aa
image_url: https://github.com/kevin666aa.png
url: https://github.com/yiranwu0
image_url: https://github.com/yiranwu0.png

jialeliu:
name: Jiale Liu
Expand Down
52 changes: 29 additions & 23 deletions website/docs/topics/groupchat/customized_speaker_selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,34 @@
"source": [
"# Customize Speaker Selection\n",
"\n",
"In GroupChat, we can also customize the speaker selection by passing in a function to `speaker_selection_method`:\n",
"```{=mdx}\n",
"![group_chat](../../../blog/2024-02-29-StateFlow/img/sf_example_1.png)\n",
"```\n",
"\n",
"In GroupChat, we can customize the speaker selection by passing a function to the `GroupChat` object. With this function, you can build a more **deterministic** agent workflow. We recommend following a **StateFlow** pattern when crafting this function. Please refer to the [StateFlow blog](/blog/2024/02/29/StateFlow) for more details.\n",
"\n",
"\n",
"## An example research workflow\n",
"We provide a simple example to build a StateFlow model for research with customized speaker selection.\n",
"\n",
"We first define the following agents:\n",
"\n",
"- Initializer: Start the workflow by sending a task.\n",
"- Coder: Retrieve papers from the internet by writing code.\n",
"- Executor: Execute the code.\n",
"- Scientist: Read the papers and write a summary.\n",
"\n",
"In the figure above, we define a simple workflow for research with 4 states: *Init*, *Retrieve*, *Research*, and *End*. Within each state, we will call different agents to perform the tasks.\n",
"\n",
"- *Init*: We use the initializer to start the workflow.\n",
"- *Retrieve*: We will first call the coder to write code and then call the executor to execute the code.\n",
"- *Research*: We will call the scientist to read the papers and write a summary.\n",
"- *End*: We will end the workflow.\n",
"\n",
"## Create your speaker selection function\n",
"\n",
"Below is a skeleton of the speaker selection function. Fill in the function to define the speaker selection logic.\n",
"\n",
"```python\n",
"def custom_speaker_selection_func(\n",
" last_speaker: Agent, \n",
Expand Down Expand Up @@ -35,28 +62,7 @@
")\n",
"```\n",
"The last speaker and the groupchat object are passed to the function. \n",
"Commonly used variables from groupchat are `groupchat.messages` and `groupchat.agents`, which is the message history and the agents in the group chat respectively. You can access other attributes of the groupchat, such as `groupchat.allowed_speaker_transitions_dict` for pre-defined `allowed_speaker_transitions_dict`.\n",
"\n",
"Heres is a simple example to build workflow for research with customized speaker selection.\n",
"\n",
"\n",
"```{=mdx}\n",
"![group_chat](../../../blog/2024-02-29-StateFlow/img/sf_example_1.png)\n",
"```\n",
"\n",
"We define the following agents:\n",
"\n",
"- Initializer: Start the workflow by sending a task.\n",
"- Coder: Retrieve papers from the internet by writing code.\n",
"- Executor: Execute the code.\n",
"- Scientist: Read the papers and write a summary.\n",
"\n",
"In the Figure, we define a simple workflow for research with 4 states: Init, Retrieve, Research and End. Within each state, we will call different agents to perform the tasks.\n",
"\n",
"Init: We use the initializer to start the workflow.\n",
"Retrieve: We will first call the coder to write code and then call the executor to execute the code.\n",
"Research: We will call the scientist to read the papers and write a summary.\n",
"End: We will end the workflow."
"Commonly used variables from groupchat are `groupchat.messages` and `groupchat.agents`, which is the message history and the agents in the group chat respectively. You can access other attributes of the groupchat, such as `groupchat.allowed_speaker_transitions_dict` for pre-defined `allowed_speaker_transitions_dict`."
]
},
{
Expand Down
13 changes: 12 additions & 1 deletion website/docs/tutorial/conversation-patterns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
"In this chapter, we will first dig a little bit more into the two-agent \n",
"chat pattern and chat result, \n",
"then we will show you several conversation patterns that involve \n",
"more than two agents.\n"
"more than two agents.\n",
"\n",
"### An Overview\n",
"\n",
"1. **Two-agent chat**: the simplest form of conversation pattern where two agents chat with each other.\n",
"2. **Sequential chat**: a sequence of chats between two agents, chained together by a carryover mechanism, which brings the summary of the previous chat to the context of the next chat.\n",
"3. **Group Chat**: a single chat involving more than two agents. An important question in group chat is: What agent should be next to speak? To support different scenarios, we provide different ways to organize agents in a group chat:\n",
" - We support several strategies to select the next agent: `round_robin`, `random`, `manual` (human selection), and `auto` (Default, using an LLM to decide).\n",
" - We provide a way to constrain the selection of the next speaker (See examples below).\n",
" - We allow you to pass in a function to customize the selection of the next speaker. With this feature, you can build a **StateFlow** model which allows a deterministic workflow among your agents.\n",
" Please refer to this [guide](/docs/topics/groupchat/customized_speaker_selection) and this [blog post](/blog/2024/02/29/StateFlow) on StateFlow for more details.\n",
"4. **Nested Chat**: package a workflow into a single agent for reuse in a larger workflow."
]
},
{
Expand Down

0 comments on commit f5e5fdf

Please sign in to comment.