Skip to content

Commit c77daa7

Browse files
committed
Removed all deprecated methods and attributes
1 parent beb838e commit c77daa7

File tree

6 files changed

+3
-405
lines changed

6 files changed

+3
-405
lines changed

src/paperqa/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
from lmi import (
42
EmbeddingModel,
53
HybridEmbeddingModel,
@@ -21,17 +19,10 @@
2119
VectorStore,
2220
)
2321
from paperqa.settings import Settings, get_settings
24-
from paperqa.types import Answer, Context, Doc, DocDetails, Text
22+
from paperqa.types import Context, Doc, DocDetails, Text
2523
from paperqa.version import __version__
2624

27-
# TODO: remove after refactoring all models to avoid using _* private vars
28-
warnings.filterwarnings(
29-
"ignore", message="Valid config keys have changed in V2:", module="pydantic"
30-
)
31-
32-
3325
__all__ = [
34-
"Answer",
3526
"Context",
3627
"Doc",
3728
"DocDetails",

src/paperqa/agents/search.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pickle
1010
import re
1111
import sys
12-
import warnings
1312
import zlib
1413
from collections import Counter
1514
from collections.abc import AsyncIterator, Callable, Sequence
@@ -613,38 +612,21 @@ def progress_bar_update() -> None:
613612
return contextlib.nullcontext(), None
614613

615614

616-
async def get_directory_index( # noqa: PLR0912
617-
index_name: str | None = None,
618-
sync_index_w_directory: bool = True,
619-
settings: MaybeSettings = None,
620-
build: bool = True,
615+
async def get_directory_index(
616+
settings: MaybeSettings = None, build: bool = True
621617
) -> SearchIndex:
622618
"""
623619
Create a Tantivy index by reading from a directory of text files.
624620
625621
This function only reads from the source directory, not edits or writes to it.
626622
627623
Args:
628-
index_name: Deprecated override on the name of the index. If unspecified,
629-
the default behavior is to generate the name from the input settings.
630-
sync_index_w_directory: Opt-out flag to sync the index (add or delete index
631-
files) with the source paper directory.
632624
settings: Application settings.
633625
build: Opt-out flag (default is True) to read the contents of the source paper
634626
directory and if sync_index_w_directory is enabled also update the index.
635627
"""
636628
_settings = get_settings(settings)
637629
index_settings = _settings.agent.index
638-
if index_name:
639-
warnings.warn(
640-
"The index_name argument has been moved to"
641-
f" {type(_settings.agent.index).__name__},"
642-
" this deprecation will conclude in version 6.",
643-
category=DeprecationWarning,
644-
stacklevel=2,
645-
)
646-
index_settings.name = index_name
647-
del index_name
648630

649631
search_index = SearchIndex(
650632
fields=[*SearchIndex.REQUIRED_FIELDS, "title", "year"],
@@ -660,17 +642,6 @@ async def get_directory_index( # noqa: PLR0912
660642
)
661643
return search_index
662644

663-
if not sync_index_w_directory:
664-
warnings.warn(
665-
"The sync_index_w_directory argument has been moved to"
666-
f" {type(_settings.agent.index).__name__},"
667-
" this deprecation will conclude in version 6.",
668-
category=DeprecationWarning,
669-
stacklevel=2,
670-
)
671-
index_settings.sync_with_paper_directory = sync_index_w_directory
672-
del sync_index_w_directory
673-
674645
paper_directory = anyio.Path(index_settings.paper_directory)
675646
manifest = await maybe_get_manifest(
676647
filename=await index_settings.finalize_manifest_file()

src/paperqa/docs.py

Lines changed: 0 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import re
77
import tempfile
88
import urllib.request
9-
import warnings
109
from collections.abc import Callable, Sequence
1110
from datetime import datetime
1211
from io import BytesIO
@@ -32,7 +31,6 @@
3231
from paperqa.types import Doc, DocDetails, DocKey, PQASession, Text
3332
from paperqa.utils import (
3433
citation_to_docname,
35-
get_loop,
3634
maybe_is_html,
3735
maybe_is_pdf,
3836
maybe_is_text,
@@ -90,35 +88,6 @@ def _get_unique_name(self, docname: str) -> str:
9088
docname += suffix
9189
return docname
9290

93-
def add_file(
94-
self,
95-
file: BinaryIO,
96-
citation: str | None = None,
97-
docname: str | None = None,
98-
dockey: DocKey | None = None,
99-
settings: MaybeSettings = None,
100-
llm_model: LLMModel | None = None,
101-
embedding_model: EmbeddingModel | None = None,
102-
) -> str | None:
103-
warnings.warn(
104-
"The synchronous `add_file` method is being deprecated in favor of the"
105-
" asynchronous `aadd_file` method, this deprecation will conclude in"
106-
" version 6.",
107-
category=DeprecationWarning,
108-
stacklevel=2,
109-
)
110-
return get_loop().run_until_complete(
111-
self.aadd_file(
112-
file,
113-
citation=citation,
114-
docname=docname,
115-
dockey=dockey,
116-
settings=settings,
117-
llm_model=llm_model,
118-
embedding_model=embedding_model,
119-
)
120-
)
121-
12291
async def aadd_file(
12392
self,
12493
file: BinaryIO,
@@ -158,35 +127,6 @@ async def aadd_file(
158127
**kwargs,
159128
)
160129

161-
def add_url(
162-
self,
163-
url: str,
164-
citation: str | None = None,
165-
docname: str | None = None,
166-
dockey: DocKey | None = None,
167-
settings: MaybeSettings = None,
168-
llm_model: LLMModel | None = None,
169-
embedding_model: EmbeddingModel | None = None,
170-
) -> str | None:
171-
warnings.warn(
172-
"The synchronous `add_url` method is being deprecated in favor of the"
173-
" asynchronous `aadd_url` method, this deprecation will conclude in"
174-
" version 6.",
175-
category=DeprecationWarning,
176-
stacklevel=2,
177-
)
178-
return get_loop().run_until_complete(
179-
self.aadd_url(
180-
url,
181-
citation=citation,
182-
docname=docname,
183-
dockey=dockey,
184-
settings=settings,
185-
llm_model=llm_model,
186-
embedding_model=embedding_model,
187-
)
188-
)
189-
190130
async def aadd_url(
191131
self,
192132
url: str,
@@ -211,43 +151,6 @@ async def aadd_url(
211151
embedding_model=embedding_model,
212152
)
213153

214-
def add(
215-
self,
216-
path: str | os.PathLike,
217-
citation: str | None = None,
218-
docname: str | None = None,
219-
dockey: DocKey | None = None,
220-
title: str | None = None,
221-
doi: str | None = None,
222-
authors: list[str] | None = None,
223-
settings: MaybeSettings = None,
224-
llm_model: LLMModel | None = None,
225-
embedding_model: EmbeddingModel | None = None,
226-
**kwargs,
227-
) -> str | None:
228-
warnings.warn(
229-
"The synchronous `add` method is being deprecated in favor of the"
230-
" asynchronous `aadd` method, this deprecation will conclude in"
231-
" version 6.",
232-
category=DeprecationWarning,
233-
stacklevel=2,
234-
)
235-
return get_loop().run_until_complete(
236-
self.aadd(
237-
path,
238-
citation=citation,
239-
docname=docname,
240-
dockey=dockey,
241-
title=title,
242-
doi=doi,
243-
authors=authors,
244-
settings=settings,
245-
llm_model=llm_model,
246-
embedding_model=embedding_model,
247-
**kwargs,
248-
)
249-
)
250-
251154
async def aadd( # noqa: PLR0912
252155
self,
253156
path: str | os.PathLike,
@@ -411,26 +314,6 @@ async def aadd( # noqa: PLR0912
411314
return doc.docname
412315
return None
413316

414-
def add_texts(
415-
self,
416-
texts: list[Text],
417-
doc: Doc,
418-
settings: MaybeSettings = None,
419-
embedding_model: EmbeddingModel | None = None,
420-
) -> bool:
421-
warnings.warn(
422-
"The synchronous `add_texts` method is being deprecated in favor of the"
423-
" asynchronous `aadd_texts` method, this deprecation will conclude in"
424-
" version 6.",
425-
category=DeprecationWarning,
426-
stacklevel=2,
427-
)
428-
return get_loop().run_until_complete(
429-
self.aadd_texts(
430-
texts, doc, settings=settings, embedding_model=embedding_model
431-
)
432-
)
433-
434317
async def aadd_texts(
435318
self,
436319
texts: list[Text],
@@ -552,39 +435,9 @@ async def retrieve_texts(
552435
matches = [m for m in matches if m.doc.dockey not in self.deleted_dockeys]
553436
return matches[:k]
554437

555-
def get_evidence(
556-
self,
557-
query: PQASession | str,
558-
exclude_text_filter: set[str] | None = None,
559-
settings: MaybeSettings = None,
560-
callbacks: Sequence[Callable] | None = None,
561-
embedding_model: EmbeddingModel | None = None,
562-
summary_llm_model: LLMModel | None = None,
563-
partitioning_fn: Callable[[Embeddable], int] | None = None,
564-
) -> PQASession:
565-
warnings.warn(
566-
"The synchronous `get_evidence` method is being deprecated in favor of the"
567-
" asynchronous `aget_evidence` method, this deprecation will conclude in"
568-
" version 6.",
569-
category=DeprecationWarning,
570-
stacklevel=2,
571-
)
572-
return get_loop().run_until_complete(
573-
self.aget_evidence(
574-
query=query,
575-
exclude_text_filter=exclude_text_filter,
576-
settings=settings,
577-
callbacks=callbacks,
578-
embedding_model=embedding_model,
579-
summary_llm_model=summary_llm_model,
580-
partitioning_fn=partitioning_fn,
581-
)
582-
)
583-
584438
async def aget_evidence(
585439
self,
586440
query: PQASession | str,
587-
exclude_text_filter: set[str] | None = None,
588441
settings: MaybeSettings = None,
589442
callbacks: Sequence[Callable] | None = None,
590443
embedding_model: EmbeddingModel | None = None,
@@ -611,21 +464,6 @@ async def aget_evidence(
611464
if summary_llm_model is None:
612465
summary_llm_model = evidence_settings.get_summary_llm()
613466

614-
if exclude_text_filter is not None:
615-
text_name = Text.__name__
616-
warnings.warn(
617-
(
618-
"The 'exclude_text_filter' argument did not work as intended"
619-
f" due to a mix-up in excluding {text_name}.name vs {text_name}."
620-
f" This bug enabled us to have 2+ contexts per {text_name}, so to"
621-
" first-class that capability and simplify our implementation,"
622-
" we're removing the 'exclude_text_filter' argument."
623-
" This deprecation will conclude in version 6"
624-
),
625-
category=DeprecationWarning,
626-
stacklevel=2,
627-
)
628-
629467
if answer_config.evidence_retrieval:
630468
matches = await self.retrieve_texts(
631469
session.question,
@@ -684,35 +522,6 @@ async def aget_evidence(
684522
session.contexts += [r for r, _ in results]
685523
return session
686524

687-
def query(
688-
self,
689-
query: PQASession | str,
690-
settings: MaybeSettings = None,
691-
callbacks: Sequence[Callable] | None = None,
692-
llm_model: LLMModel | None = None,
693-
summary_llm_model: LLMModel | None = None,
694-
embedding_model: EmbeddingModel | None = None,
695-
partitioning_fn: Callable[[Embeddable], int] | None = None,
696-
) -> PQASession:
697-
warnings.warn(
698-
"The synchronous `query` method is being deprecated in favor of the"
699-
" asynchronous `aquery` method, this deprecation will conclude in"
700-
" version 6.",
701-
category=DeprecationWarning,
702-
stacklevel=2,
703-
)
704-
return get_loop().run_until_complete(
705-
self.aquery(
706-
query,
707-
settings=settings,
708-
callbacks=callbacks,
709-
llm_model=llm_model,
710-
summary_llm_model=summary_llm_model,
711-
embedding_model=embedding_model,
712-
partitioning_fn=partitioning_fn,
713-
)
714-
)
715-
716525
async def aquery(
717526
self,
718527
query: PQASession | str,

0 commit comments

Comments
 (0)