autogen/website/docs/topics/retrieval_augmentation.md
Example Setup: RAG with Retrieval Augmented Agents with PGVector The following is an example setup demonstrating how to create retrieval augmented agents in AutoGen:  ### Step 1. Create an instance of `RetrieveAssistantAgent` and `RetrieveUserProxyAgent`.  Here `RetrieveUserProxyAgent` instance acts as a proxy agent that retrieves relevant information based on the user's input.  Specify the connection_string, or the host, port, database, username, and password in the db_config.  ```python assistant = RetrieveAssistantAgent(     name="assistant",     system_message="You are a helpful assistant.",     llm_config={         "timeout": 600,         "cache_seed": 42,         "config_list": config_list,     }, ) ragproxyagent = RetrieveUserProxyAgent(     name="ragproxyagent",     human_input_mode="NEVER",     max_consecutive_auto_reply=3,     retrieve_config={         "task": "code",         "docs_path": [             "https://raw.githubusercontent.com/microsoft/FLAML/main/website/docs/Examples/Integrate%20-%20Spark.md",             "https://raw.githubusercontent.com/microsoft/FLAML/main/website/docs/Research.md",             os.path.join(os.path.abspath(""), "..", "website", "docs"),         ],         "vector_db": "pgvector",         "collection_name": "autogen_docs",         "db_config": {             "connection_string": "postgresql://testuser:testpwd@localhost:5432/vectordb", # Optional - connect to an external vector database             # "host": None, # Optional vector database host             # "port": None, # Optional vector database port             # "database": None, # Optional vector database name             # "username": None, # Optional vector database username             # "password": None, # Optional vector database password         },         "custom_text_types": ["mdx"],         "chunk_token_size": 2000,         "model": config_list[0]["model"],         "get_or_create": True,     },     code_execution_config=False, ) ```  ### Step 2. Initiating Agent Chat with Retrieval Augmentation  Once the retrieval augmented agents are set up, you can initiate a chat with retrieval augmentation using the following code:  ```python code_problem = "How can I use FLAML to perform a classification task and use spark to do parallel training. Train 30 seconds and force cancel jobs if time limit is reached." ragproxyagent.initiate_chat(     assistant, message=ragproxyagent.message_generator, problem=code_problem, search_string="spark" )  # search_string is used as an extra filter for the embeddings search, in this case, we only want to search documents that contain "spark". ``` 