caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
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).
2026-07-10 16:23:13 +03:00

83 lines
3.3 KiB
Python

from bs4 import BeautifulSoup
import os
from ..utils import get_relevant_images
class FireCrawl:
def __init__(self, link, session=None):
self.link = link
self.session = session
from firecrawl import FirecrawlApp
self.firecrawl = FirecrawlApp(api_key=self.get_api_key(), api_url=self.get_server_url())
def get_api_key(self) -> str:
"""
Gets the FireCrawl API key
Returns:
Api key (str)
"""
try:
api_key = os.environ["FIRECRAWL_API_KEY"]
except KeyError:
raise Exception(
"FireCrawl API key not found. Please set the FIRECRAWL_API_KEY environment variable.")
return api_key
def get_server_url(self) -> str:
"""
Gets the FireCrawl server URL.
Default to official FireCrawl server ('https://api.firecrawl.dev').
Returns:
server url (str)
"""
try:
server_url = os.environ["FIRECRAWL_SERVER_URL"]
except KeyError:
server_url = 'https://api.firecrawl.dev'
return server_url
def scrape(self) -> tuple:
"""
This function extracts content and title from a specified link using the FireCrawl Python SDK,
images from the link are extracted using the functions from `gpt_researcher/scraper/utils.py`.
Returns:
The `scrape` method returns a tuple containing the extracted content, a list of image URLs, and
the title of the webpage specified by the `self.link` attribute. It uses the FireCrawl Python SDK to
extract and clean content from the webpage. If any exception occurs during the process, an error
message is printed and an empty result is returned.
"""
try:
# Fixed: Changed from scrape_url() to scrape() to match FireCrawl SDK v4.6.0+
response = self.firecrawl.scrape(url=self.link, formats=["markdown"])
# Check if the page has been scraped successfully
# Fixed: Access metadata attributes directly (not as dict keys)
if response.metadata and response.metadata.error:
print("Scrape failed! : " + str(response.metadata.error))
return "", [], ""
elif response.metadata and response.metadata.status_code and response.metadata.status_code != 200:
print(f"Scrape failed! Status code: {response.metadata.status_code}")
return "", [], ""
# Extract the content (markdown) and title from FireCrawl response
# Fixed: Access attributes directly (not as dict keys)
content = response.markdown if response.markdown else ""
title = response.metadata.title if response.metadata and response.metadata.title else ""
# Parse the HTML content of the response to create a BeautifulSoup object for the utility functions
response_bs = self.session.get(self.link, timeout=4)
soup = BeautifulSoup(
response_bs.content, "lxml", from_encoding=response_bs.encoding
)
# Get relevant images using the utility function
image_urls = get_relevant_images(soup, self.link)
return content, image_urls, title
except Exception as e:
print("Error! : " + str(e))
return "", [], ""