Skip to content

Commit 1b8d65d

Browse files
Knucklessg1thinkallHk669
authored
2447 fix pgvector tests and notebook (#2455)
* Re-added missing notebook * Test installing postgres * Error handle the connection. * Fixed import. * Fixed import. * Fixed creation of collection without client. * PGVector portion working. OpenAI untested. * Fixed prints. * Added output. * Fixed pre-commits. * Run pgvector notebook * Improve efficiency of get_collection * Fix delete_collection * Fixed issues with pytests and validated functions. * Validated pytests. * Fixed pre-commits * Separated extra_requires to allow more logic. Retrieve_chat base dependencies included on pgvector and qdrant. * Fixed extra newline. * Added username and password fields. * URL Encode the connection string parameters to support symbols like % * Fixed pre-commits. * Added pgvector service * pgvector doesn't have health intervals. * Switched to colon based key values. * Run on Ubuntu only. Linux is only option with container service support. * Using default credentials instead. * Fix postgres setup * Fix postgres setup * Don't skip tests on win and mac * Fix command error * Try apt install postgresql * Assert table does not exist when deleted. * Raise value error on a empty list or None value provided for IDs * pre-commit * Add install pgvector * Add install pgvector * Reorg test files, create a separate job for test pgvector * Fix format * Fix env format * Simplify job name, enable test_retrieve_config * Fix test_retrieve_config * Corrected behavior for get_docs_by_ids with no ids returning all docs. * Corrected behavior for get_docs_by_ids with no ids returning all docs. * Fixed pre-commits. * Added return values for all functions. * Validated distance search is implemented correctly. * Validated all pytests * Removed print. * Added default clause. * Make ids optional * Fix test, make it more robust * Bump version of openai for the vector_store support * Added support for choosing the sentence transformer model. * Added error handling for model name entered. * Updated model info. * Added model_name db_config param. * pre-commit fixes and last link fix. * Use secrets password. * fix: link fixed * updated tests * Updated config_list. * pre-commit fix. * Added chat_result to all output. Unable to re-run notebooks. * Pre-commit fix detected this requirement. * Fix python 3.8 and 3.9 not supported for macos * Fix python 3.8 and 3.9 not supported for macos * Fix format * Reran notebook with MetaLlama3Instruct7BQ4_k_M * added gpt model. * Reran notebook --------- Co-authored-by: Li Jiang <[email protected]> Co-authored-by: Hk669 <[email protected]>
1 parent 600bd3f commit 1b8d65d

11 files changed

+784
-1968
lines changed

.github/workflows/contrib-openai.yml

+18-7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ jobs:
2424
python-version: ["3.10"]
2525
runs-on: ${{ matrix.os }}
2626
environment: openai1
27+
services:
28+
pgvector:
29+
image: ankane/pgvector
30+
env:
31+
POSTGRES_DB: postgres
32+
POSTGRES_USER: postgres
33+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
34+
POSTGRES_HOST_AUTH_METHOD: trust
35+
options: >-
36+
--health-cmd pg_isready
37+
--health-interval 10s
38+
--health-timeout 5s
39+
--health-retries 5
40+
ports:
41+
- 5432:5432
2742
steps:
2843
# checkout to pr branch
2944
- name: Checkout
@@ -41,29 +56,25 @@ jobs:
4156
pip install -e .
4257
python -c "import autogen"
4358
pip install coverage pytest-asyncio
44-
- name: Install PostgreSQL
45-
run: |
46-
sudo apt install postgresql -y
47-
- name: Start PostgreSQL service
48-
run: sudo service postgresql start
4959
- name: Install packages for test when needed
5060
run: |
5161
pip install docker
52-
pip install -e .[retrievechat-qdrant,retrievechat-pgvector]
62+
pip install -e .[retrievechat,retrievechat-qdrant,retrievechat-pgvector]
5363
- name: Coverage
5464
env:
5565
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
5666
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
5767
AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }}
5868
OAI_CONFIG_LIST: ${{ secrets.OAI_CONFIG_LIST }}
5969
run: |
60-
coverage run -a -m pytest test/agentchat/contrib/test_retrievechat.py::test_retrievechat test/agentchat/contrib/test_qdrant_retrievechat.py::test_retrievechat test/agentchat/contrib/test_pgvector_retrievechat.py::test_retrievechat
70+
coverage run -a -m pytest -k test_retrievechat test/agentchat/contrib/retrievechat
6171
coverage xml
6272
- name: Upload coverage to Codecov
6373
uses: codecov/codecov-action@v3
6474
with:
6575
file: ./coverage.xml
6676
flags: unittests
77+
6778
CompressionTest:
6879
strategy:
6980
matrix:

