Skip to content

Commit 13bfe96

Browse files
committed
✨ feat(botservice.ts): Changed to respond to system notifications collectively
Because of splitting messages results in slow response. ✨ feat(package.json): add bugs and homepage URLs for issue reporting and project homepage 🐛 fix(package.json): add npm dedup to upgrade script 🔧 chore(package.json): update versions of dev dependencies 🔧 fix(botservice.ts): filter and modify messages to remove system messages and their lines 🐛 fix(botservice.ts): change variable name case from lowercase limit_tokes to uppercase LIMIT_TOKENS to improve semantics ✨ feat(botservice.ts): add expireMessages function to remove old messages ✨ feat: added functionality to add completion and modify last line when continuing a thread 🐛 fix: removed unnecessary function call and added debug information to log 🔧 fix(mm-client.ts): fix import order of packages 🔧 fix(openai-thread-completion.ts): change variable name to uppercase MAX_TOKENS ✨ feat(openai-thread-completion.ts): add usage statistics for the response 🔧 fix(process-graph-response.ts): fix import order Added bugs and homepage URLs to package.json for issue reporting and accessing the project homepage, allowing users to report issues and access the project's homepage. Added npm dedup to the upgrade script, which resolves dependency duplication and keeps package versions up to date. Updated versions of dev dependencies, allowing the use of the latest versions of tools such as TypeScript and ESLint. Filtered and modified the messages to remove system messages and their lines. This results in a cleaner display of messages within threads. By changing the variable name to LIMIT_TOKENS, the limit value for tokens becomes more clear. The addition of the expireMessages function allows for the removal of old messages. This ensures that the total token count of the messages does not exceed the limit. When continuing a thread, the continueThread function is used to add completion to the reply message. The modifyLastLine function is used to modify the last line. The modified answer is then passed to the newPost function to be posted, allowing the thread to continue. Additionally, debug information is added to the log.
1 parent 537d514 commit 13bfe96

13 files changed

+1093
-521
lines changed

.codeclimate.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# # SaaS版
2+
# engines:
3+
# # ... CONFIG CONTENT ...
4+
# tslint:
5+
# enabled: true
6+
# # ... CONFIG CONTENT ...
7+
# checks:
8+
# comment-format:
9+
# enabled: false
10+
# whitespace:
11+
# enabled: false
12+
# semicolon:
13+
# enabled: false
14+
# no-console:
15+
# enabled: false
16+
# # ... CONFIG CONTENT ...
17+
---
18+
version: "2"
19+
plugins:
20+
# csslint:
21+
# enabled: true
22+
# coffeelint:
23+
# enabled: true
24+
duplication:
25+
enabled: true
26+
config:
27+
languages:
28+
# https://docs.codeclimate.com/docs/duplication
29+
- typescript
30+
- ruby
31+
- javascript
32+
- python
33+
- php
34+
# https://docs.codeclimate.com/docs/list-of-engines
35+
# https://docs.codeclimate.com/docs/tslint
36+
# $ ./node_modules/.bin/tslint src/**/*.ts
37+
# tslint:
38+
# enabled: true
39+
# config: tslint.json
40+
eslint:
41+
enabled: true
42+
channel: "stable"
43+
config: .eslintrc.json
44+
fixme:
45+
enabled: true
46+
rubocop:
47+
enabled: true
48+
exclude_patterns:
49+
- config/
50+
- db/
51+
- dist/
52+
- features/
53+
- "**/node_modules/"
54+
- script/
55+
- "**/spec/"
56+
- "**/test/"
57+
- "**/tests/"
58+
- Tests/
59+
- "**/vendor/"
60+
- "**/*_test.go"
61+
- "**/*.d.ts"
62+
- "**/*.min.js"
63+
- "**/*.min.css"
64+
- "**/__tests__/"
65+
- "**/__mocks__/"

