Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable embedding_function in RetrieveUserProxyAgent to create initial… #4183

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions autogen/agentchat/contrib/retrieve_user_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,24 @@ def _init_db(self):
)
chunk_ids_set = set(chunk_ids)
chunk_ids_set_idx = [chunk_ids.index(hash_value) for hash_value in chunk_ids_set]
docs = [
Document(id=chunk_ids[idx], content=chunks[idx], metadata=sources[idx])
for idx in chunk_ids_set_idx
if chunk_ids[idx] not in all_docs_ids
]

if self._embedding_function is None:
docs = [
Document(id=chunk_ids[idx], content=chunks[idx], metadata=sources[idx])
for idx in chunk_ids_set_idx
if chunk_ids[idx] not in all_docs_ids
]
else:
docs = [
Document(
id=chunk_ids[idx],
content=chunks[idx],
metadata=sources[idx],
embedding=self._embedding_function([chunks[idx]])[0]
)
for idx in chunk_ids_set_idx
if chunk_ids[idx] not in all_docs_ids
]

self._vector_db.insert_docs(docs=docs, collection_name=self._collection_name, upsert=True)

Expand Down
Loading