66import re
77import tempfile
88import urllib .request
9- import warnings
109from collections .abc import Callable , Sequence
1110from datetime import datetime
1211from io import BytesIO
3231from paperqa .types import Doc , DocDetails , DocKey , PQASession , Text
3332from 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