-
Notifications
You must be signed in to change notification settings - Fork 8
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
Sliding MessageDB window #76
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
To run these tests, first set up a mock Postgres instance with the following commands | ||
(make sure you don't have anything running on port 0.0.0.0:5432): | ||
|
||
```sh | ||
docker pull ankane/pgvector | ||
docker run --name mock-postgres -p 5432:5432 \ | ||
-e POSTGRES_USER=mock_user -e POSTGRES_PASSWORD=mock_password -e POSTGRES_DB=mock_db \ | ||
-d ankane/pgvector | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2023-present Oori Data <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# test/embedding/test_pgvector.py | ||
# test/embedding/test_pgvector_doc.py | ||
''' | ||
Set up a mock Postgres instance with the following commands | ||
(make sure you don't have anything running on port 0.0.0.0:5432))): | ||
docker pull ankane/pgvector | ||
docker run --name mock-postgres -p 5432:5432 \ | ||
-e POSTGRES_USER=mock_user -e POSTGRES_PASSWORD=mock_password -e POSTGRES_DB=mock_db \ | ||
-d ankane/pgvector | ||
|
||
Then run the tests with: | ||
pytest test | ||
After setup as described in the README.md for this directory, run the tests with: | ||
|
||
or | ||
pytest test | ||
|
||
pytest test/embedding/test_pgvector.py | ||
or, for just this test module: | ||
|
||
Uses fixtures from ../conftest.py | ||
pytest test/embedding/test_pgvector_doc.py | ||
|
||
Uses fixtures from conftest.py in current & parent directories | ||
''' | ||
|
||
import pytest | ||
|
@@ -133,12 +126,14 @@ def encode_tweaker(*args, **kwargs): | |
|
||
# Using limit default | ||
sim_search = await DB.search(text='Text', tags=['tag1', 'tag3'], conjunctive=False) | ||
assert sim_search is not None, Exception("No results returned from filtered search") | ||
assert len(list(sim_search)) == 3, Exception(f"There should be 3 results, received {sim_search}") | ||
assert sim_search is not None, Exception("Null return from filtered search") | ||
sim_search = list(sim_search) | ||
assert len(sim_search) == 3, Exception(f"There should be 3 results, received {sim_search}") | ||
|
||
sim_search = await DB.search(text='Text', tags=['tag1', 'tag3'], conjunctive=False, limit=1000) | ||
assert sim_search is not None, Exception("No results returned from filtered search") | ||
assert len(list(sim_search)) == 3, Exception(f"There should be 3 results, received {sim_search}") | ||
assert sim_search is not None, Exception("Null return from filtered search") | ||
sim_search = list(sim_search) | ||
assert len(sim_search) == 3 | ||
|
||
texts = ['Hello world', 'Hello Dolly', 'Good-Bye to All That'] | ||
authors = ['Brian Kernighan', 'Louis Armstrong', 'Robert Graves'] | ||
|
@@ -148,12 +143,15 @@ def encode_tweaker(*args, **kwargs): | |
await DB.insert_many(records) | ||
|
||
sim_search = await DB.search(text='Hi there!', threshold=0.999, limit=0) | ||
assert sim_search is not None, Exception("No results returned from filtered search") | ||
assert len(list(sim_search)) == 3, Exception(f"There should be 3 results, received {sim_search}") | ||
|
||
sim_search = await DB.search(text='Hi there!', threshold=0.999, limit=2) | ||
assert sim_search is not None, Exception("No results returned from filtered search") | ||
assert len(list(sim_search)) == 2, Exception(f"There should be 2 results, received {sim_search}") | ||
assert sim_search is not None, Exception("Null return from filtered search") | ||
sim_search = list(sim_search) | ||
# FIXME: Double-check this expected result | ||
assert len(sim_search) == 10 | ||
|
||
sim_search = await DB.search(text='Hi there!', threshold=0.5, limit=2) | ||
assert sim_search is not None, Exception("Null return from filtered search") | ||
sim_search = list(sim_search) | ||
assert len(list(sim_search)) == 2 | ||
|
||
await DB.drop_table() | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should prob take a pass at moving all sql out of the
.py
s at some pointThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Maybe make it a goal for 0.9.0.