microsoft / autogen

A programming framework for agentic AI. Discord: https://aka.ms/autogen-dc. Roadmap: https://aka.ms/autogen-roadmap
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
28.23k stars 4.13k forks source link

[Bug]: 'OpenAIEmbeddingFunction' object has no attribute 'encode' related to pgvectordb #2813

Open riefnaibaho opened 1 month ago

riefnaibaho commented 1 month ago

Describe the bug

I follow the guideline on this doc https://microsoft.github.io/autogen/blog/page/2#customizing-embedding-function, but get Attribute Error in pgvectordb.py:422 when use Azure OpenAI embedding_function in the retrieve_config

Steps to reproduce

import chromadb.utils.embedding_functions as embedding_functions azure_openai_ef= embedding_functions.OpenAIEmbeddingFunction( api_key={azure_api_key}", api_base="{azure_api_base}", api_type="azure", api_version="2023-05-15", model_name="text-embedding-ada-002" )

ragproxyagent = RetrieveUserProxyAgent( name="ragproxyagent", human_input_mode="NEVER", max_consecutive_auto_reply=1, retrieve_config={ "task": "qa", "docs_path": ["{local_docs_path}"], "chunk_token_size": 2000, "chunk_mode": "one_line", "model": config_list[0]["model"], "vector_db": "pgvector", # PGVector database "collection_name": "pg_collections", "embedding_function": azure_openai_ef, "db_config": { "connection_string": "postgresql://{user}:{password}@{host:port}/{db_name}", # Optional - connect to an external vector database }, "get_or_create": True, # set to False if you don't want to reuse an existing collection "overwrite": False, # set to True if you want to overwrite an existing collection "distance_threshold": 0.6, # Optional - set the distance threshold for the vector database }, code_execution_config=False, # set to False if you don't want to execute the code )

Model Used

I use text-embedding-ada-002 model

Expected Behavior

I tried with default all-MiniLM-L6-v2 model it works

Screenshots and logs

image

Additional Information

AutoGen version: 0.2.27 Python Version: 3.11.0

mariagbrl commented 1 month ago

i've encountered similar issue