Skip to content

Commit 6df6bad

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/botservice.js
2 parents 33bcab9 + dab85a8 commit 6df6bad

20 files changed

+1116
-301
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/node_modules/
2+
/dist/
23
/*.crt
34
docker-compose.override.yml

.idea/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# NPM builder image
2-
FROM node:16-alpine as npm_builder
2+
FROM node:18-alpine as npm_builder
33

44
WORKDIR /app
5-
COPY [ "package.json", "package-lock.json", "./" ]
5+
COPY [ "package.json", "package-lock.json", "tsconfig.json", "./"]
66
COPY [ "src/", "./src/" ]
77

88
RUN npm ci --omit dev
9-
9+
RUN npm run build
1010

1111
# NPM runtime image
12-
FROM node:16-alpine as npm_runtime
12+
FROM node:18-alpine as npm_runtime
1313

1414
WORKDIR /app
1515

1616
ARG NODE_ENV=production
1717
ENV NODE_ENV $NODE_ENV
18+
ENV PLUGINS=image-plugin,graph-plugin
1819

1920
# Avoid running as root:
2021
USER node
2122

2223
COPY --from=npm_builder [ "/app/node_modules/", "./node_modules/" ]
23-
COPY --from=npm_builder [ "/app/src/", "./src/" ]
24+
COPY --from=npm_builder [ "/app/dist/", "./src/" ]
2425
COPY [ "./license.md", "./" ]
2526

2627
ENTRYPOINT [ "node", "src/botservice.js" ]

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,30 @@ You need
99
- the [OpenAI API key](https://platform.openai.com/account/api-keys)
1010
- a [Docker](https://www.docker.com/) server for continuously running the service, alternatively for testing, Node.js is sufficient.
1111

12-
There's a guide about how to do the first two steps written by @InterestingSoup, [here](https://interestingsoup.com/create-a-chatgpt-bot-on-mattermost/) (lots of ads on that page, just block them, ignore them, or keep on reading and try without their screenshots!)
12+
Andrew Zigler from Mattermost created a [YouTube Video](https://www.youtube.com/watch?v=Hx4Ex7YZZiA) that quickly guides you through the setup.
13+
14+
If you want to learn more about how this plugin came to live, [read the blog post at yWorks.com](https://www.yworks.com/blog/diagramming-with-chatgpt)!
15+
1316

1417
## Options
1518

16-
These are the available options, you can set them as environment variables when running [the script](./src/botservice.js)
19+
These are the available options, you can set them as environment variables when running [the script](./src/botservice.ts)
1720
or when [running the docker image](#using-the-ready-made-image) or when configuring your [docker-compose](#docker-compose) file.
1821

19-
| Name | Required | Example Value | Description |
20-
|---------------------|----------|-----------------------------|---------------------------------------------------------------------------------------------|
21-
| MATTERMOST_URL | yes | `https://mattermost.server` | The URL to the server. This is used for connecting the bot to the Mattermost API |
22-
| MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot |
23-
| OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI |
24-
| OPENAI_MODEL_NAME | no | `gpt-3.5-turbo` | The OpenAI language model to use, defaults to `gpt-3.5-turbo` |
25-
| OPENAI_MAX_TOKENS | no | `2000` | The maximum number of tokens to pass to the OpenAI API, defaults to 2000 |
26-
| YFILES_SERVER_URL | no | `http://localhost:3835` | The URL to the yFiles graph service for embedding auto-generated diagrams. |
27-
| NODE_EXTRA_CA_CERTS | no | `/file/to/cert.crt` | a link to a certificate file to pass to node.js for authenticating self-signed certificates |
28-
| MATTERMOST_BOTNAME | no | `"@chatgpt"` | the name of the bot user in Mattermost, defaults to '@chatgpt' |
29-
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
22+
| Name | Required | Example Value | Description |
23+
|----------------------|----------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
24+
| MATTERMOST_URL | yes | `https://mattermost.server` | The URL to the server. This is used for connecting the bot to the Mattermost API |
25+
| MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot |
26+
| OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI |
27+
| OPENAI_MODEL_NAME | no | `gpt-3.5-turbo` | The OpenAI language model to use, defaults to `gpt-3.5-turbo` |
28+
| OPENAI_MAX_TOKENS | no | `2000` | The maximum number of tokens to pass to the OpenAI API, defaults to 2000 |
29+
| OPENAI_TEMPERATURE | no | `0.2` | The sampling temperature to use, between 0 and 2, defaults to 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. |
30+
| YFILES_SERVER_URL | no | `http://localhost:3835` | The URL to the yFiles graph service for embedding auto-generated diagrams. |
31+
| NODE_EXTRA_CA_CERTS | no | `/file/to/cert.crt` | a link to a certificate file to pass to node.js for authenticating self-signed certificates |
32+
| MATTERMOST_BOTNAME | no | `"@chatgpt"` | the name of the bot user in Mattermost, defaults to '@chatgpt' |
33+
| PLUGINS | no | `graph-plugin, image-plugin` | The enabled plugins of the bot. By default all plugins (grpah-plugin and image-plugin) are enabled. |
34+
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
35+
| BOT_CONTEXT_MSG | no | `15` | The number of previous messages which are appended to the conversation with ChatGPT, defaults to 100 |
3036

3137
> **Note**
3238
> The `YFILES_SERVER_URL` is used for automatically converting text information created by the bot into diagrams.
@@ -39,7 +45,7 @@ or when [running the docker image](#using-the-ready-made-image) or when configur
3945
Use the prebuilt image from [`ghcr.io/yguy/chatgpt-mattermost-bot`](https://ghcr.io/yguy/chatgpt-mattermost-bot)
4046

4147
```bash
42-
docker run -d --restart unless-stopped \
48+
docker runPlugin -d --restart unless-stopped \
4349
-e MATTERMOST_URL=https://mattermost.server \
4450
-e MATTERMOST_TOKEN=abababacdcdcd \
4551
-e OPENAI_API_KEY=234234234234234234 \
@@ -55,18 +61,18 @@ First step is to clone this repo.
5561
git clone https://github.com/yGuy/chatgpt-mattermost-bot.git && cd chatgpt-mattermost-bot
5662
```
5763

58-
For testing, you could now just run `npm install` and `npm run start` or `node src/botservice.js` directly, but be sure to set the [environment variables](#options) or pass them to the node process, first!
64+
For testing, you could now just runPlugin `npm install` and `npm runPlugin start` or `node src/botservice.js` directly, but be sure to set the [environment variables](#options) or pass them to the node process, first!
5965

60-
For production use, in order to create a service on a docker container that will always provide the service without you having to run it on your own PC, you can do the following:
66+
For production use, in order to create a service on a docker container that will always provide the service without you having to runPlugin it on your own PC, you can do the following:
6167

6268
Build the docker image from the [Dockerfile](./Dockerfile):
6369
```bash
6470
docker build . -t yguy/chatgpt-mattermost-bot
6571
```
6672

67-
Create and run a container from the image
73+
Create and runPlugin a container from the image
6874
```bash
69-
docker run -d --restart unless-stopped \
75+
docker runPlugin -d --restart unless-stopped \
7076
-e MATTERMOST_URL=https://mattermost.server \
7177
-e MATTERMOST_TOKEN=abababacdcdcd \
7278
-e OPENAI_API_KEY=234234234234234234 \
@@ -81,7 +87,7 @@ will need to provide the CA's public root to the container for validation.
8187
If the root certificate is located at `/absolutepath/to/certfile.crt`, then you
8288
can mount that file into the container at a fixed position and specify the [node environment variable](https://nodejs.org/api/cli.html#node_extra_ca_certsfile) accordingly:
8389
```bash
84-
docker run -d --restart unless-stopped \
90+
docker runPlugin -d --restart unless-stopped \
8591
-v /absolutepath/to/certfile.crt:/certs/certfile.crt \
8692
-e NODE_EXTRA_CA_CERTS=/certs/certfile.crt \
8793
-e MATTERMOST_URL=https://mattermost.server \
@@ -102,7 +108,7 @@ docker stop chatbot
102108
```
103109

104110
## Docker Compose
105-
If you want to run docker compose (maybe even merge it with your mattermost docker stack), you can use this
111+
If you want to runPlugin docker compose (maybe even merge it with your mattermost docker stack), you can use this
106112
as a starting point: First adjust the environment variables in `docker-compose.yml`.
107113

108114
### Required Environment Variables
@@ -172,4 +178,4 @@ I will also accept helpful pull requests if you find an issue or have an idea fo
172178

173179
Last but not least, check out [yWorks](https://www.yworks.com)' fine diagramming SDKs for software developers [yFiles](https://yworks.com/yfiles) and our [free online graph and diagram editors](https://yworks.com/editors)!
174180

175-
This is under MIT license Copyright (c) 2023 Sebastian Mueller (yWorks)
181+
This is under MIT license Copyright (c) 2023 Sebastian Mueller and Michael Haeglsperger (yWorks)

0 commit comments

Comments
 (0)