6
6
import re
7
7
import tempfile
8
8
import urllib .request
9
- import warnings
10
9
from collections .abc import Callable , Sequence
11
10
from datetime import datetime
12
11
from io import BytesIO
32
31
from paperqa .types import Doc , DocDetails , DocKey , PQASession , Text
33
32
from paperqa .utils import (
34
33
citation_to_docname ,
35
- get_loop ,
36
34
maybe_is_html ,
37
35
maybe_is_pdf ,
38
36
maybe_is_text ,
@@ -90,35 +88,6 @@ def _get_unique_name(self, docname: str) -> str:
90
88
docname += suffix
91
89
return docname
92
90
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
-
122
91
async def aadd_file (
123
92
self ,
124
93
file : BinaryIO ,
@@ -158,35 +127,6 @@ async def aadd_file(
158
127
** kwargs ,
159
128
)
160
129
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
-
190
130
async def aadd_url (
191
131
self ,
192
132
url : str ,
@@ -211,43 +151,6 @@ async def aadd_url(
211
151
embedding_model = embedding_model ,
212
152
)
213
153
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
-
251
154
async def aadd ( # noqa: PLR0912
252
155
self ,
253
156
path : str | os .PathLike ,
@@ -411,26 +314,6 @@ async def aadd( # noqa: PLR0912
411
314
return doc .docname
412
315
return None
413
316
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
-
434
317
async def aadd_texts (
435
318
self ,
436
319
texts : list [Text ],
@@ -552,39 +435,9 @@ async def retrieve_texts(
552
435
matches = [m for m in matches if m .doc .dockey not in self .deleted_dockeys ]
553
436
return matches [:k ]
554
437
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
-
584
438
async def aget_evidence (
585
439
self ,
586
440
query : PQASession | str ,
587
- exclude_text_filter : set [str ] | None = None ,
588
441
settings : MaybeSettings = None ,
589
442
callbacks : Sequence [Callable ] | None = None ,
590
443
embedding_model : EmbeddingModel | None = None ,
@@ -611,21 +464,6 @@ async def aget_evidence(
611
464
if summary_llm_model is None :
612
465
summary_llm_model = evidence_settings .get_summary_llm ()
613
466
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
-
629
467
if answer_config .evidence_retrieval :
630
468
matches = await self .retrieve_texts (
631
469
session .question ,
@@ -684,35 +522,6 @@ async def aget_evidence(
684
522
session .contexts += [r for r , _ in results ]
685
523
return session
686
524
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
-
716
525
async def aquery (
717
526
self ,
718
527
query : PQASession | str ,
0 commit comments