mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
109 lines
3.3 KiB
Markdown
109 lines
3.3 KiB
Markdown
# DocsGPT react widget
|
|
|
|
This widget will allow you to embed a DocsGPT assistant in your React app.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npm install docsgpt
|
|
```
|
|
|
|
## Usage
|
|
|
|
### React
|
|
|
|
```javascript
|
|
import { DocsGPTWidget } from "docsgpt";
|
|
|
|
const App = () => {
|
|
return <DocsGPTWidget />;
|
|
};
|
|
```
|
|
|
|
To link the widget to your api and your documents you can pass parameters to the <DocsGPTWidget /> component.
|
|
|
|
```javascript
|
|
import { DocsGPTWidget } from "docsgpt";
|
|
|
|
const App = () => {
|
|
return <DocsGPTWidget
|
|
apiHost="https://your-docsgpt-api.com"
|
|
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."
|
|
theme = "dark"
|
|
buttonIcon = "https://your-icon"
|
|
buttonBg = "#222327"
|
|
/>;
|
|
};
|
|
```
|
|
|
|
### Html
|
|
|
|
```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="https://unpkg.com/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 })**.
|
|
|
|
```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="https://unpkg.com/docsgpt/dist/modern/main.js" type="module"></script>
|
|
<script type="module">
|
|
window.onload = function() {
|
|
renderDocsGPTWidget('app', {
|
|
apiHost: 'http://localhost:7001',
|
|
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.',
|
|
theme:"dark",
|
|
buttonIcon:"https://your-icon.svg",
|
|
buttonBg:"#222327"
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
## Our github
|
|
|
|
[DocsGPT](https://github.com/arc53/DocsGPT)
|
|
|
|
You can find the source code in the extensions/react-widget folder.
|