paper-qa
paper-qa copied to clipboard
How to skip the semantic and corssfy api Request
hi there . i have question for you . due my country restriction i can't get semantic or crossfy api . is there way that in that i cant deactivated that and make request timeout longer?
@MrAlishr 🌟 Hello and welcome! I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. Let's tackle this together!
To skip the Semantic Scholar and Crossref API requests and extend the request timeout due to country restrictions, you can modify the DocMetadataClient initialization to exclude the SemanticScholarProvider and CrossrefProvider and adjust the timeout settings. Here is an example of how you can achieve this:
from paperqa.clients import DocMetadataClient, UnpaywallProvider
import aiohttp
# Define a longer timeout value
EXTENDED_TIMEOUT = 10.0 # 10 seconds
async def fetch_metadata():
async with aiohttp.ClientSession() as session:
# Initialize the client with a different provider and extended timeout
client = DocMetadataClient(
session,
clients=[UnpaywallProvider],
timeout=aiohttp.ClientTimeout(total=EXTENDED_TIMEOUT)
)
details = await client.query(
doi="10.1007/s40278-023-41815-2",
fields=["doi", "title"]
)
return details
# Example usage
import asyncio
details = asyncio.run(fetch_metadata())
print(details)
In this example, replace UnpaywallProvider with the actual provider you want to use that is not restricted in your country. The timeout parameter is set to aiohttp.ClientTimeout(total=EXTENDED_TIMEOUT) to extend the request timeout. The SemanticScholarProvider and CrossrefProvider are excluded to avoid country restrictions [1][2][3].
To continue talking to Dosu, mention @dosu.
Waiting for the solution, I encountered the same issue and couldn't access these two APIs. How should I modify the code to skip them?
set use_doc_details=False
settings = Settings(
verbosity=3,
parsing=ParsingSettings(use_doc_details=False)
)
This is not exposed! this is not in __init.py! you guys have built a pretty lousy system...not really usable at all.
Hey all,
Thanks for the support here @xiaobeicn . PaperQA is highly customizable. We gather all available settings in the Settings class.
Also, This tutorial shows one example on how to use it!
I'll close this issue as it has already been answered. But feel free to reopen it if you have any further questions!