{"id":18798608,"url":"https://github.com/liteobject/autogen_with_chromadb","last_synced_at":"2026-01-02T02:30:15.360Z","repository":{"id":222590051,"uuid":"757816008","full_name":"LiteObject/autogen_with_chromadb","owner":"LiteObject","description":"This repository contains a Python script that uses the `autogen` and `chromadb` libraries to create a chatbot that can retrieve information from a database and generate responses based on a language model. The chatbot can also execute code and provide answers based on the context of the user's question.","archived":false,"fork":false,"pushed_at":"2024-02-17T04:17:20.000Z","size":3486,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-29T18:21:58.448Z","etag":null,"topics":["ai-agent","autogen","chromadb","vector-database"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiteObject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-15T03:22:19.000Z","updated_at":"2024-06-24T01:30:59.000Z","dependencies_parsed_at":"2024-11-07T22:22:44.465Z","dependency_job_id":null,"html_url":"https://github.com/LiteObject/autogen_with_chromadb","commit_stats":null,"previous_names":["liteobject/autogen_with_chromadb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Fautogen_with_chromadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Fautogen_with_chromadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Fautogen_with_chromadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Fautogen_with_chromadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiteObject","download_url":"https://codeload.github.com/LiteObject/autogen_with_chromadb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239727055,"owners_count":19687099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","autogen","chromadb","vector-database"],"created_at":"2024-11-07T22:12:28.531Z","updated_at":"2026-01-02T02:30:15.309Z","avatar_url":"https://github.com/LiteObject.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Autogen with Chroma DB \u003cimg src=\"https://docs.trychroma.com/img/chroma.svg\"  width=\"10%\" /\u003e\n\n\u003eAutoGen is an open-source framework that enables the development of conversational AI applications using multiple agents.\n\n\u003eChroma DB is an open-source vector database for storing and retrieving vector embeddings.\n\n### Create virtual python environment\n- `virtualenv -p python3.11 env_name`\n- `python -m venv env_name`\n\n### Activate the virtual env\n- `env_name/scripts/activate`\n\n---\n## Installs AutoGen \u0026 Chroms DB\n    pip install -U \"pyautogen[retrievechat]\" chromadb\n\n\n- `-U` tells pip to upgrade any already installed packages to their latest versions before installing.\n- `\"pyautogen[retrievechat]\"` installs the pyautogen package and also installs the optional \"retrievechat\" extra feature of that package\n\n## Set environment variable AUTOGEN_USE_DOCKER to False\n\n### Bash Command:\n    export AUTOGEN_USE_DOCKER=False\n\n\n### PowerShell Command:\n    $Env:AUTOGEN_USE_DOCKER=\"False\"\n\n\nExporting `AUTOGEN_USE_DOCKER=False` tells pyautogen to run its tasks directly on the host rather than using Docker containers. It bypasses the Docker dependency but also loses some of the isolation benefits Docker provides.\n\n## Set environment variable OPENAI_API_KEY=???\n\n### Bash Command:\n    export OPENAI_API_KEY=Fxxxxxxxxxxxxxxxxxxxxxxxxx\n\n### PowerShell Command:\n    $Env:OPENAI_API_KEY=\"xxxxxxxxxxxxxxxxxxxxxxxxx\"\n\n\n## Run `app.py`\n    python app.py\n\n## Explanation of the code file\n\nThis code file defines a chatbot system using the autogen and chromadb libraries. Here's a step-by-step breakdown of the code:\n\n### Importing Libraries\nThe first step is to import the necessary libraries. In this case, we're using autogen and chromadb to create a chatbot that can retrieve information from a database and generate responses based on a language model.\n\n```python\nimport autogen\nimport chromadb\n```\n\n### Defining the Chatbot Assistant\nNext, we define the chatbot assistant using the AssistantAgent class from the autogen library. This class takes a name, language model configuration, and system message as input.\n\n```python\nassistant = AssistantAgent(\n    name=\"my_assistant\",\n    llm_config=llm_config_proxy,\n    system_message=\"You are a helpful assistant. Provide accurate answers based on the context. Respond 'Unsure about answer' if uncertain.\"\n)\n```\n### Defining the User\nWe also define the user using the RetrieveUserProxyAgent class from the autogen.agentchat.contrib module. This class takes a name, human input mode, system message, maximum number of consecutive auto-replies, and configuration for retrieving information from a database as input.\n\n```python\nuser = RetrieveUserProxyAgent(\n    name=\"me_user\",\n    human_input_mode=\"NEVER\",\n    system_message=\"Assistant who has extra content retrieval power for solving difficult problems.\",\n    max_consecutive_auto_reply=10,\n    retrieve_config={\n        \"task\": \"code\",\n        \"docs_path\": ['./docs/autogen.pdf'],\n        \"chunk_token_size\": 1000,\n        \"model\": config_list[0][\"model\"],\n        \"client\": chromadb.PersistentClient(path='/tmp/chromadb'),\n        \"collection_name\": \"pdfreader\",\n        \"get_or_create\": True,\n    },\n    code_execution_config={\"work_dir\": \"coding\"},\n)\n```\n\n### Defining the User Question\nWe define the user's question or prompt as a string variable.\n\n```python\nuser_question = \"\"\"\nCompose a short blog post showcasing how AutoGen is revolutionizing the future of Generative AI \nthrough the collaboration of various agents. Craft an introduction, main body, and a compelling \nconclusion. Encourage readers to share the post. Keep the post under 500 words.\n\"\"\"\n```\n\n### Initiating the Chat\nFinally, we initiate the chat session between the user and the chatbot using the initiate_chat method of the RetrieveUserProxyAgent class.\n\n```python\nuser.initiate_chat(assistant, problem=user_question)\n```\n\n### Summary\nOverall, this code file defines a chatbot system that can respond to user questions or prompts by retrieving information from a database and generating responses based on a language model. The chatbot can also execute code and provide answers based on the context of the user's question.\n\n---\n## Links\n\n- [Getting started with Chroma DB](https://docs.trychroma.com/getting-started)\n- [AutoGen: Enable Next-Gen Large Language Model Applications](https://microsoft.github.io/autogen/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliteobject%2Fautogen_with_chromadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliteobject%2Fautogen_with_chromadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliteobject%2Fautogen_with_chromadb/lists"}