Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
95 lines
3.0 KiB
Python
95 lines
3.0 KiB
Python
# Xquik X/Twitter Retriever
|
|
#
|
|
# Searches X (Twitter) for real-time perspectives, dev discussions,
|
|
# product feedback, breaking news, and expert opinions.
|
|
# $0.00015 per tweet — 33x cheaper than the official X API.
|
|
|
|
import json
|
|
import os
|
|
import urllib.parse
|
|
import urllib.request
|
|
|
|
|
|
class XquikSearch:
|
|
"""
|
|
Xquik X/Twitter search retriever.
|
|
|
|
Searches tweets via the Xquik REST API and returns results in the
|
|
standard {title, href, body} format used by all GPT Researcher retrievers.
|
|
|
|
Set XQUIK_API_KEY in your environment. Get one at https://xquik.com
|
|
"""
|
|
|
|
def __init__(self, query, query_domains=None, **kwargs):
|
|
self.query = query
|
|
self.query_domains = query_domains
|
|
self.api_key = self.get_api_key()
|
|
|
|
def get_api_key(self):
|
|
try:
|
|
api_key = os.environ["XQUIK_API_KEY"]
|
|
except KeyError:
|
|
raise Exception(
|
|
"Xquik API key not found. Please set the XQUIK_API_KEY "
|
|
"environment variable. Get a key at https://xquik.com"
|
|
)
|
|
return api_key
|
|
|
|
def search(self, max_results=10):
|
|
"""
|
|
Search X/Twitter via Xquik API.
|
|
|
|
Returns:
|
|
list: Search results as [{title, href, body}, ...]
|
|
"""
|
|
print(f"Searching X/Twitter with query: {self.query}...")
|
|
|
|
try:
|
|
results = self._search_tweets(max_results)
|
|
return results
|
|
except Exception as e:
|
|
print(f"Error: {e}. Failed fetching X/Twitter sources. Resulting in empty response.")
|
|
return []
|
|
|
|
def _search_tweets(self, max_results):
|
|
params = urllib.parse.urlencode({
|
|
"q": self.query,
|
|
"limit": min(max_results, 200),
|
|
"queryType": "Top",
|
|
})
|
|
url = f"https://xquik.com/api/v1/x/tweets/search?{params}"
|
|
|
|
req = urllib.request.Request(url, headers={
|
|
"X-API-Key": self.api_key,
|
|
"Accept": "application/json",
|
|
"User-Agent": "gpt-researcher/1.0",
|
|
})
|
|
|
|
with urllib.request.urlopen(req, timeout=15) as resp:
|
|
data = json.loads(resp.read().decode("utf-8"))
|
|
|
|
tweets = data.get("tweets", [])
|
|
search_results = []
|
|
|
|
for tweet in tweets[:max_results]:
|
|
author = tweet.get("author", {})
|
|
username = author.get("username", "unknown")
|
|
text = tweet.get("text", "")
|
|
tweet_id = tweet.get("id", "")
|
|
|
|
likes = tweet.get("likeCount", 0)
|
|
retweets = tweet.get("retweetCount", 0)
|
|
views = tweet.get("viewCount", 0)
|
|
|
|
engagement = f"{likes} likes, {retweets} RTs"
|
|
if views:
|
|
engagement += f", {views} views"
|
|
|
|
search_results.append({
|
|
"title": f"@{username}: {text[:120]}{'...' if len(text) > 120 else ''}",
|
|
"href": f"https://x.com/{username}/status/{tweet_id}",
|
|
"body": f"{text}\n\n[{engagement}]",
|
|
})
|
|
|
|
return search_results
|