.eslintrc.json

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,43 @@
2121
//"packageManager": "npm",
2222
"env": { "node": true },
2323
"rules": {
24+
"max-lines-per-function": ["warn", {"max": 75}], //GitLab25
25+
"max-lines": ["warn", {"max": 500}], //GitLab250
26+
//"complexity": ["error", { "max": 5 }], //GitLab5
2427
"import/order": "off",
25-
"sort-imports": "off",
28+
"sort-imports": "warn",
2629
// "simple-import-sort/imports": "error",
2730
// "simple-import-sort/exports": "error",
2831
"import/first": "error",
2932
"import/newline-after-import": "error",
3033
"import/no-duplicates": "error",
3134
"@typescript-eslint/no-non-null-assertion": "off",
32-
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
35+
"@typescript-eslint/no-unused-vars": ["error", {
36+
"argsIgnorePattern": "^_",
37+
"varsIgnorePattern": "^[A-Z]"
38+
}],
39+
/** 命名規則 */
40+
"@typescript-eslint/naming-convention": [
41+
"error",
42+
{ // classやtypeなどは頭大文
43+
"selector": "typeLike",
44+
"format": ["PascalCase"]
45+
},
46+
{ // グローバル定数はアッパーケース
47+
"selector": "variable",
48+
"modifiers": ["global", "const"],
49+
"format": ["camelCase", "UPPER_CASE"]
50+
},
51+
{ // 変数名はキャメルケース
52+
"selector": "variable",
53+
"format": ["camelCase", "UPPER_CASE"]
54+
}
55+
],
56+
// 未使用の変数や関数は宣言禁止、ただし大文字で始まっているものはクラスなので許す
57+
"no-unused-vars": ["error", {
58+
"argsIgnorePattern": "^_",
59+
"varsIgnorePattern": "^[A-Z]"
60+
}],
3361
"no-console": "error"
3462
}
3563
}

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"semi": false,
33
"singleQuote": true,
44
"trailingComma": "all",
5+
"printWidth": 120,
56
"arrowParens": "avoid"
67
}

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ or when [running the docker image](#using-the-ready-made-image) or when configur
2525
| MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot |
2626
| OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI |
2727
| 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 |
28+
| OPENAI_MAX_TOKENS | no | `2000` | The max_tokens parameter to pass to the OpenAI API, with a default value of 2000. API will answer up to this number of tokens |
2929
| 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. |
3030
| AZURE_OPENAI_API_KEY | no | `0123456789abcdefghijklmno` | The Azure OpenAI Service API key to authoenticate |
3131
| AZURE_OPENAI_API_INSTANCE_NAME | no | `example-name` | The instance name on the Azure OpenAI Service |
3232
| AZURE_OPENAI_API_DEPLOYMENT_NAME | no | `gpt-35-turbo` | The name of the deployed model on the Azure OpenAI Service |
3333
| AZURE_OPENAI_API_VERSION | no | `2023-03-15-preview` | The Azure OpenAI version |
34-
| YFILES_SERVER_URL | no | `http://localhost:3835` | The URL to the yFiles graph service for embedding auto-generated diagrams. |
35-
| 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 |
36-
| MATTERMOST_BOTNAME | no | `"@chatgpt"` | the name of the bot user in Mattermost, defaults to '@chatgpt' |
37-
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
34+
| YFILES_SERVER_URL | no | `http://localhost:3835` | The URL to the yFiles graph service for embedding auto-generated diagrams. |
35+
| 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 |
36+
| MATTERMOST_BOTNAME | no | `"@chatgpt"` | the name of the bot user in Mattermost, defaults to '@chatgpt' |
37+
| MAX_PROMPT_TOKENS | no | `2000` | Maximum token count of the prompt passed to the OpenAI API. default is 2000 |
38+
| DEBUG_LEVEL | no | `TRACE` | a debug level used for logging activity, defaults to `INFO` |
3839

3940
> **Note**
4041
> The `YFILES_SERVER_URL` is used for automatically converting text information created by the bot into diagrams.
@@ -53,17 +54,17 @@ or when [running the docker image](#using-the-ready-made-image) or when configur
5354
* Splitting message that are too long
5455
* Support GitLab AutoDevOps by test dummy
5556

56-
## Using the docker image
57+
## Using the ready-made image
5758

58-
Use your builted and pushed image.
59+
Use the prebuilt image from [`gitlab.on-o.com/docker/chatgpt-mattermost-bot/release`](https://gitlab.on-o.com/Docker/chatgpt-mattermost-bot/container_registry/150)
5960

6061
```bash
6162
docker run -d --restart unless-stopped \
6263
-e MATTERMOST_URL=https://mattermost.server \
6364
-e MATTERMOST_TOKEN=abababacdcdcd \
6465
-e OPENAI_API_KEY=234234234234234234 \
6566
--name chatbot \
66-
<Your Docker Registry>/chatgpt-mattermost-bot:latest
67+
gitlab.on-o.com/docker/chatgpt-mattermost-bot/release:latest
6768
```
6869

6970
As Azure OpenAI Service case
@@ -74,7 +75,7 @@ docker run -d --restart unless-stopped \
7475
-e AZURE_OPENAI_API_KEY=234234234234234234 \
7576
-e AZURE_OPENAI_API_INSTANCE_NAME=example-name \
7677
--name chatbot \
77-
<Your Docker Registry>/chatgpt-mattermost-bot:latest
78+
gitlab.on-o.com/docker/chatgpt-mattermost-bot/release:latest
7879
```
7980

8081

chatgpt-mattermost-bot.code-workspace

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"path": "."
55
}
66
],
7-
"settings": {}
7+
"settings": {},
8+
"extensions": {
9+
"recommendations": [
10+
"dbaeumer.vscode-eslint",
11+
"esbenp.prettier-vscode"
12+
]
13+
}
814
}

0 commit comments

Comments
 (0)