Skip to content

Commit aae44d4

Browse files
authored
Merge branch 'microsoft:main' into main
2 parents 25ac479 + 1bd2124 commit aae44d4

File tree

168 files changed

+2218
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+2218
-743
lines changed

.github/workflows/contrib-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
paths:
1010
- "autogen/**"
1111
- "test/agentchat/contrib/**"
12+
- "test/test_browser_utils.py"
13+
- "test/test_retrieve_utils.py"
1214
- ".github/workflows/contrib-tests.yml"
1315
- "setup.py"
1416

.github/workflows/dotnet-build.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,16 @@ jobs:
5656
- name: Setup .NET
5757
uses: actions/setup-dotnet@v4
5858
with:
59-
global-json-file: dotnet/global.json
59+
dotnet-version: '8.0.x'
6060
- name: Restore dependencies
6161
run: |
6262
# dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config
6363
dotnet restore -bl
64+
- name: Format check
65+
run: |
66+
echo "Format check"
67+
echo "If you see any error in this step, please run 'dotnet format' locally to format the code."
68+
dotnet format --verify-no-changes -v diag --no-restore
6469
- name: Build
6570
run: |
6671
echo "Build AutoGen"

.github/workflows/dotnet-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Setup .NET
3333
uses: actions/setup-dotnet@v4
3434
with:
35-
global-json-file: dotnet/global.json
35+
dotnet-version: '8.0.x'
3636
- name: Restore dependencies
3737
run: |
3838
dotnet restore -bl

