npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thebolarin/narrative-analysis-ai

v1.0.23

Published

A service for generating narrative analysis using OpenAI

Readme

📖 Narrative Analysis AI - @thebolarin/narrative-analysis-ai

An AI-powered narrative analysis tool that processes research articles to extract key narratives, analyze their dominance, and track their evolution. This package is built on OpenAI’s GPT models and designed for researchers, journalists, and analysts.

🚀 Features

AI-Powered Narrative Analysis – Identifies key narratives in research articles.
Dominance & Evolution Tracking – Understands how narratives shift over time.
Aggregated Insights – Combines data from multiple articles for broad analysis.
Statistical Data for Visualization – Provides key metrics to build visual representations.
Research Question Alignment – Ensures analysis aligns with your research focus.


📦 Installation

Install the package via npm:

npm install @thebolarin/narrative-analysis-ai

🛠 Usage

Import and use the package in your Node.js project:

import { NarrativeAnalysis } from "@thebolarin/narrative-analysis-ai";

const openai = new OpenAI({
      organization: OPENAI_ORGANIZATION,
      project: OPENAI_PROJECT,
    });

const narrativeAnalysis = new NarrativeAnalysis(openai, preferred_gpt_model);

const researchQuestion = "How has climate change been represented in media?";
const articles = [
  {
    uniqueId: "1",
    title: "The Climate Crisis",
    summary: "The article explores global climate change trends."
  },
  {
    uniqueId: "2",
    title: "Green Energy Policies",
    summary: "Discusses global efforts to transition to renewable energy."
  }
];

async function analyze() {
  const result = await narrativeAnalysis.generateAnalysis({ researchQuestion, articles });
  console.log(result);
}

analyze();

📘 Features

  • Article Analysis: Extracts key narratives, dominance, and evolution of narratives in a given set of articles.
  • Aggregated Analysis: Combines findings across multiple articles to identify broader trends.
  • Statistical Insights: Provides top 5 narratives with their prominence, useful for data visualization.
  • Overall Conclusion: Summarizes findings in relation to the research question.

📌 API Methods

generateAnalysis(researchQuestion: string, articles: Article[]): Promise<AnalysisResult>

Analyzes a set of articles and extracts narratives.

Parameters:

  • researchQuestion (string)
    The central question guiding the analysis.

  • articles (Article[])
    Array of articles, each containing:

    • uniqueId (string) : Unique identifier for the article.

    • title (string) : The article’s title.

    • summary (string) : A brief summary of the article.

Returns:

  • Promise<AnalysisResult>
    An object containing:
    • articleAnalysis : Array of analyzed articles with their narratives.

    • statistics : Data for visualization (top 5 narratives).

    • overallConclusion : Summarized conclusion based on the research question.

📝 Example Response

{
  "articleAnalysis": [
    {
      "uniqueId": "1",
      "title": "Global Warming and Its Effects",
      "summary": "This article discusses the impact of global warming on sea levels and agriculture.",
      "narratives": [
        {"narrative": "Rising sea levels", "details": "Sea levels are rising due to melting ice caps."}
      ],
      "dominance": [
        {"narrative": "Rising sea levels", "percentage": 60}
      ],
      "evolution": "Over time, the focus shifted from local effects to global policy changes."
    }
  ],
  "statistics": [
    {"narrative": "Climate Policy", "value": 45},
    {"narrative": "Renewable Energy", "value": 25}
  ],
  "overallConclusion": "The research shows that climate policies and renewable energy are key narratives in climate discussions."
}

🛠️ Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.