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

@rumenpetrov/ai-chat-widget

v0.0.19

Published

This is a native web component which provides basic AI chat functionality.

Downloads

15

Readme

✨ AI chat widget

⚠️ Warning This is a learning project. It's not meant to be used in production environments.

🚧 Work in progress 🚧 This is a native web component which provides basic AI chat functionality (single question, no history).

| | | |-|-| | mobile light capital | mobile dark capital | mobile light provider settings | mobile dark provider settings |

Demo video See more

📋 Features

  • [x] Integrate it in your website - Use it in your vanilla website or with a framework which supports web components
  • [x] Provider selection - You could use Open AI API or another local LLM server like LM Studio or LocalAI
  • [x] Theming - Could be customized and adapted to light/dark user preferences
  • [x] Stream responses - The response is shown to you at same time it is generated
  • [x] Syntax highlight for code snippets

🔒 Privacy

  • 🟢 Database - The project is using IndexDB, under the hood. This is native, local database which modern browsers provide. Meaning any configuration you provide is stored locally on your machine,accessible only to you.
  • AI prompts - Every question you ask has to be processed somewhere which leaves it to the AI provider to dictate the privacy level.
    • 🟢 Local provider - Everything is stored locally
    • 🟡 Open AI - Any prompts are send to Open AI's API for processing

🚀 Get started

  1. Add the module to your website
With bundler
$ npm i @rumenpetrov/ai-chat-widget
// index.js
import '@rumenpetrov/ai-chat-widget'
Use CDN for buildless approach
<script type="module" src="https://esm.sh/@rumenpetrov/ai-chat-widget/dist/bundle.js"></script>
  1. Get yourself a theme - You could use Material Theme Builder on the Web to generate all the CSS custom properties (design tokens) which the UI library we are using expects to function correctly and add them to you styles.
<!-- Quick light/dark theme example -->
<!doctype html>
<html lang="en">
  <head>
    ...
    <style>
      :root {
        color-scheme: light dark;

        font-family: system-ui, sans-serif;
        color: #213547;
        background-color: #ffffff;

        /* All generated tokens from the light theme you got form Material Theme Builder */
        --md-sys-color-primary: rgb(65 95 145);
        --md-sys-color-surface-tint: rgb(65 95 145);
        ...
      }

      @media (prefers-color-scheme: dark) {
        :root {
          color: rgba(255, 255, 255, 0.87);
          background-color: #242424;

          /* All generated tokens from the dark theme you got form Material Theme Builder */
          --md-sys-color-primary: rgb(170 199 255);
          --md-sys-color-surface-tint: rgb(170 199 255);
          ...
        }
      }
    }
    </style>
    ...
  </head>
  <body>
    ...
  </body>
</html>
  1. Use the web component somewhere on your page
<acw-root></acw-root>
  1. Make sure you select and configure your AI provider of choice - You could use the settings modal for this.

🖌️ Styling

  • The UI is based on Material web components which means you could use CSS custom properties to overwrite any of the tokens their components expose.
  • There are part attributes spread around the UI which could be used for styling as well

Technical stack