0.0.16 • Published 2 months ago

@sib-swiss/chat-with-context v0.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

šŸ’¬ Chat with context web component

NPM

A web component to easily deploy an interface for a chat with context. It is the frontend for the chat API built at github.com/sib-swiss/sparql-llm. It provides a user-friendly chat interface with additional features to inspect the context used by the LLM to generate the response.

šŸ‘†ļø You can try it for a few SPARQL endpoints of the SIB, such as UniProt and Bgee, at chat.expasy.org

šŸš€ Use

  1. Import from a CDN:

    <script type="module" src="https://unpkg.com/@sib-swiss/chat-with-context"></script>
    <link href="https://unpkg.com/@sib-swiss/chat-with-context/dist/chat-with-context.css" rel="stylesheet" />

    Or install with a package manager in your project:

    npm install --save @sib-swiss/chat-with-context
    # or
    pnpm add @sib-swiss/chat-with-context

    And import in your JS/TS file with:

    import "@sib-swiss/chat-with-context";
    import "@sib-swiss/chat-with-context/dist/chat-with-context.css";
  2. Use the custom element in your HTML/JSX/TSX code:

    <chat-with-context
      chat-endpoint="http://localhost:8000/chat"
      feedback-endpoint="http://localhost:8000/feedback"
      api-key="public_apikey_used_by_frontend_to_prevent_abuse_from_robots"
      examples="Which resources are available at the SIB?,How can I get the HGNC symbol for the protein P68871?,What are the rat orthologs of the human TP53?,Where is expressed the gene ACE2 in human?,Anatomical entities where the INS zebrafish gene is expressed and its gene GO annotations,List the genes in primates orthologous to genes expressed in the fruit fly eye"
    ></chat-with-context>

!WARNING

It uses TailwindCSS for styling

šŸ“ Basic example

No need for a complex project you can integrate SPARQL editor in any HTML page by importing from a CDN!

Create a index.html file with:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>SPARQL editor dev</title>
    <meta name="description" content="SPARQL editor demo page" />
    <link rel="icon" type="image/png" href="https://upload.wikimedia.org/wikipedia/commons/f/f3/Rdf_logo.svg" />
    <!-- Import the module from a CDN -->
    <script type="module" src="https://unpkg.com/@sib-swiss/chat-with-context"></script>
  </head>

  <body>
    <div>
      <chat-with-context
        chat-endpoint="http://localhost:8000/chat"
        feedback-endpoint="http://localhost:8000/feedback"
        api-key="public_apikey_used_by_frontend_to_prevent_abuse_from_robots"
        examples="Which resources are available at the SIB?,How can I get the HGNC symbol for the protein P68871?,What are the rat orthologs of the human TP53?,Where is expressed the gene ACE2 in human?,Anatomical entities where the INS zebrafish gene is expressed and its gene GO annotations,List the genes in primates orthologous to genes expressed in the fruit fly eye"
      ></chat-with-context>
    </div>
  </body>
</html>

Then just open this HTML page in your favorite browser.

You can also start a basic web server with NodeJS or Python:

npx http-server
# or
python -m http.server

šŸ§‘ā€šŸ’» Development

Install:

npm i

Start in dev:

npm run dev

Build package:

npm run build

Build demo website (used by the python API):

npm run build:demo

Format and lint:

npm run fmt
npm run lint

Publish new version:

npm version patch
0.0.16

2 months ago

0.0.15

2 months ago

0.0.14

3 months ago

0.0.13

3 months ago

0.0.12

6 months ago

0.0.11

6 months ago

0.0.10

6 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.1

7 months ago