Skip to content

Commit

Permalink
Allow plugins to be disabled via environment variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
haegelsperger authored and yGuy committed Jul 20, 2023
1 parent 7830e79 commit 0062b7b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ If you want to learn more about how this plugin came to live, [read the blog pos
These are the available options, you can set them as environment variables when running [the script](./src/botservice.ts)
or when [running the docker image](#using-the-ready-made-image) or when configuring your [docker-compose](#docker-compose) file.

| Name | Required | Example Value | Description |
|----------------------|----------|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| MATTERMOST_URL | yes | `https://mattermost.server` | The URL to the server. This is used for connecting the bot to the Mattermost API |
| MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot |
| OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI |
| OPENAI_MODEL_NAME | no | `gpt-3.5-turbo` | The OpenAI language model to use, defaults to `gpt-3.5-turbo` |
| OPENAI_MAX_TOKENS | no | `2000` | The maximum number of tokens to pass to the OpenAI API, defaults to 2000 |
| 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. |
| YFILES_SERVER_URL | no | `http://localhost:3835` | The URL to the yFiles graph service for embedding auto-generated diagrams. |
| 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 |
| MATTERMOST_BOTNAME | no | `"@chatgpt"` | the name of the bot user in Mattermost, defaults to '@chatgpt' |
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
| BOT_CONTEXT_MSG | no | `7` | The number of previous messages which are appended to the conversation with ChatGPT, defaults to 7 |
| Name | Required | Example Value | Description |
|----------------------|----------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| MATTERMOST_URL | yes | `https://mattermost.server` | The URL to the server. This is used for connecting the bot to the Mattermost API |
| MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot |
| OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI |
| OPENAI_MODEL_NAME | no | `gpt-3.5-turbo` | The OpenAI language model to use, defaults to `gpt-3.5-turbo` |
| OPENAI_MAX_TOKENS | no | `2000` | The maximum number of tokens to pass to the OpenAI API, defaults to 2000 |
| 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. |
| YFILES_SERVER_URL | no | `http://localhost:3835` | The URL to the yFiles graph service for embedding auto-generated diagrams. |
| 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 |
| MATTERMOST_BOTNAME | no | `"@chatgpt"` | the name of the bot user in Mattermost, defaults to '@chatgpt' |
| PLUGINS | no | `graph-plugin, image-plugin` | The enabled plugins of the bot. By default all plugins (grpah-plugin and image-plugin) are enabled. |
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
| BOT_CONTEXT_MSG | no | `15` | The number of previous messages which are appended to the conversation with ChatGPT, defaults to 100 |

> **Note**
> The `YFILES_SERVER_URL` is used for automatically converting text information created by the bot into diagrams.
Expand Down Expand Up @@ -177,4 +178,4 @@ I will also accept helpful pull requests if you find an issue or have an idea fo

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)!

This is under MIT license Copyright (c) 2023 Sebastian Mueller (yWorks)
This is under MIT license Copyright (c) 2023 Sebastian Mueller and Michael Haeglsperger (yWorks)
4 changes: 4 additions & 0 deletions src/plugins/GraphPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class GraphPlugin extends PluginBase<GraphPluginArgs> {

setup(): boolean {
this.addPluginArgument('graphPrompt', 'string', 'A description or topic of the graph. This may also includes style, layout or edge properties')

if(!process.env.plugins || process.env.plugins.indexOf('graph-plugin') === -1)
return false

return !!this.yFilesGPTServerUrl
}

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/ImagePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class ImagePlugin extends PluginBase<ImagePluginArgs> {

setup(): boolean {
this.addPluginArgument('imageDescription', 'string', 'The description of the image provided by the user')

if(!process.env.plugins || process.env.plugins.indexOf('image-plugin') === -1)
return false

return super.setup();
}

Expand Down

0 comments on commit 0062b7b

Please sign in to comment.