DocsGPT/extensions/react-widget
2024-06-03 20:36:52 +05:30
..
src fix: dompurify import error 2024-06-03 20:36:52 +05:30
.gitignore shifted to parcel, styled-components 2024-03-05 21:15:58 +05:30
.parcelrc shifted to parcel, styled-components 2024-03-05 21:15:58 +05:30
custom.d.ts shifted to parcel, styled-components 2024-03-05 21:15:58 +05:30
package-lock.json fix: dompurify import error 2024-06-03 20:36:52 +05:30
package.json fix: dompurify import error 2024-06-03 20:36:52 +05:30
README.md fix: added targets for browser environment 2024-06-03 12:57:53 +05:30
tsconfig.json shifted to parcel, styled-components 2024-03-05 21:15:58 +05:30

DocsGPT react widget

This widget will allow you to embed a DocsGPT assistant in your React app.

Installation

npm install  docsgpt

Usage

React

    import { DocsGPTWidget } from "docsgpt";

    const App = () => {
      return <DocsGPTWidget />;
    };

To link the widget to your api and your documents you can pass parameters to the component.

    import { DocsGPTWidget } from "docsgpt";

    const App = () => {
      return <DocsGPTWidget
             apiHost = 'http://localhost:7001',
             selectDocs = 'default',
             apiKey = '',
             avatar = 'https://d3dg1063dc54p9.cloudfront.net/cute-docsgpt.png',
             title = 'Get AI assistance',
             description = 'DocsGPT\'s AI Chatbot is here to help',
             heroTitle = 'Welcome to DocsGPT !',
             heroDescription='This chatbot is built with DocsGPT and utilises GenAI, please review important information using sources.'
             />;
    };

Html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>DocsGPT Widget</title>
      </head>
      <body>
        <div id="app"></div>
        <!-- Include the widget script from dist/modern or dist/legacy -->
        <script src="./node_modules/docsgpt/dist/modern/main.js" type="module"></script>
        <script type="module">
          window.onload = function() {
            renderDocsGPTWidget('app');
          }
        </script>
      </body>
    </html>

To link the widget to your api and your documents you can pass parameters to the renderDocsGPTWidget('div id', { parameters }).

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>DocsGPT Widget</title>
      </head>
      <body>
        <div id="app"></div>
        <!-- Include the widget script from dist/modern or dist/legacy -->
        <script src="./node_modules/docsgpt/dist/modern/main.js" type="module"></script>
        <script type="module">
          window.onload = function() {
            renderDocsGPTWidget('app', , {
              apiHost: 'http://localhost:7001',
              selectDocs: 'default',
              apiKey: '',
              avatar: 'https://d3dg1063dc54p9.cloudfront.net/cute-docsgpt.png',
              title: 'Get AI assistance',
              description: "DocsGPT's AI Chatbot is here to help",
              heroTitle: 'Welcome to DocsGPT !',
              heroDescription: 'This chatbot is built with DocsGPT and utilises GenAI, please review important information using sources.'
            });
          }
        </script>
      </body>
    </html>

Our github

DocsGPT

You can find the source code in the extensions/react-widget folder.