Skip to content

Commit 8cf103b

Browse files
committed
Merge branch 'master' into release
Upgrade v2.3.0 from upstream.
2 parents 941b8a9 + 0964982 commit 8cf103b

File tree

9 files changed

+25
-34
lines changed

9 files changed

+25
-34
lines changed

.github/workflows/docker-image.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Docker Image CI
22

33
on:
44
push:
5-
branches: [ "master" ]
65
tags: [ 'v*.*.*' ]
76

87
env:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ or when [running the docker image](#using-the-ready-made-docker-image) or when c
4444
| MATTERMOST_URL | yes | `https://mattermost.server` | The URL to the server. This is used for connecting the bot to the Mattermost API |
4545
| MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot |
4646
| OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI |
47+
| OPENAI_API_BASE | no | `http://example.com:8080/v1` | The address of an OpenAI compatible API. Overrides the default base path (`https://api.openai.com`) |
4748
| OPENAI_MODEL_NAME | no | `gpt-3.5-turbo` | The OpenAI language model to use, defaults to `gpt-3.5-turbo` |
4849
| OPENAI_MAX_TOKENS | no | `2000` | The maximum number of tokens to pass to the OpenAI API, defaults to 2000 |
4950
| 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. |
@@ -66,6 +67,7 @@ or when [running the docker image](#using-the-ready-made-docker-image) or when c
6667
| PLUGINS | no | `graph-plugin, image-plugin` | The enabled plugins of the bot. By default all plugins (grpah-plugin and image-plugin) are enabled. |
6768
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
6869
| BOT_CONTEXT_MSG | no | `15` | The number of previous messages which are appended to the conversation with ChatGPT, defaults to 100 |
70+
| BOT_INSTRUCTION | no | `Act like Elon Musk` | Extra instruction to give your assistance. How should the assistant behave? |
6971

7072
> **Note**
7173
> The `YFILES_SERVER_URL` is used for automatically converting text information created by the bot into diagrams.

helm/chatgpt-mattermost-bot/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v2
22
name: chatgpt-mattermost-bot
33
description: A ChatGPT-powered Chatbot for Mattermost
44
type: application
5-
version: 2.1.2
6-
appVersion: v2.1.2
5+
version: 2.3.0
6+
appVersion: v2.3.0
77

helm/chatgpt-mattermost-bot/templates/chatbot-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ data:
1717
DEBUG_LEVEL: "{{ .Values.config.DEBUG_LEVEL | default "INFO" }}"
1818
BOT_CONTEXT_MSG: "{{ .Values.config.BOT_CONTEXT_MSG | default "100" }}"
1919
NODE_ENV: "{{ .Values.config.NODE_ENV | default "production" }}"
20-
21-
20+
BOT_INSTRUCTION: "{{ .Values.config.BOT_INSTRUCTION | default "" }}"

helm/chatgpt-mattermost-bot/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ image:
33
repository: chatgpt-mattermost-bot
44
pullPolicy: IfNotPresent
55
# Overrides the image tag whose default is the chart appVersion.
6-
tag: "v2.1.2"
6+
tag: ""
77

88
imagePullSecrets: []
99

@@ -26,6 +26,7 @@ config: # required: example: descriptio
2626
DEBUG_LEVEL: "" # no TRACE a debug level used for logging activity, defaults to INFO
2727
BOT_CONTEXT_MSG: "" # no 15 The number of previous messages which are appended to the conversation with ChatGPT, defaults to 100
2828
NODE_ENV: "" # no development The mode NodeJS runs in. Defaults to production
29+
BOT_INSTRUCTION: "" # no Act like Elon Musk Extra instruction to give your assistance. How should the assistant behave?
2930

3031

3132
serviceAccount:

package-lock.json

Lines changed: 5 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "chatgpt-mattermost-bot",
3-
"version": "2.1.2",
4-
"description": "ChatGPT bot on mattermost",
3+
"version": "2.3.0",
54
"private": true,
65
"keywords": [
76
"chatgpt",

src/botservice.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ if (!global.FormData) {
2727

2828
const name = process.env['MATTERMOST_BOTNAME'] || '@chatgpt'
2929
const contextMsgCount = Number(process.env['BOT_CONTEXT_MSG'] ?? 100)
30-
export const SYSTEM_MESSAGE_HEADER = '// BOT System Message: '
31-
export const LIMIT_TOKENS = Number(process.env['MAX_PROMPT_TOKENS'] ?? 2000)
30+
const additionalBotInstructions = process.env['BOT_INSTRUCTION'] || "You are a helpful assistant. Whenever users asks you for help you will " +
31+
"provide them with succinct answers formatted using Markdown. You know the user's name as it is provided within the " +
32+
"meta data of the messages."
3233

3334
/* List of all registered plugins */
3435
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -41,12 +42,8 @@ const plugins: PluginBase<any>[] = [
4142
]
4243

4344
/* The main system instruction for GPT */
44-
const botInstructions =
45-
'Your name is ' +
46-
name +
47-
' and you are a helpful assistant. Whenever users asks you for help you will ' +
48-
"provide them with succinct answers formatted using Markdown. You know the user's name as it is provided within the " +
49-
'meta data of the messages.'
45+
const botInstructions = "Your name is " + name + ". " + additionalBotInstructions
46+
botLog.debug({botInstructions: botInstructions})
5047

5148
async function onClientMessage(msg: WebSocketMessage<JSONMessageData>, meId: string) {
5249
if ((msg.event !== 'posted' && msg.event !== 'post_edited') || !meId) {

src/openai-wrapper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import { PluginBase } from './plugins/PluginBase.js'
44

55
import { openAILog as log } from './logging.js'
66

7-
const apiKey = process.env['OPENAI_API_KEY']
8-
const azureOpenAiApiKey = process.env['AZURE_OPENAI_API_KEY']
9-
const azureOpenAiApiVersion = process.env['AZURE_OPENAI_API_VERSION'] ?? '2023-09-01-preview'
7+
const apiKey = process.env['OPENAI_API_KEY'];
8+
const basePath = process.env['OPENAI_API_BASE'];
9+
log.trace({apiKey, basePath})
10+
11+
const configuration = new Configuration({ apiKey, basePath })
12+
13+
const openai = new OpenAIApi(configuration)
1014

1115
const model = process.env['OPENAI_MODEL_NAME'] ?? 'gpt-3.5-turbo'
1216
const MAX_TOKENS = Number(process.env['OPENAI_MAX_TOKENS'] ?? 2000)

0 commit comments

Comments
 (0)