Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Python client for interacting with the PaperQA server
Python 3.11+ is required for this package
pip install pqapi
Make sure to set the environment variable PQA_API_KEY
to your API token:
export PQA_API_KEY=pqa-...
API keys generally have a rate limit associated with them that is based on queries per day. These are based on a rolling window, rather than resetting at a specific time. You will receive 429s if you have exceeded your rate limit on submission.
The simplest way to use the API is with synchronous queries:
import pqapi
response = pqapi.agent_query("Are COVID-19 vaccines effective?")
print(response.answer)
You can also make asynchronous queries:
import pqapi
response = await pqapi.async_agent_query(query)
These still require an open connection though, so do not accumulate too many of them. Each query takes between 1 and 5 minutes generally.
For running multiple long-running queries efficiently, use the job submission API:
import asyncio
import pqapi
# Define multiple queries
queries = [
'What is the elastic modulus of gold?',
'What is the elastic modulus of silver?',
'What is the elastic modulus of copper?'
]
# Submit jobs
jobs = [pqapi.submit_agent_job(query=q) for q in queries]
# Poll for results
results = asyncio.run(pqapi.gather_pqa_results_via_polling(
[job['metadata']['query_id'] for job in jobs]
))
The results will include:
question
: Your original query textrequest
: Serialized settings used in your queryresponse
: Serialized pqapi.AnswerResponse
objectYou can use predefined templates that you develop and save on paperqa.app:
# Single query with template
response = pqapi.agent_query(
'The melting point of gold is 1000F.',
named_template='check for contradiction'
)
# Batch jobs with templates
contradictions = [
{
'query': 'Gold can be transmuted into platinum.',
'named_template': 'check for contradiction'
},
]
contradiction_jobs = [pqapi.submit_agent_job(**c) for c in contradictions]
results = asyncio.run(pqapi.gather_pqa_results_via_polling(
[job['metadata']['query_id'] for job in contradiction_jobs]
))
The response object contains detailed information about your query:
Access the main specific answer text with:
print(response.answer)
FAQs
API for interacting with paperqa.app
We found that pqapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.