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).
97 lines
3.2 KiB
Python
97 lines
3.2 KiB
Python
"""Source curator skill for GPT Researcher.
|
|
|
|
This module provides the SourceCurator class that evaluates and ranks
|
|
research sources based on relevance, credibility, and reliability.
|
|
"""
|
|
|
|
import json
|
|
from typing import Dict, List, Optional
|
|
|
|
from ..actions import stream_output
|
|
from ..config.config import Config
|
|
from ..utils.llm import create_chat_completion
|
|
|
|
|
|
class SourceCurator:
|
|
"""Ranks and curates sources based on relevance, credibility and reliability.
|
|
|
|
This class uses LLM-based evaluation to assess research sources
|
|
and select the most appropriate ones for report generation.
|
|
|
|
Attributes:
|
|
researcher: The parent GPTResearcher instance.
|
|
"""
|
|
|
|
def __init__(self, researcher):
|
|
"""Initialize the SourceCurator.
|
|
|
|
Args:
|
|
researcher: The GPTResearcher instance that owns this curator.
|
|
"""
|
|
self.researcher = researcher
|
|
|
|
async def curate_sources(
|
|
self,
|
|
source_data: List,
|
|
max_results: int = 10,
|
|
) -> List:
|
|
"""
|
|
Rank sources based on research data and guidelines.
|
|
|
|
Args:
|
|
query: The research query/task
|
|
source_data: List of source documents to rank
|
|
max_results: Maximum number of top sources to return
|
|
|
|
Returns:
|
|
str: Ranked list of source URLs with reasoning
|
|
"""
|
|
print(f"\n\nCurating {len(source_data)} sources: {source_data}")
|
|
if self.researcher.verbose:
|
|
await stream_output(
|
|
"logs",
|
|
"research_plan",
|
|
f"⚖️ Evaluating and curating sources by credibility and relevance...",
|
|
self.researcher.websocket,
|
|
)
|
|
|
|
response = ""
|
|
try:
|
|
response = await create_chat_completion(
|
|
model=self.researcher.cfg.smart_llm_model,
|
|
messages=[
|
|
{"role": "system", "content": f"{self.researcher.role}"},
|
|
{"role": "user", "content": self.researcher.prompt_family.curate_sources(
|
|
self.researcher.query, source_data, max_results)},
|
|
],
|
|
temperature=0.2,
|
|
max_tokens=8000,
|
|
llm_provider=self.researcher.cfg.smart_llm_provider,
|
|
llm_kwargs=self.researcher.cfg.llm_kwargs,
|
|
cost_callback=self.researcher.add_costs,
|
|
)
|
|
|
|
curated_sources = json.loads(response)
|
|
print(f"\n\nFinal Curated sources {len(source_data)} sources: {curated_sources}")
|
|
|
|
if self.researcher.verbose:
|
|
await stream_output(
|
|
"logs",
|
|
"research_plan",
|
|
f"🏅 Verified and ranked top {len(curated_sources)} most reliable sources",
|
|
self.researcher.websocket,
|
|
)
|
|
|
|
return curated_sources
|
|
|
|
except Exception as e:
|
|
print(f"Error in curate_sources from LLM response: {response}")
|
|
if self.researcher.verbose:
|
|
await stream_output(
|
|
"logs",
|
|
"research_plan",
|
|
f"🚫 Source verification failed: {str(e)}",
|
|
self.researcher.websocket,
|
|
)
|
|
return source_data
|