-
Notifications
You must be signed in to change notification settings - Fork 132
feat: Add research-paper-analyzer kit #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
cb94160
e543d63
305f4ce
064f105
63e14cd
b628928
e27509c
92fc63c
4c5e7ea
a594e90
917a247
bdf3c80
45febd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| RESEARCH_PAPER_ANALYZER_FLOW_ID="your-flow-id" | ||
| LAMATIC_API_URL="https://your-project.lamatic.ai" | ||
| LAMATIC_PROJECT_ID="your-project-id" | ||
| LAMATIC_API_KEY="your-api-key" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .env | ||
| .env.local | ||
| apps/node_modules | ||
| apps/.next | ||
| apps/.vercel |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # Research Paper Analyzer | ||
|
|
||
| An AI-powered kit that takes any academic PDF URL and returns a structured breakdown: | ||
|
|
||
| - **Problem Statement** — what the research is trying to solve and why it matters | ||
| - **Methodology** — how the study was conducted | ||
| - **Key Findings** — the main results and conclusions | ||
| - **Limitations** — acknowledged weaknesses or gaps | ||
| - **Plain English Summary** — jargon-free explanation for non-specialists | ||
| - **Follow-up Questions** — ideas for future research directions | ||
|
|
||
| Built on [Lamatic.ai](https://lamatic.ai) with a **FastAPI** backend and a **React + Vite** frontend (JavaScript/JSX). | ||
|
|
||
| --- | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| React (Vite/JSX) → FastAPI (Python) → Lamatic Flow → LLM | ||
| frontend backend orchestration | ||
| localhost:5173 localhost:8000 | ||
| ``` | ||
|
|
||
|
Comment on lines
+18
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mission brief: neutralize markdownlint blockers before merge. At Line 18 and Line 52, fenced blocks are missing language tags (MD040). Around Line 52, Line 91, and Line 96, add blank lines around fenced blocks (MD031) to satisfy the validator. Proposed patch ## Architecture
-```
+```text
React (Vite/JSX) → FastAPI (Python) → Lamatic Flow → LLM
frontend backend orchestration
localhost:5173 localhost:8000@@ Response: {
"success": true,Also applies to: 52-57, 91-93, 96-111 🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 18-18: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||
| --- | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Deploy the Flow in Lamatic Studio | ||
|
|
||
| 1. Go to [studio.lamatic.ai](https://studio.lamatic.ai) → New Project → New Flow | ||
| 2. Add nodes in this order: | ||
| - **API Trigger** — input schema: `{ pdf_url: string }` | ||
| - **Extract From File** — file URL: `{{trigger.pdf_url}}` | ||
| - **LLM Node** — use prompt from `prompts/analyze-paper.md`, structured JSON output | ||
| - **API Response** — output: `{{LLMNode.output}}` | ||
|
Comment on lines
+33
to
+35
|
||
| 3. Deploy the flow and copy the **Flow ID** from Settings | ||
|
|
||
| ### 2. Start the FastAPI Backend | ||
|
|
||
| ```bash | ||
| cd apps/backend | ||
| cp .env.example .env | ||
| # Fill in your Flow ID and Lamatic credentials in .env | ||
| pip install -r requirements.txt | ||
| uvicorn main:app --reload | ||
| ``` | ||
|
|
||
| Backend runs at [http://localhost:8000](http://localhost:8000). | ||
| Check [http://localhost:8000/docs](http://localhost:8000/docs) for the auto-generated API docs. | ||
|
|
||
| `.env` values to fill in: | ||
| ``` | ||
| RESEARCH_PAPER_ANALYZER_FLOW_ID=<your-flow-id> | ||
| LAMATIC_API_URL=<from Lamatic Settings> | ||
| LAMATIC_PROJECT_ID=<from Lamatic Settings> | ||
| LAMATIC_API_KEY=<from Lamatic Settings> | ||
| ``` | ||
|
|
||
| ### 3. Start the React Frontend | ||
|
|
||
| ```bash | ||
| cd apps/frontend | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
|
|
||
| Frontend runs at [http://localhost:5173](http://localhost:5173). | ||
| Vite proxies `/analyze` → FastAPI automatically, so no CORS issues in dev. | ||
|
|
||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Paste any publicly accessible PDF URL (e.g., an arXiv paper) | ||
| 2. Click **Analyze Paper** | ||
| 3. Browse the structured breakdown — expand/collapse each section | ||
| 4. Click **JSON** to copy the raw JSON output | ||
|
|
||
| ### Example URLs to try | ||
|
|
||
| - `https://arxiv.org/pdf/2303.08774.pdf` — GPT-4 Technical Report | ||
| - `https://arxiv.org/pdf/1706.03762.pdf` — Attention Is All You Need | ||
|
|
||
| --- | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### `POST /analyze` | ||
|
|
||
| **Request:** | ||
| ```json | ||
| { "pdf_url": "https://arxiv.org/pdf/2303.08774.pdf" } | ||
| ``` | ||
|
|
||
| **Response:** | ||
| ```json | ||
| { | ||
| "success": true, | ||
| "data": { | ||
| "title": "...", | ||
| "authors": ["..."], | ||
| "year": 2023, | ||
| "problem_statement": "...", | ||
| "methodology": "...", | ||
| "key_findings": ["..."], | ||
| "limitations": ["..."], | ||
| "plain_english_summary": "...", | ||
| "follow_up_questions": ["..."] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| - **Backend**: FastAPI, Python, httpx, Pydantic, python-dotenv | ||
| - **Frontend**: React.js, Vite, JavaScript/JSX, Tailwind CSS, Lucide React | ||
| - **AI Orchestration**: Lamatic.ai flows | ||
|
|
||
| --- | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Python 3.10+ | ||
| - Node.js 18+, npm 9+ | ||
| - Lamatic.ai account ([sign up free](https://lamatic.ai)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Research Paper Analyzer Agent | ||
|
|
||
| ## Identity | ||
|
|
||
| You are an expert academic research analyst. Your role is to read scientific papers and produce clear, structured analyses that help researchers, students, and professionals quickly understand complex academic work. | ||
|
|
||
| ## Capabilities | ||
|
|
||
| - Extract and articulate the core research problem and motivation | ||
| - Identify and explain the methodology used | ||
| - Summarize key findings and results objectively | ||
| - Surface limitations and potential gaps in the research | ||
| - Translate academic language into plain English for non-specialists | ||
| - Generate thoughtful follow-up research questions | ||
|
|
||
| ## Behavior Guidelines | ||
|
|
||
| - Always base your analysis strictly on the paper content — do not hallucinate facts | ||
| - Be objective; do not editorialize beyond what the paper states | ||
| - If a section of the paper is unclear or missing, state that explicitly | ||
| - Keep the plain-English summary accessible to a smart non-expert | ||
| - Format all output as structured JSON matching the defined schema | ||
|
|
||
| ## Output Schema | ||
|
|
||
|
|
||
| ```json | ||
| { | ||
| "title": "string", | ||
| "authors": ["string"], | ||
| "year": "number | null", | ||
| "problem_statement": "string", | ||
| "methodology": "string", | ||
| "key_findings": ["string"], | ||
| "limitations": ["string"], | ||
| "plain_english_summary": "string", | ||
| "follow_up_questions": ["string"] | ||
| } | ||
| ``` | ||
|
|
||
| ## Constraints | ||
|
|
||
| - Never invent citations, statistics, or claims not present in the paper | ||
| - Refuse requests to misrepresent or plagiarize research | ||
| - If the uploaded file is not an academic paper, respond with a clear error message | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||||||||||||||
| RESEARCH_PAPER_ANALYZER_FLOW_ID="your-flow-id" | ||||||||||||||||||
| LAMATIC_API_URL="https://your-project.lamatic.ai" | ||||||||||||||||||
| LAMATIC_PROJECT_ID="your-project-id" | ||||||||||||||||||
| LAMATIC_API_KEY="your-api-key" | ||||||||||||||||||
|
Comment on lines
+1
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surveillance confirms: Identical quote character issue in apps/.env.example. This template mirrors the same vulnerability as the root 🔧 Suggested correction-RESEARCH_PAPER_ANALYZER_FLOW_ID="your-flow-id"
-LAMATIC_API_URL="https://your-project.lamatic.ai"
-LAMATIC_PROJECT_ID="your-project-id"
-LAMATIC_API_KEY="your-api-key"
+RESEARCH_PAPER_ANALYZER_FLOW_ID=your-flow-id
+LAMATIC_API_URL=https://your-project.lamatic.ai
+LAMATIC_PROJECT_ID=your-project-id
+LAMATIC_API_KEY=your-api-key📝 Committable suggestion
Suggested change
🧰 Tools🪛 dotenv-linter (4.0.0)[warning] 1-1: [QuoteCharacter] The value has quote characters (', ") (QuoteCharacter) [warning] 2-2: [QuoteCharacter] The value has quote characters (', ") (QuoteCharacter) [warning] 2-2: [UnorderedKey] The LAMATIC_API_URL key should go before the RESEARCH_PAPER_ANALYZER_FLOW_ID key (UnorderedKey) [warning] 3-3: [QuoteCharacter] The value has quote characters (', ") (QuoteCharacter) [warning] 3-3: [UnorderedKey] The LAMATIC_PROJECT_ID key should go before the RESEARCH_PAPER_ANALYZER_FLOW_ID key (UnorderedKey) [warning] 4-4: [QuoteCharacter] The value has quote characters (', ") (QuoteCharacter) [warning] 4-4: [UnorderedKey] The LAMATIC_API_KEY key should go before the LAMATIC_API_URL key (UnorderedKey) 🤖 Prompt for AI Agents |
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "use server"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import { lamaticClient } from "@/lib/lamatic-client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface PaperAnalysis { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| title: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| authors: string[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| year: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| problem_statement: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| methodology: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| key_findings: string[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| limitations: string[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plain_english_summary: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| follow_up_questions: string[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function analyzePaper( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pdfUrl: string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ): Promise<{ success: boolean; data?: PaperAnalysis; error?: string }> { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const flowId = process.env.RESEARCH_PAPER_ANALYZER_FLOW_ID; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!flowId) throw new Error("RESEARCH_PAPER_ANALYZER_FLOW_ID is not set."); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mission briefing: Critical security gap detected in parameter validation. Agent, your function accepts a Recommended defensive protocol: 🛡️ Suggested validation enhancement export async function analyzePaper(
pdfUrl: string
): Promise<{ success: boolean; data?: PaperAnalysis; error?: string }> {
try {
+ // Validate input
+ if (!pdfUrl || !pdfUrl.trim()) {
+ throw new Error("PDF URL is required.");
+ }
+
+ // Validate URL format
+ try {
+ new URL(pdfUrl);
+ } catch {
+ throw new Error("Invalid PDF URL format.");
+ }
+
const flowId = process.env.RESEARCH_PAPER_ANALYZER_FLOW_ID;
if (!flowId) throw new Error("RESEARCH_PAPER_ANALYZER_FLOW_ID is not set.");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const resData = await lamaticClient.executeFlow(flowId, { pdf_url: pdfUrl }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = resData?.result ?? resData?.output ?? resData; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!result) throw new Error("No result returned from the flow."); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| return { success: true, data: result as PaperAnalysis }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intelligence report: Type assertion without runtime validation detected. Your mission uses an unchecked type cast at line 29 ( Recommended validation protocol: 🔍 Suggested runtime validation const resData = await lamaticClient.executeFlow(flowId, { pdf_url: pdfUrl });
const result = resData?.result ?? resData?.output ?? resData;
- if (!result) throw new Error("No result returned from the flow.");
+ // Validate response structure
+ if (!result || typeof result !== "object") {
+ throw new Error("No valid result returned from the flow.");
+ }
+
+ // Validate required fields
+ const required = ["title", "authors", "year", "problem_statement", "methodology",
+ "key_findings", "limitations", "plain_english_summary", "follow_up_questions"];
+ const missing = required.filter(field => !(field in result));
+ if (missing.length > 0) {
+ throw new Error(`Flow response missing required fields: ${missing.join(", ")}`);
+ }
- return { success: true, data: result as PaperAnalysis };
+ return { success: true, data: result as PaperAnalysis };📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const message = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| error instanceof Error ? error.message : "Unknown error occurred."; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return { success: false, error: message }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import 'tailwindcss'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether other kits in this repo use explicit postcss.config.js with Tailwind v4
fd -t f '^postcss\.config\.(js|mjs)$' kits/ --exec echo "Found: {}"Repository: Lamatic/AgentKit Length of output: 915 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1) Check whether this specific kit has an explicit postcss config
fd -t f '^postcss\.config\.(js|mjs)$' kits/research-paper-analyzer --exec echo "Found in research-paper-analyzer: {}" || true
# 2) Find all occurrences of Tailwind v4 import style and show nearby context (and whether a postcss config exists per kit)
rg -n "`@import` 'tailwindcss';" kits --glob='*.css' --glob='*.pcss' | head -n 50
# 3) Locate package.json files for the research-paper-analyzer app and print dependency versions for next/tailwind/postcss (small extraction)
# (Use jq if present; otherwise grep.)
find kits/research-paper-analyzer -maxdepth 4 -name package.json -print | head -n 20
# Try to extract relevant deps from any found package.json under the app
find kits/research-paper-analyzer -maxdepth 6 -name package.json -print0 | \
python3 - <<'PY'
import json,sys,os,glob
paths = [p for p in glob.glob('kits/research-paper-analyzer/**/package.json', recursive=True)]
for p in paths:
try:
with open(p,'r',encoding='utf-8') as f:
data=json.load(f)
deps={}
for k in ['dependencies','devDependencies','peerDependencies']:
deps.update(data.get(k,{}))
keys=['next','tailwindcss','postcss']
got={k:deps.get(k) for k in keys if k in deps}
if got:
print(p)
for k,v in got.items():
print(f" {k}: {v}")
except Exception as e:
pass
PY
# 4) Inspect one representative PostCSS config from another kit to see wiring pattern
# Pick hiring-copilot-agent since it was mentioned in the original comment's example area.
if [ -f kits/hiring-copilot-agent/apps/postcss.config.mjs ]; then
echo "---- hiring-copilot-agent/apps/postcss.config.mjs ----"
sed -n '1,120p' kits/hiring-copilot-agent/apps/postcss.config.mjs
fiRepository: Lamatic/AgentKit Length of output: 1193 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1) Does research-paper-analyzer define an explicit PostCSS config?
echo "== postcss.config.* under kits/research-paper-analyzer =="
fd -t f '^postcss\.config\.(js|mjs)$' kits/research-paper-analyzer --exec echo "Found: {}" || true
# 2) Show the tailwind/postcss/next parts of its package.json
echo
echo "== kits/research-paper-analyzer/apps/package.json (relevant deps) =="
cat kits/research-paper-analyzer/apps/package.json | rg -n '"(next|tailwindcss|postcss)"\s*:' -n
# 3) Show one PostCSS config from another kit that uses Tailwind v4 import
echo
echo "== Example postcss.config from a sibling kit =="
if [ -f kits/hiring-copilot-agent/apps/postcss.config.mjs ]; then
sed -n '1,160p' kits/hiring-copilot-agent/apps/postcss.config.mjs
else
# fallback: pick the first postcss.config.* found under kits/
cfg="$(fd -t f '^postcss\.config\.(js|mjs)$' kits --exec echo {} | head -n 1)"
echo "Using: $cfg"
sed -n '1,160p' "$cfg"
fiRepository: Lamatic/AgentKit Length of output: 414 🌐 Web query:
💡 Result: In Next.js 15, while Tailwind CSS v4 features automatic content detection [1][2][3], a Citations:
Wire Tailwind v4 PostCSS adapter for Agent, your mission depends on Tailwind v4 actually running in the Next build pipeline: Addconst config = {
plugins: {
"`@tailwindcss/postcss`": {},
},
};
export default config;🧰 Tools🪛 Stylelint (17.12.0)[error] 1-2: Unknown rule scss/at-rule-no-unknown. Did you mean at-rule-no-unknown? (scss/at-rule-no-unknown) 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { Metadata } from "next"; | ||
| import { Analytics } from "@vercel/analytics/next"; | ||
| import "./globals.css"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "Research Paper Analyzer", | ||
| description: | ||
| "Upload any academic PDF and get a structured breakdown: problem statement, methodology, key findings, limitations, plain-English summary, and follow-up research questions.", | ||
| }; | ||
|
|
||
| export default function RootLayout({ | ||
| children, | ||
| }: Readonly<{ children: React.ReactNode }>) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body className="antialiased"> | ||
| {children} | ||
| <Analytics /> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Analyzer } from "@/components/analyzer"; | ||
|
|
||
| export default function Home() { | ||
| return <Analyzer />; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field report: Unnecessary quote characters detected in .env template.
Agent, your environment variable values are wrapped in quotes. Most
.envparsers read these literally—meaning your actual runtime values will include the quote characters themselves. This can cause authentication failures or unexpected string matching issues.Mission directive: Remove quotes for clean parsing.
🔧 Suggested correction
📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 1-1: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 2-2: [UnorderedKey] The LAMATIC_API_URL key should go before the RESEARCH_PAPER_ANALYZER_FLOW_ID key
(UnorderedKey)
[warning] 3-3: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 3-3: [UnorderedKey] The LAMATIC_PROJECT_ID key should go before the RESEARCH_PAPER_ANALYZER_FLOW_ID key
(UnorderedKey)
[warning] 4-4: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 4-4: [UnorderedKey] The LAMATIC_API_KEY key should go before the LAMATIC_API_URL key
(UnorderedKey)
🤖 Prompt for AI Agents