Skip to content

Commit

Permalink
Merge pull request #218 from polywrap/namesty/remove-loop
Browse files Browse the repository at this point in the history
Remove pinecone search loop
  • Loading branch information
namesty committed Feb 21, 2024
2 parents 2436e84 + e15ae58 commit a09360d
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ def get_top_matching_projects(prompt: str) -> list[Projects]:
)

target_unique_ids = 35
total_unique_ids: list[str] = []

while (len(total_unique_ids) < target_unique_ids):
matches = vectorstore.similarity_search(query=prompt, k=300, filter={"id": { "$nin": total_unique_ids }})
query_to_matched_project_ids = [match.metadata["id"] for match in matches]

total_unique_ids += remove_duplicates_and_preserve_order(query_to_matched_project_ids)
matches = vectorstore.similarity_search(query=prompt, k=1500)
query_to_matched_project_ids = [match.metadata["id"] for match in matches]

total_unique_ids = remove_duplicates_and_preserve_order(query_to_matched_project_ids)

matched_projects: list[tuple[Projects, list[Answer]]] = get_projects_by_ids(total_unique_ids[:target_unique_ids])

Expand Down

0 comments on commit a09360d

Please sign in to comment.