autogen/agentchat/chat.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ def __find_async_chat_order(chat_ids: Set[int], prerequisites: List[Prerequisite
107107
return chat_order
108108

109109

110+
def _post_process_carryover_item(carryover_item):
111+
if isinstance(carryover_item, str):
112+
return carryover_item
113+
elif isinstance(carryover_item, dict) and "content" in carryover_item:
114+
return str(carryover_item["content"])
115+
else:
116+
return str(carryover_item)
117+
118+
110119
def __post_carryover_processing(chat_info: Dict[str, Any]) -> None:
111120
iostream = IOStream.get_default()
112121

@@ -116,7 +125,7 @@ def __post_carryover_processing(chat_info: Dict[str, Any]) -> None:
116125
UserWarning,
117126
)
118127
print_carryover = (
119-
("\n").join([t for t in chat_info["carryover"]])
128+
("\n").join([_post_process_carryover_item(t) for t in chat_info["carryover"]])
120129
if isinstance(chat_info["carryover"], list)
121130
else chat_info["carryover"]
122131
)
@@ -153,7 +162,7 @@ def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]:
153162
For example:
154163
- `"sender"` - the sender agent.
155164
- `"recipient"` - the recipient agent.
156-
- `"clear_history" (bool) - whether to clear the chat history with the agent.
165+
- `"clear_history"` (bool) - whether to clear the chat history with the agent.
157166
Default is True.
158167
- `"silent"` (bool or None) - (Experimental) whether to print the messages in this
159168
conversation. Default is False.

autogen/agentchat/contrib/retrieve_user_proxy_agent.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import hashlib
22
import os
33
import re
4+
import uuid
45
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union
56

67
from IPython import get_ipython
@@ -135,7 +136,7 @@ def __init__(
135136
- `client` (Optional, chromadb.Client) - the chromadb client. If key not provided, a
136137
default client `chromadb.Client()` will be used. If you want to use other
137138
vector db, extend this class and override the `retrieve_docs` function.
138-
**Deprecated**: use `vector_db` instead.
139+
*[Deprecated]* use `vector_db` instead.
139140
- `docs_path` (Optional, Union[str, List[str]]) - the path to the docs directory. It
140141
can also be the path to a single file, the url to a single file or a list
141142
of directories, files and urls. Default is None, which works only if the
@@ -149,7 +150,7 @@ def __init__(
149150
By default, "extra_docs" is set to false, starting document IDs from zero.
150151
This poses a risk as new documents might overwrite existing ones, potentially
151152
causing unintended loss or alteration of data in the collection.
152-
**Deprecated**: use `new_docs` when use `vector_db` instead of `client`.
153+
*[Deprecated]* use `new_docs` when use `vector_db` instead of `client`.
153154
- `new_docs` (Optional, bool) - when True, only adds new documents to the collection;
154155
when False, updates existing documents and adds new ones. Default is True.
155156
Document id is used to determine if a document is new or existing. By default, the
@@ -172,7 +173,7 @@ def __init__(
172173
models can be found at `https://www.sbert.net/docs/pretrained_models.html`.
173174
The default model is a fast model. If you want to use a high performance model,
174175
`all-mpnet-base-v2` is recommended.
175-
**Deprecated**: no need when use `vector_db` instead of `client`.
176+
*[Deprecated]* no need when use `vector_db` instead of `client`.
176177
- `embedding_function` (Optional, Callable) - the embedding function for creating the
177178
vector db. Default is None, SentenceTransformer with the given `embedding_model`
178179
will be used. If you want to use OpenAI, Cohere, HuggingFace or other embedding
@@ -219,7 +220,7 @@ def __init__(
219220
220221
Example of overriding retrieve_docs - If you have set up a customized vector db, and it's
221222
not compatible with chromadb, you can easily plug in it with below code.
222-
**Deprecated**: Use `vector_db` instead. You can extend VectorDB and pass it to the agent.
223+
*[Deprecated]* use `vector_db` instead. You can extend VectorDB and pass it to the agent.
223224
```python
224225
class MyRetrieveUserProxyAgent(RetrieveUserProxyAgent):
225226
def query_vector_db(
@@ -365,7 +366,11 @@ def _init_db(self):
365366
else:
366367
all_docs_ids = set()
367368

368-
chunk_ids = [hashlib.blake2b(chunk.encode("utf-8")).hexdigest()[:HASH_LENGTH] for chunk in chunks]
369+
chunk_ids = (
370+
[hashlib.blake2b(chunk.encode("utf-8")).hexdigest()[:HASH_LENGTH] for chunk in chunks]
371+
if not self._vector_db.type == "qdrant"
372+
else [str(uuid.UUID(hex=hashlib.md5(chunk.encode("utf-8")).hexdigest())) for chunk in chunks]
373+
)
369374
chunk_ids_set = set(chunk_ids)
370375
chunk_ids_set_idx = [chunk_ids.index(hash_value) for hash_value in chunk_ids_set]
371376
docs = [

autogen/agentchat/contrib/vectordb/base.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Tuple, TypedDict, Union, runtime_checkable
1+
from typing import (
2+
Any,
3+
Callable,
4+
List,
5+
Mapping,
6+
Optional,
7+
Protocol,
8+
Sequence,
9+
Tuple,
10+
TypedDict,
11+
Union,
12+
runtime_checkable,
13+
)
214

315
Metadata = Union[Mapping[str, Any], None]
416
Vector = Union[Sequence[float], Sequence[int]]
@@ -49,6 +61,9 @@ class VectorDB(Protocol):
4961

5062
active_collection: Any = None
5163
type: str = ""
64+
embedding_function: Optional[Callable[[List[str]], List[List[float]]]] = (
65+
None # embeddings = embedding_function(sentences)
66+
)
5267

5368
def create_collection(self, collection_name: str, overwrite: bool = False, get_or_create: bool = True) -> Any:
5469
"""
@@ -185,7 +200,7 @@ class VectorDBFactory:
185200
Factory class for creating vector databases.
186201
"""
187202

188-
PREDEFINED_VECTOR_DB = ["chroma", "pgvector"]
203+
PREDEFINED_VECTOR_DB = ["chroma", "pgvector", "qdrant"]
189204

190205
@staticmethod
191206
def create_vector_db(db_type: str, **kwargs) -> VectorDB:
@@ -207,6 +222,10 @@ def create_vector_db(db_type: str, **kwargs) -> VectorDB:
207222
from .pgvectordb import PGVectorDB
208223

209224
return PGVectorDB(**kwargs)
225+
if db_type.lower() in ["qdrant", "qdrantdb"]:
226+
from .qdrant import QdrantVectorDB
227+
228+
return QdrantVectorDB(**kwargs)
210229
else:
211230
raise ValueError(
212231
f"Unsupported vector database type: {db_type}. Valid types are {VectorDBFactory.PREDEFINED_VECTOR_DB}."

0 commit comments

Comments
 (0)