Skip to content

Commit

Permalink
Merge branch 'main' into feat/Qdrant_docs_reconstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRochefortB authored Jan 2, 2025
2 parents 745a1ce + 525bb32 commit 28a26af
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
- run: uv python pin ${{ matrix.python-version }}
- uses: hynek/build-and-inspect-python-package@v2
- run: uv sync --python-preference=only-managed
- run: uv run refurb paperqa tests
- run: uv run pylint paperqa
test:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
rev: v0.8.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down Expand Up @@ -63,7 +63,7 @@ repos:
hooks:
- id: uv-lock
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.58.1
rev: 39.75.1
hooks:
- id: renovate-config-validator
args: [--strict]
Expand Down
6 changes: 2 additions & 4 deletions paperqa/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,8 @@ async def _build_texts_index(self, embedding_model: EmbeddingModel) -> None:
strict=True,
):
t.embedding = t_embedding
if asyncio.iscoroutinefunction(self.texts_index.add_texts_and_embeddings):
await self.texts_index.add_texts_and_embeddings(texts)
else:
self.texts_index.add_texts_and_embeddings(texts)

await self.texts_index.add_texts_and_embeddings(texts)

async def retrieve_texts(
self,
Expand Down
10 changes: 6 additions & 4 deletions paperqa/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def __len__(self) -> int:
return len(self.texts_hashes)

@abstractmethod
def add_texts_and_embeddings(self, texts: Iterable[Embeddable]) -> None:
async def add_texts_and_embeddings(self, texts: Iterable[Embeddable]) -> None:
"""Add texts and their embeddings to the store."""
self.texts_hashes.update(hash(t) for t in texts)

@abstractmethod
Expand Down Expand Up @@ -200,8 +201,8 @@ def clear(self) -> None:
self._embeddings_matrix = None
self._texts_filter = None

def add_texts_and_embeddings(self, texts: Iterable[Embeddable]) -> None:
super().add_texts_and_embeddings(texts)
async def add_texts_and_embeddings(self, texts: Iterable[Embeddable]) -> None:
await super().add_texts_and_embeddings(texts)
self.texts.extend(texts)
self._embeddings_matrix = np.array([t.embedding for t in self.texts])

Expand Down Expand Up @@ -352,7 +353,8 @@ async def clear(self) -> None:
self._point_ids = None

async def add_texts_and_embeddings(self, texts: Iterable[Embeddable]) -> None:
super().add_texts_and_embeddings(texts)

await super().add_texts_and_embeddings(texts)

texts_list = list(texts)

Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ testpaths = ["tests"]
[tool.refurb]
enable_all = true
ignore = [
"FURB101", # FURB101, FURB103, FURB141, FURB144, FURB146, FURB147, FURB150, FURB155: no need for pathlib
"FURB103",
"FURB141",
"FURB101", # Rely on ruff FURB101 for this
"FURB103", # Rely on ruff FURB103 for this
"FURB141", # FURB141, FURB144, FURB146, FURB147, FURB150, FURB155: don't care to enforce pathlib
"FURB144",
"FURB146",
"FURB147",
Expand Down Expand Up @@ -379,6 +379,7 @@ extend-select = [
"FURB166",
"FURB171",
"FURB180",
"FURB181",
"FURB188",
"FURB189",
"FURB192",
Expand Down Expand Up @@ -440,6 +441,8 @@ ignore = [
"FBT002",
"FIX", # Don't care to prevent TODO, FIXME, etc.
"FLY002", # Can be less readable
"FURB101", # FURB101, FURB103: don't care to enforce pathlib
"FURB103",
"G004", # f-strings are convenient
"INP001", # Can use namespace packages
"ISC001", # For ruff format compatibility
Expand Down

0 comments on commit 28a26af

Please sign in to comment.