Skip to content

Add ScholarAI: Cloudflare Python Worker AI research assistant#1

Open
Copilot wants to merge 4 commits intomainfrom
copilot/add-ai-research-assistant
Open

Add ScholarAI: Cloudflare Python Worker AI research assistant#1
Copilot wants to merge 4 commits intomainfrom
copilot/add-ai-research-assistant

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 8, 2026

Implements a full AI-powered academic research assistant as a Cloudflare Python Worker backed by Workers AI (@cf/meta/llama-3.1-8b-instruct). Covers paper discovery, summarization, citation exploration, Q&A, knowledge organization, trend analysis, and literature review generation.

Structure

  • src/entry.py — Plain Python using only workers.Response + WorkerEntrypoint. Manual URL routing via urllib.parse. Business logic is split into pure async handler functions (handle_discover, handle_summarize, etc.) that return (dict, int) tuples. No third-party frameworks.
  • wrangler.toml — Workers config in TOML format with python_workers compatibility flag and [ai] binding.
  • pyproject.toml / package.json — Python deps (webtypy) and Wrangler CLI scripts (npm run dev / npm run deploy).
  • conftest.py — Minimal workers SDK stub (stubs both Response and WorkerEntrypoint) enabling pytest to import src/entry.py outside the Cloudflare runtime.
  • tests/test_entry.py — 27 async pytest tests calling handler functions directly with a mocked env.AI binding (no HTTP stack or TestClient required).

Endpoints

Endpoint Purpose
GET / API info + usage guide
POST /api/discover Find papers by query/field
POST /api/summarize Structured summary from title/abstract/content
POST /api/citations Forward / backward / related citation network
POST /api/qa Research Q&A with optional context + papers
POST /api/organize Cluster reading list by topic/year/author/methodology
POST /api/trends Emerging and declining trend analysis
POST /api/review Full literature review section generation

Request/response shape (example)

// POST /api/discover
{"query": "transformer models in NLP", "fields": ["ML"], "limit": 10}

// Response
{
  "query": "transformer models in NLP",
  "results": {
    "papers": [...],
    "research_directions": [...],
    "key_concepts": [...],
    "related_queries": [...]
  }
}

Architecture

HTTP Request
  → Default.fetch()              # Cloudflare Workers runtime (WorkerEntrypoint)
  → manual URL routing           # urllib.parse path dispatch
  → handle_*() functions         # pure async business logic
  → env.AI.run(model, params)    # Workers AI inference
  → Response(json, status)       # workers.Response
Original prompt

AI-powered research assistant designed to help students and scientists navigate large volumes of academic literature. Supports paper discovery, summarization, citation exploration, and question answering across research papers. Helps organize knowledge, identify trends, and accelerate literature review workflows. make it use cloudflare ai using cloudflare python workers


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI self-assigned this Mar 8, 2026
Copilot AI and others added 2 commits March 8, 2026 23:21
Co-authored-by: A1L13N <193832434+A1L13N@users.noreply.github.com>
Co-authored-by: A1L13N <193832434+A1L13N@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AI-powered research assistant using Cloudflare AI Add ScholarAI: Cloudflare Python Worker AI research assistant Mar 8, 2026
@A1L13N A1L13N marked this pull request as ready for review March 14, 2026 16:48
@A1L13N
Copy link
Copy Markdown
Contributor

A1L13N commented Mar 14, 2026

@copilot user wrangler.toml and dont use fastapi or any plugins

Co-authored-by: A1L13N <193832434+A1L13N@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 14, 2026

@copilot user wrangler.toml and dont use fastapi or any plugins

Done in commit 1c25b3b:

  • wrangler.jsoncwrangler.toml — TOML format with [ai] binding and python_workers compatibility flag.
  • FastAPI and all plugins removedsrc/entry.py now uses only workers.Response + WorkerEntrypoint. Routing is a plain if/elif on the URL path, request bodies are parsed with await request.json(), and responses are built with workers.Response(json.dumps(...)).
  • Tests updated — no more TestClient; async pytest tests call the handler functions directly with a mocked env.AI.

Copilot AI requested a review from A1L13N March 14, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants