From a06241d48cd8eb42e2d154f7f4ef2ac25b8ab2b4 Mon Sep 17 00:00:00 2001 From: Dohoon Date: Thu, 10 Oct 2024 16:46:39 +0900 Subject: [PATCH 1/3] "allow usage of api_key for PubMed API" --- libs/community/langchain_community/utilities/pubmed.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/community/langchain_community/utilities/pubmed.py b/libs/community/langchain_community/utilities/pubmed.py index e3b23cfa0adfb..20185d0c2858e 100644 --- a/libs/community/langchain_community/utilities/pubmed.py +++ b/libs/community/langchain_community/utilities/pubmed.py @@ -31,6 +31,7 @@ class PubMedAPIWrapper(BaseModel): sleep_time: time to wait between retries. Default is 0.2 seconds. email: email address to be used for the PubMed API. + api_key: API key to be used for the PubMed API. """ parse: Any #: :meta private: @@ -47,6 +48,7 @@ class PubMedAPIWrapper(BaseModel): MAX_QUERY_LENGTH: int = 300 doc_content_chars_max: int = 2000 email: str = "your_email@example.com" + api_key: str = "" @model_validator(mode="before") @classmethod @@ -101,6 +103,8 @@ def lazy_load(self, query: str) -> Iterator[dict]: + str({urllib.parse.quote(query)}) + f"&retmode=json&retmax={self.top_k_results}&usehistory=y" ) + if self.api_key != "": + url += f"&api_key={self.api_key}" result = urllib.request.urlopen(url) text = result.read().decode("utf-8") json_text = json.loads(text) @@ -135,6 +139,8 @@ def retrieve_article(self, uid: str, webenv: str) -> dict: + "&webenv=" + webenv ) + if self.api_key != "": + url += f"&api_key={self.api_key}" retry = 0 while True: From 1ce752051c0a325a8b653d09bb6eae4d97e185a5 Mon Sep 17 00:00:00 2001 From: Dohoon Date: Thu, 10 Oct 2024 16:59:15 +0900 Subject: [PATCH 2/3] make test --- libs/community/file::memory:?cache=shared | Bin 0 -> 32768 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 libs/community/file::memory:?cache=shared diff --git a/libs/community/file::memory:?cache=shared b/libs/community/file::memory:?cache=shared new file mode 100644 index 0000000000000000000000000000000000000000..80ab5172a5fab62eabd4d8d77ab654d17508228b GIT binary patch literal 32768 zcmeI%v2NNx7{GBm0i2)^(#cDP8?i(ySyiVF4W(9sN=)n0rc4$Mj%vvS0*-{($n*3K zy7meBCfz#rObRw~NW5D5Te5t2{?7N^?<`9vfBM+=Lr+|dCc}OxUMfe5swyW!D2j3{ z&pmmrj-o6SRuy?w6Xk8iW97yCrc(W@Xa{G?;h*Zy%J0J;m6L;CvdVz~0tg_000Iag zfB*tH6_{(9{>D@n&;09wH}hxi)ol>C!@(;z2!`%u|MI&RmC~(yO~-0ySzpE0 zj-q3WbZ1eM&ot(xr^ogOvvhYY!`QOpwz1_cV^J+?`njC=^G7B=o{Wa$Fw#ipP|A=) z+<#jtafGqB*wu8?RPTCW|6AatM@+XA{^!tbylq<#GMD%Lf%wvJnr971*qyGhKeyX; zQQnUSUfqsb<*FpBkzvd3TBnv1_elm!yy)J&dK1WvtJ}W~N6Y#{FPxd4YH@L@YPw;lcdeLb{faK**R`EA%le+Et>(VUd4nYZ zu+g57*l2$e;NH0|z$I`F&^bur|aHRtn0h-Gqc>=SEBFDQBFTPq>TUq z2q1s}0tg_000IagfB*uS1j Date: Tue, 15 Oct 2024 21:45:23 -0400 Subject: [PATCH 3/3] x --- libs/community/file::memory:?cache=shared | Bin 32768 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 libs/community/file::memory:?cache=shared diff --git a/libs/community/file::memory:?cache=shared b/libs/community/file::memory:?cache=shared deleted file mode 100644 index 80ab5172a5fab62eabd4d8d77ab654d17508228b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI%v2NNx7{GBm0i2)^(#cDP8?i(ySyiVF4W(9sN=)n0rc4$Mj%vvS0*-{($n*3K zy7meBCfz#rObRw~NW5D5Te5t2{?7N^?<`9vfBM+=Lr+|dCc}OxUMfe5swyW!D2j3{ z&pmmrj-o6SRuy?w6Xk8iW97yCrc(W@Xa{G?;h*Zy%J0J;m6L;CvdVz~0tg_000Iag zfB*tH6_{(9{>D@n&;09wH}hxi)ol>C!@(;z2!`%u|MI&RmC~(yO~-0ySzpE0 zj-q3WbZ1eM&ot(xr^ogOvvhYY!`QOpwz1_cV^J+?`njC=^G7B=o{Wa$Fw#ipP|A=) z+<#jtafGqB*wu8?RPTCW|6AatM@+XA{^!tbylq<#GMD%Lf%wvJnr971*qyGhKeyX; zQQnUSUfqsb<*FpBkzvd3TBnv1_elm!yy)J&dK1WvtJ}W~N6Y#{FPxd4YH@L@YPw;lcdeLb{faK**R`EA%le+Et>(VUd4nYZ zu+g57*l2$e;NH0|z$I`F&^bur|aHRtn0h-Gqc>=SEBFDQBFTPq>TUq z2q1s}0tg_000IagfB*uS1j