Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
Signed-off-by: cbh778899 <cbh778899@outlook.com>
  • Loading branch information
cbh778899 committed Aug 30, 2024
1 parent 2b4bcfc commit c8c5bcc
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,45 @@ make dev
```
**NOTE:** `make dev` Requires Node.js environment installed, or at least have `node_modules` specified in `package.json` installed on your server. Please see [Local Machine](#local-machine) section.

## Embed your chatbot into website
To embed a chatbot to your website, simply add
## Lint
To start lint your code, simply run
```shell
npm run lint
```

## APIs

### Docs
Go to the url of your project, default [http://localhost:8000](http://localhost:8000) if you didn't disabled the `Docs` route, then you can see docs and try it on.
See [demo video](#setup-and-api-usage-demo-video).

### Monitor
This project got monitor build with swagger-stats, when you got this project running, just go to `<Your Server>:<Your Port>/stats`.
For example, [http://localhost:8000/stats](http://localhost:8000/stats)

### Chatbox
> When you set up the project and didn't disabled the `chatbox` API, you can get a quick-setup chatbot with some basic styles on your own website, which calls the `/v1/chat/completions` API for inference.
To set it up, simply add
```html
<script src='http://localhost:8000/chatbox?base_url=http%3A%2F%2Flocalhost%3A8000' defer></script>
<script src='http://localhost:8000/chatbox' defer></script>
```
into the bottom of your html body element. So easy!
Please change the `http://localhost:8000` and the base_url in request query to your real host to make sure it works.

If you want to hide the real link, in your javascript code you can do
```js
const chatbox_script = await (await fetch("http://localhost:8000/chatbox?base_url=http%3A%2F%2Flocalhost%3A8000")).blob();
const chatbox_script = await (await fetch("http://localhost:8000/chatbox")).blob();
const chatbox_url = URL.createObjectURL(chatbox_script);
const script_elem = document.createElement('script');
script_elem.src = chatbox_url;
document.body.append(script_elem);
```
And remember to use `URL.revokeObjectURL(chatbox_url)` if you don't need it anymore.

## Lint
To start lint your code, simply run
```shell
npm run lint
```

## Monitor
This project got monitor build with swagger-stats, when you got this project running, just go to `<Your Server>:<Your Port>/stats`.
For example, [http://localhost:8000/stats](http://localhost:8000/stats)
And remember to use `URL.revokeObjectURL(chatbox_url)` if you don't need it anymore.

Extra parameters ([request query](https://en.wikipedia.org/wiki/Query_string)) you can add to it are:
* `base_url`: `String`
> Add this when in production, otherwise the requests won't send to correct route.
> Default `http://localhost:8000`.
* `max_tokens`: `Integer`
> Add this when you want to limit tokens can be generated, is useful in production.
> Default `128`

0 comments on commit c8c5bcc

Please sign in to comment.