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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsperplex

v1.0.2

Published

An innovative JavaScript library for advanced semantic search and AI-powered answer generation

Downloads

5

Readme

JSperplex

JSperplex is an innovative npm package for advanced semantic search and AI-powered answer generation. It provides powerful search capabilities that can be easily integrated into Node.js applications.

Features

  • Semantic searching using cutting-edge NLP techniques
  • Intelligent result reranking for improved relevance
  • AI-powered answer generation using Groq API
  • Seamless integration with Node.js applications

Installation

Install JSperplex via npm:

npm install jsperplex

Usage

Here's a basic example of how to use JSperplex:

import JSperplex from "jsperplex";
import dotenv from "dotenv";

// Load environment variables
dotenv.config();

// Initialize JSperplex with your API keys
const searcher = new JSperplex({
  cohereApiKey: process.env.COHERE_API_KEY,
  jinaApiKey: process.env.JINA_API_KEY,
  serperApiKey: process.env.SERPER_API_KEY,
  groqApiKey: process.env.GROQ_API_KEY,
});

// Configuration options for the search
const searchOptions = {
  proMode: true,
  location: "us",
};

// Perform a search
async function performSearch() {
  try {
    const result = await searcher.search(
      "What are the benefits of regular exercise?",
      searchOptions
    );
    console.log("Answer:", result.answer);
    console.log("Relevant Questions:", result.relevantQuestions);
    console.log("Number of sources:", result.sourcesResult.organic.length);
  } catch (error) {
    console.error("Error:", error.message);
  }
}

performSearch();

API Reference

new JSperplex(config)

Creates a new JSperplex instance.

  • config: An object containing API keys for various services.

search(query, options)

Performs a semantic search and generates an AI-powered answer.

  • query: The search query string.
  • options: An object with the following properties:
    • proMode: Boolean indicating whether to use advanced features (default: false).
    • location: String representing the search location (default: 'us').

Returns a Promise that resolves to an object containing:

  • answer: The generated answer string.
  • relevantQuestions: An array of relevant follow-up questions.
  • sourcesResult: An object containing the search results and sources.

Environment Setup

Create a .env file in the root of your project and add your API keys:

COHERE_API_KEY=your_cohere_api_key
JINA_API_KEY=your_jina_api_key
SERPER_API_KEY=your_serper_api_key
GROQ_API_KEY=your_groq_api_key

You can obtain these keys from:

Contributing

We welcome contributions to JSperplex! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Support

For any questions or feedback, please open an issue on the GitHub repository.


Elevate your search capabilities with JSperplex! 🚀🔍