Spaces:
Running
Running
File size: 8,422 Bytes
9286db5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# OpenAlex Integration: The Missing Piece?
**Status**: NOT Implemented (Candidate for Addition)
**Priority**: HIGH - Could Replace Multiple Tools
**Reference**: Already implemented in `reference_repos/DeepCritical`
---
## What is OpenAlex?
OpenAlex is a **fully open** index of the global research system:
- **209M+ works** (papers, books, datasets)
- **2B+ author records** (disambiguated)
- **124K+ venues** (journals, repositories)
- **109K+ institutions**
- **65K+ concepts** (hierarchical, linked to Wikidata)
**Free. Open. No API key required.**
---
## Why OpenAlex for DeepCritical?
### Current Architecture
```
User Query
β
ββββββββββββββββββββββββββββββββββββββββ
β PubMed ClinicalTrials Europe PMC β β 3 separate APIs
ββββββββββββββββββββββββββββββββββββββββ
β
Orchestrator (deduplicate, judge, synthesize)
```
### With OpenAlex
```
User Query
β
ββββββββββββββββββββββββββββββββββββββββ
β OpenAlex β β Single API
β (includes PubMed + preprints + β
β citations + concepts + authors) β
ββββββββββββββββββββββββββββββββββββββββ
β
Orchestrator (enrich with CT.gov for trials)
```
**OpenAlex already aggregates**:
- PubMed/MEDLINE
- Crossref
- ORCID
- Unpaywall (open access links)
- Microsoft Academic Graph (legacy)
- Preprint servers
---
## Reference Implementation
From `reference_repos/DeepCritical/DeepResearch/src/tools/openalex_tools.py`:
```python
class OpenAlexFetchTool(ToolRunner):
def __init__(self):
super().__init__(
ToolSpec(
name="openalex_fetch",
description="Fetch OpenAlex work or author",
inputs={"entity": "TEXT", "identifier": "TEXT"},
outputs={"result": "JSON"},
)
)
def run(self, params: dict[str, Any]) -> ExecutionResult:
entity = params["entity"] # "works", "authors", "venues"
identifier = params["identifier"]
base = "https://api.openalex.org"
url = f"{base}/{entity}/{identifier}"
resp = requests.get(url, timeout=30)
return ExecutionResult(success=True, data={"result": resp.json()})
```
---
## OpenAlex API Features
### Search Works (Papers)
```python
# Search for metformin + cancer papers
url = "https://api.openalex.org/works"
params = {
"search": "metformin cancer drug repurposing",
"filter": "publication_year:>2020,type:article",
"sort": "cited_by_count:desc",
"per_page": 50,
}
```
### Rich Filtering
```python
# Filter examples
"publication_year:2023"
"type:article" # vs preprint, book, etc.
"is_oa:true" # Open access only
"concepts.id:C71924100" # Papers about "Medicine"
"authorships.institutions.id:I27837315" # From Harvard
"cited_by_count:>100" # Highly cited
"has_fulltext:true" # Full text available
```
### What You Get Back
```json
{
"id": "W2741809807",
"title": "Metformin: A candidate drug for...",
"publication_year": 2023,
"type": "article",
"cited_by_count": 45,
"is_oa": true,
"primary_location": {
"source": {"display_name": "Nature Medicine"},
"pdf_url": "https://...",
"landing_page_url": "https://..."
},
"concepts": [
{"id": "C71924100", "display_name": "Medicine", "score": 0.95},
{"id": "C54355233", "display_name": "Pharmacology", "score": 0.88}
],
"authorships": [
{
"author": {"id": "A123", "display_name": "John Smith"},
"institutions": [{"display_name": "Harvard Medical School"}]
}
],
"referenced_works": ["W123", "W456"], # Citations
"related_works": ["W789", "W012"] # Similar papers
}
```
---
## Key Advantages Over Current Tools
### 1. Citation Network (We Don't Have This!)
```python
# Get papers that cite a work
url = f"https://api.openalex.org/works?filter=cites:{work_id}"
# Get papers cited by a work
# Already in `referenced_works` field
```
### 2. Concept Tagging (We Don't Have This!)
OpenAlex auto-tags papers with hierarchical concepts:
- "Medicine" β "Pharmacology" β "Drug Repurposing"
- Can search by concept, not just keywords
### 3. Author Disambiguation (We Don't Have This!)
```python
# Find all works by an author
url = f"https://api.openalex.org/works?filter=authorships.author.id:{author_id}"
```
### 4. Institution Tracking
```python
# Find drug repurposing papers from top institutions
url = "https://api.openalex.org/works"
params = {
"search": "drug repurposing",
"filter": "authorships.institutions.id:I27837315", # Harvard
}
```
### 5. Related Works
Each paper comes with `related_works` - semantically similar papers discovered by OpenAlex's ML.
---
## Proposed Implementation
### New Tool: `src/tools/openalex.py`
```python
"""OpenAlex search tool for comprehensive scholarly data."""
import httpx
from src.tools.base import SearchTool
from src.utils.models import Evidence
class OpenAlexTool(SearchTool):
"""Search OpenAlex for scholarly works with rich metadata."""
name = "openalex"
async def search(self, query: str, max_results: int = 10) -> list[Evidence]:
async with httpx.AsyncClient() as client:
resp = await client.get(
"https://api.openalex.org/works",
params={
"search": query,
"filter": "type:article,is_oa:true",
"sort": "cited_by_count:desc",
"per_page": max_results,
"mailto": "[email protected]", # Polite pool
},
)
data = resp.json()
return [
Evidence(
source="openalex",
title=work["title"],
abstract=work.get("abstract", ""),
url=work["primary_location"]["landing_page_url"],
metadata={
"cited_by_count": work["cited_by_count"],
"concepts": [c["display_name"] for c in work["concepts"][:5]],
"is_open_access": work["is_oa"],
"pdf_url": work["primary_location"].get("pdf_url"),
},
)
for work in data["results"]
]
```
---
## Rate Limits
OpenAlex is **extremely generous**:
- No hard rate limit documented
- Recommended: <100,000 requests/day
- **Polite pool**: Add `[email protected]` param for faster responses
- No API key required (optional for priority support)
---
## Should We Add OpenAlex?
### Arguments FOR
1. **Already in reference repo** - proven pattern
2. **Richer data** - citations, concepts, authors
3. **Single source** - reduces API complexity
4. **Free & open** - no keys, no limits
5. **Institution adoption** - Leiden, Sorbonne switched to it
### Arguments AGAINST
1. **Adds complexity** - another data source
2. **Overlap** - duplicates some PubMed data
3. **Not biomedical-focused** - covers all disciplines
4. **No full text** - still need PMC/Europe PMC for that
### Recommendation
**Add OpenAlex as a 4th source**, don't replace existing tools.
Use it for:
- Citation network analysis
- Concept-based discovery
- High-impact paper finding
- Author/institution tracking
Keep PubMed, ClinicalTrials, Europe PMC for:
- Authoritative biomedical search
- Clinical trial data
- Full-text access
- Preprint tracking
---
## Implementation Priority
| Task | Effort | Value |
|------|--------|-------|
| Basic search | Low | High |
| Citation network | Medium | Very High |
| Concept filtering | Low | High |
| Related works | Low | High |
| Author tracking | Medium | Medium |
---
## Sources
- [OpenAlex Documentation](https://docs.openalex.org)
- [OpenAlex API Overview](https://docs.openalex.org/api)
- [OpenAlex Wikipedia](https://en.wikipedia.org/wiki/OpenAlex)
- [Leiden University Announcement](https://www.leidenranking.com/information/openalex)
- [OpenAlex: A fully-open index (Paper)](https://arxiv.org/abs/2205.01833)
|