.github/workflows/contrib-tests.yml

+65-13
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
os: [ubuntu-latest, macos-latest, windows-2019]
30+
os: [macos-latest, windows-2019]
3131
python-version: ["3.9", "3.10", "3.11"]
3232
exclude:
3333
- os: macos-latest
@@ -45,30 +45,82 @@ jobs:
4545
- name: Install qdrant_client when python-version is 3.10
4646
if: matrix.python-version == '3.10'
4747
run: |
48-
pip install .[retrievechat-qdrant]
48+
pip install -e .[retrievechat-qdrant]
49+
- name: Install packages and dependencies for RetrieveChat
50+
run: |
51+
pip install -e .[retrievechat]
52+
- name: Set AUTOGEN_USE_DOCKER based on OS
53+
shell: bash
54+
run: |
55+
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
56+
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
57+
fi
58+
- name: Coverage
59+
run: |
60+
pip install coverage>=5.3
61+
coverage run -a -m pytest test/test_retrieve_utils.py test/agentchat/contrib/retrievechat test/agentchat/contrib/vectordb --skip-openai
62+
coverage xml
63+
- name: Upload coverage to Codecov
64+
uses: codecov/codecov-action@v3
65+
with:
66+
file: ./coverage.xml
67+
flags: unittests
68+
69+
RetrieveChatTest-Ubuntu:
70+
runs-on: ubuntu-latest
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
python-version: ["3.9", "3.10", "3.11"]
75+
services:
76+
pgvector:
77+
image: ankane/pgvector
78+
env:
79+
POSTGRES_DB: postgres
80+
POSTGRES_USER: postgres
81+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
82+
POSTGRES_HOST_AUTH_METHOD: trust
83+
options: >-
84+
--health-cmd pg_isready
85+
--health-interval 10s
86+
--health-timeout 5s
87+
--health-retries 5
88+
ports:
89+
- 5432:5432
90+
steps:
91+
- uses: actions/checkout@v4
92+
- name: Set up Python ${{ matrix.python-version }}
93+
uses: actions/setup-python@v5
94+
with:
95+
python-version: ${{ matrix.python-version }}
96+
- name: Install packages and dependencies for all tests
97+
run: |
98+
python -m pip install --upgrade pip wheel
99+
pip install pytest
100+
- name: Install qdrant_client when python-version is 3.10
101+
if: matrix.python-version == '3.10'
102+
run: |
103+
pip install -e .[retrievechat-qdrant]
104+
- name: Install pgvector when on linux
105+
run: |
106+
pip install -e .[retrievechat-pgvector]
49107
- name: Install unstructured when python-version is 3.9 and on linux
108+
if: matrix.python-version == '3.9'
50109
run: |
51110
sudo apt-get update
52111
sudo apt-get install -y tesseract-ocr poppler-utils
53112
pip install unstructured[all-docs]==0.13.0
54-
- name: Install and Start PostgreSQL
55-
runs-on: ubuntu-latest
113+
- name: Install packages and dependencies for RetrieveChat
56114
run: |
57-
sudo apt install postgresql -y
58-
sudo service postgresql start
59-
- name: Install packages and dependencies for PGVector
60-
run: |
61-
pip install -e .[retrievechat-pgvector]
115+
pip install -e .[retrievechat]
62116
- name: Set AUTOGEN_USE_DOCKER based on OS
63117
shell: bash
64118
run: |
65-
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
66-
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
67-
fi
119+
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
68120
- name: Coverage
69121
run: |
70122
pip install coverage>=5.3
71-
coverage run -a -m pytest test/test_retrieve_utils.py test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py test/agentchat/contrib/vectordb --skip-openai
123+
coverage run -a -m pytest test/test_retrieve_utils.py test/agentchat/contrib/retrievechat test/agentchat/contrib/vectordb --skip-openai
72124
coverage xml
73125
- name: Upload coverage to Codecov
74126
uses: codecov/codecov-action@v3

0 commit comments

Comments
 (0)