Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yGuy/chatgpt-mattermost-bot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: takuya-o/chatgpt-mattermost-bot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on May 29, 2023

  1. ✨ Feature(src/openai-thread-completion.js): add support for Azure Op…

    …enAI Service
    
    If setting Azure OpenAI API key instead of OpenAI API key, it uses Azure OpenAI Service.
    The instance name, deployment name and API version are now configurable via environment variables. The API request base path and headers are set upped accordingly to use the Azure OpenAI Service API.
    takuya-o committed May 29, 2023
    Copy the full SHA
    7caaeb3 View commit details

Commits on Jun 19, 2023

  1. 🆕 feat Migrated to TypeScript.

      - Formatted by Prettier
      - Lint by eslint
      - Build by esbuild
    ✨ Token-count-based conversation thread management
    ✨ Splitting message that are too long
    ✨ Support GitLab AutoDevOps by test dummy
    takuya-o committed Jun 19, 2023
    Copy the full SHA
    537d514 View commit details

Commits on Jul 19, 2023

  1. ✨ feat(botservice.ts): Changed to respond to system notifications col…

    …lectively
    
    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.
    takuya-o committed Jul 19, 2023
    Copy the full SHA
    13bfe96 View commit details

Commits on Aug 13, 2023

  1. Merge branch 'yGuy/master' into release

    ✨ Upgrade 2.1.2 from upstream
    takuya-o committed Aug 13, 2023
    Copy the full SHA
    be8e4bf View commit details
  2. 🧰 Made upstream 2.1.2 features work fine

    ✨ feat(openai-wrapper.ts): Added a function to use the original OpenAI for image generation even if you are using Azure OpenAI
    🔧 fix(Dockerfile, compose.yaml): downgrade Node version from 20 to 16 and add new environment variables
    🐛 fix(botservice.ts): correct update of answer variable in postMessage function to prevent duplication of error messages
    🔧 Refactoring: Converted plugin and types files to ES modules and performed code formatting
    🔧 fix(tsconfig.json): update module resolution settings
    🔧 fix(tsconfig.json): change TypeScript module resolution strategy from "node" to "bundler", set baseUrl and paths
    🔧 chore(esbuild.config.js): change output directory from 'out' to 'dist'
    ✨ feat(build.sh): add build script
    🔧 chore(.gitignore): update .gitignore to ignore .env extensions
    📝 docs(README.md): Update project details to reflect new features and changes
    🔥 remove(openai-thread-completion.ts): deleted openai-thread-completion.ts file
    takuya-o committed Aug 13, 2023
    Copy the full SHA
    fde42d4 View commit details

Commits on Aug 16, 2023

  1. 🔧 refactor(Dockerfile, package.json, botservice.ts, mm-client.ts, Ima…

    …gePlugin.ts, PluginBase.ts, vite.config.ts): package updates and code improvements
    
    In Dockerfile, updated the node version from 16 to 20. This allows us to use the latest features and security patches.
    
    In package.json, updated several packages and added "node-fetch". This allows us to use the latest features and improves the stability and performance of the code.
    
    In botservice.ts, mm-client.ts, ImagePlugin.ts, PluginBase.ts, made several improvements to improve the readability and maintainability of the code.
    takuya-o committed Aug 16, 2023
    Copy the full SHA
    faf00a1 View commit details

Commits on Nov 7, 2023

  1. 🔧 refactoring: Updated openai-node to v4 and updated environment vari…

    …able samples
    
    Updated the OpenAI API from v3 to v4. This allows us to take advantage of the new API features and improves the readability and maintainability of the code. Also, added new environment variable samples to the .env-sample file. This makes it easier for users to configure the use of the new API.
    
    🔄 update(botservice.ts): Updated to OpenAI API v4
    
    The OpenAI API has been updated to v4, and changes have been made to accommodate this. This allows the use of the new API features, improving the performance and functionality of the application. Also, unnecessary code has been removed to improve code readability and maintainability.
    
    🔧 refactor(ImagePlugin.ts, types.d.ts): use string literals instead of directly using OpenAI types
    
    Using OpenAI types directly can lead to unexpected type changes due to library updates. Therefore, we used string literals to ensure type stability. Also, in types.d.ts, we imported the entire OpenAI instead of directly importing OpenAI types. This allows us to reference the necessary types directly, improving the readability of the code.
    takuya-o committed Nov 7, 2023
    Copy the full SHA
    6c5599b View commit details
  2. 🔥 remove(compose.yaml, botservice.mjs, botservice.ts): remove unneces…

    …sary code and add new environment variable
    
    Added a new environment variable OPENAI_IMAGE_MODEL_NAME in compose.yaml. This allows setting the image model name for OpenAI on docker image. Also, removed the duplicate check for global.FormData in botservice.mjs and botservice.ts. This reduces code redundancy and improves readability.
    takuya-o committed Nov 7, 2023
    Copy the full SHA
    953872d View commit details

Commits on Nov 15, 2023

  1. ✨Support gpt-4-vision-preview model

        ✨ feat(compose.yaml): add OPENAI_VISION_MODEL_NAME environment variable
        ✨ feat(botservice.ts): add image support and separate user and assistant messages
        🔀 refactor(botservice.ts): make isMessageIgnored function asynchronous and add DM check
        🔧 refactor(package.json, botservice.ts, openai-wrapper.ts): update package versions and improve code organization
        🔧 refactor(types.ts, botservice.ts, openai-wrapper.ts, plugins): rename MessageData to MattermostMessageData
    takuya-o committed Nov 15, 2023
    Copy the full SHA
    8f5b7d1 View commit details

Commits on Nov 16, 2023

  1. 📦 feat(package.json, botservice.ts): added image processing library s…

    …harp and implemented image resizing and format conversion
    
        To conform to the image formats and sizes supported by the OpenAI vision model, we use the sharp library to resize and convert the format of images. This ensures that images uploaded by users meet the requirements of the vision model, preventing errors.
    takuya-o committed Nov 16, 2023
    Copy the full SHA
    67c190f View commit details

Commits on Nov 22, 2023

  1. ✨ feet(openai-wrapper.ts, .env-sample, README.md, MEMO.md): Separate …

    …Azure OpenAI API keys and endpoints for text, vision, and image
    
        Separated Azure OpenAI API keys and endpoints into three: text, vision, and image. This allows for individual configuration of each API's version and deployment name, providing more flexible settings. Also improved error messages to make it easier to identify the cause when a problem occurs.
    
        ✨ feat(botservice.ts, ExitPlugin.ts, UnuseImagesPlugin.ts): added ability to ignore images
        Added a new plugin `UnuseImagesPlugin`. This plugin instructs the bot to ignore images when the user asks to "ignore images". Also, a new function `isUnuseImages` was added to `botservice.ts` to determine whether to ignore images or not. This allows the bot to ignore images according to the user's request.
    
        📝 fix(README.md, openai-wrapper.ts): Update documentation and default values
        Fixed some descriptions and default values in README.md that were incorrect. Specifically, corrected the default value for OPENAI_MODEL_NAME to be `gpt-3.5-turbo`, updated the version for AZURE_OPENAI_API_VERSION to `2023-12-01-preview`, and added to the description for AZURE_OPENAI_API_IMAGE_DEPLOYMENT_NAME that DALL-E 3 requires at least the 2023-12-01-preview API version.
    
        📝 docs(README.md): Add support for GPT-4V Vision API and update Azure OpenAI API version
        By adding support for the GPT-4V Vision API, we have enabled the realization of multimodal text and images. Updating the Azure OpenAI API version allows us to use the latest features. Additionally, we added a new screenshot to visually demonstrate how users can interact with the bot.
    
        🔧 refactor(botservice.ts): improve image fetching method and enhance error handling
        To improve the image fetching method, the getBase64Image function has been modified to include a token parameter. This makes the function more versatile and allows it to fetch images with different authentication tokens. Additionally, to enhance error handling, a check has been added to ensure the fetch response is successful. This ensures that the application functions correctly even if image fetching fails.
    
        🔧 refactor(openai-wrapper.ts): completed transition from function_call to tool_calls
        The OpenAI API has been updated to use tool_calls instead of function_call. This change makes the code compatible with the new API and prevents future incompatibility issues. Additionally, this change improves the ability to handle multiple tool calls simultaneously.
    takuya-o committed Nov 22, 2023
    Copy the full SHA
    798e880 View commit details
  2. Merge branch 'yGuy/master' into release

    Support Helm chart
    takuya-o committed Nov 22, 2023
    Copy the full SHA
    941b8a9 View commit details

Commits on Apr 9, 2024

  1. Merge branch 'master' into release

    Upgrade v2.3.0 from upstream.
    takuya-o committed Apr 9, 2024
    Copy the full SHA
    8cf103b View commit details
  2. ✨feat(src/AIProvider.ts): Support Cohere Command R+

    Support Cohere Command R+ and Anthropic Claude 3 by AI provider interface.
    
    Implemented a series of changes related to the development environment, code quality management, and project configuration. This includes updating the development container settings, adding samples for environment variables, introducing Textlint settings, updating VSCode workspace settings, improving Docker Compose configuration, refactoring source code, updating packages, adding a synchronization script, and adjusting TypeScript settings. These changes aim to streamline the development process, improve code readability and maintainability, and enhance the flexibility of project configuration.
    
    Updated the development environment settings to use a new Docker image. Added new variables to the environment variable sample file and introduced Textlint to improve document quality. Updated VSCode workspace settings with added debug configurations. Improved Docker Compose configuration for more flexible environment variable management. The source code includes abstraction of AI providers, refactoring, and addition of new features. Updated package dependencies and added a script to facilitate project synchronization. Finally, adjusted TypeScript settings to improve the development experience.
    takuya-o committed Apr 9, 2024
    Copy the full SHA
    c2f8bc0 View commit details

Commits on Apr 13, 2024

  1. 🚀 feat: Add support for integration with Google Gemini API

        Added support for Google Gemini API by updating environment variables, README, adding a new GoogleGeminiAdapter class, and adjusting existing code. This enables the use of Google's latest AI models to provide more diverse responses and functionalities.
    
        🚀 feat(Dockerfile, eslint.config.js, package.json): Support ESLint V9
        Added an ESLint configuration file `eslint.config.js` and included a step in the Dockerfile to copy this file.
        Also, removed the unnecessary `--ext ts` option from the `lint` script in `package.json` and streamlined dependencies. These changes aim to maintain consistency in the code and make it easier for developers to uphold code quality.
    
        🔥 remove(.eslintrc.json): Remove old ESLint configuration file from the project
        To simplify the project setup and reduce maintenance efforts, the old ESLint configuration file has been removed. This opens up opportunities to explore alternative ways to maintain code quality.
    
        🚚 change(Dockerfile): Remove reference to .eslintrc.json from Dockerfile
        Following the removal of the ESLint configuration file from the project, its reference has been removed from the Dockerfile. This updates the build process and avoids copying unnecessary files.
    
        🔥 refactor(AIProvider.ts): Improve code for safely accessing inputTokens and outputTokens in NonStreamedChatResponse
        Previously, the implementation used the `any` type to access `inputTokens` and `outputTokens`, which was not type-safe. The new implementation uses optional chaining and the nullish coalescing operator to safely access these values, defaulting to -1 if they are not present. This enhances the readability and safety of the code.
    
        📦 package update(package.json): updated versions of dependencies and devDependencies
        Updating the versions of dependencies and devDependencies to their latest ensures that security vulnerabilities are addressed and the latest features are available. Notably, versions of "@anthropic-ai/sdk", "openai", "@swc/core", "@types/node", "@typescript-eslint/eslint-plugin", "@typescript-eslint/parser", "eslint", "tsx", and "typescript" have been updated, which is expected to improve performance and resolve compatibility issues.
         @anthropic-ai/sdk                   ^0.19.0  →   ^0.20.2
         @swc/core                           ^1.4.11  →   ^1.4.13
         @types/node                       ^20.11.30  →  ^20.12.6
         @typescript-eslint/eslint-plugin     ^7.4.0  →    ^7.6.0
         @typescript-eslint/parser            ^7.4.0  →    ^7.6.0
         eslint                              ^8.57.0  →    ^9.0.0
         openai                              ^4.29.2  →   ^4.33.0
         tsx                                  ^4.7.1  →    ^4.7.2
         typescript                           ^5.4.3  →    ^5.4.4
    takuya-o committed Apr 13, 2024
    Copy the full SHA
    a7d3848 View commit details

Commits on Apr 15, 2024

  1. ♻️Refactoring: The classes contained in AIProvider.ts were made into …

    …separate files.
    
    🔧 chore(.codeclimate.yml): Update Code Climate configuration to enhance quality checks
    Several changes have been made to the Code Climate configuration file. These include adding new checks, enabling CSSLint, removing unnecessary languages, and adding Markdownlint. These changes aim to strengthen code quality checks and ensure a more consistent codebase. Additionally, the settings for excluding certain files and folders have been updated to ensure auto-generated files and folders are excluded from checks.
    
    🔤 docs(README.md): Correct "GOGGLE_API_KEY" to "GOOGLE_API_KEY" for accurate spelling
    Correcting the typo improves the accuracy of the documentation. This ensures that the correct environment variable name for the API key is clearly communicated to users, avoiding confusion when configuring.
    takuya-o committed Apr 15, 2024
    Copy the full SHA
    96370a7 View commit details

Commits on Apr 19, 2024

  1. ✨ New feature (src/adapters/GoogleGeminiAdapter.ts): Support tools by…

    … v1beta version of Google Gemini API
    
    GoogleGeminiAdapter.ts uses the v1beta version of the Google Gemini API.
    and added support for tools. This allows us to take advantage of new features in the API and provide more advanced functionality. We also improved the way responses are handled and implemented logic to format them to match OpenAI's format.
    takuya-o committed Apr 19, 2024
    Copy the full SHA
    c94eb9d View commit details

Commits on May 25, 2024

  1. ♻️ refactor: package upgrade and refactor code

    1. **devcontainer.json**:
       - Commend detailed steps for new image setup.
    2. **chatgpt-mattermost-bot.code-workspace**:
       - Added Docker extension recommendation.
    3. **compose.yaml**:
       - Fixed typo in service name.
    4. **botservice.mjs**:
       - Added function to shorten long strings.
       - Added names to message roles.
       - Improved image resizing and format conversion logic.
    5. **package.json**:
       - Updated dependency versions.
         @anthropic-ai/sdk                 ^0.20.5  →    ^0.21.1
         @eslint/js                         ^9.0.0  →     ^9.3.0
         @google/generative-ai              ^0.7.0  →    ^0.11.4
         @mattermost/client                 ^9.6.0  →     ^9.7.0
         @mattermost/types                  ^9.6.0  →     ^9.7.0
         @swc/core                         ^1.4.14  →     ^1.5.7
         @swc/helpers                      ^0.5.10  →    ^0.5.11
         @types/node                      ^20.12.7  →  ^20.12.12
         cohere-ai                          ^7.9.4  →    ^7.10.1
         esbuild                           ^0.20.2  →    ^0.21.3
         eslint                             ^9.0.0  →     ^9.3.0
         openai                            ^4.35.0  →    ^4.47.1
         rimraf                             ^5.0.5  →     ^5.0.7
         sharp                             ^0.33.3  →    ^0.33.4
         textlint-rule-preset-ja-spacing    ^2.3.1  →     ^2.4.3
         tsx                                ^4.7.2  →    ^4.11.0
         typescript-eslint                  ^7.7.0  →    ^7.10.0
         vitest                             ^1.5.0  →     ^1.6.0
         ws                                ^8.16.0  →    ^8.17.0
    6. **CohereAdapter.ts**:
       - Refactored code.
    7. **GoogleGeminiAdapter.ts**:
       - Added function to shorten long strings.
       - Added names to message roles.
    8. **botservice.ts**:
       - Added user names to messages.
    9. **openai-wrapper.ts**:
       - Added logging for chat completions.
       - Added names to message roles.
    10. **postMessage.ts**:
        - Added user names to messages.
    
    - Added support for environment variables to enhance application flexibility.
    - Refactored code to improve readability and maintainability.
    - Updated dependencies to apply the latest features and security patches.
    takuya-o committed May 25, 2024
    Copy the full SHA
    f50687b View commit details

Commits on Dec 12, 2024

  1. 🔧 chore(devcontainer.json, README.md, package.json, CohereAdapter.ts,…

    … GoogleGeminiAdapter.ts, botservice.ts, openai-wrapper.ts, postMessage.ts): update dependencies and improve code
    
    Updated the development environment Docker image to the latest 1-22-bookworm and upgraded dependency packages to their latest versions, enhancing security and performance. Added comments and function descriptions to improve code readability and maintainability. Improved token management in OpenAI API calls and organized log outputs.
     @anthropic-ai/sdk                 ^0.21.1  →   ^0.32.1
     @eslint/js                         ^9.3.0  →   ^9.16.0
     @google/generative-ai              ^0.7.1  →   ^0.21.0
     @mattermost/client                 ^9.6.0  →   ^10.2.0
     @mattermost/types                  ^9.6.0  →   ^10.2.0
     @swc/core                         ^1.4.14  →   ^1.10.1
     @swc/helpers                      ^0.5.10  →   ^0.5.15
     @types/node                      ^20.12.7  →  ^22.10.2
     @types/node-fetch                 ^2.6.11  →   ^2.6.12
     @types/ws                         ^8.5.11  →   ^8.5.13
     cohere-ai                          ^7.9.4  →   ^7.15.0
     debug-level                         3.1.4  →     3.2.1
     esbuild                           ^0.20.2  →   ^0.24.0
     eslint                             ^9.0.0  →   ^9.16.0
     form-data                          ^4.0.0  →    ^4.0.1
     openai                            ^4.35.0  →   ^4.76.1
     prettier                           ^3.3.3  →    ^3.4.2
     sharp                             ^0.33.3  →   ^0.33.5
     textlint                          ^14.0.4  →   ^14.4.0
     textlint-rule-preset-jtf-style    ^2.3.14  →    ^3.0.0
     tsx                                ^4.7.2  →   ^4.19.2
     typescript                         ^5.5.3  →    ^5.7.2
     typescript-eslint                  ^7.7.0  →   ^8.18.0
     vitest                             ^1.5.2  →    ^2.1.8
    takuya-o committed Dec 12, 2024
    Copy the full SHA
    029231c View commit details

Commits on Dec 20, 2024

  1. 🔧 chore(Dockerfile, compose.yaml): use distroless, update Node.js ver…

    …sion and enhance security
    
    Updated Node.js version from 20 to 22 in the Dockerfile and switched to using a distroless image to improve container security by removing unnecessary packages and reducing the attack surface. Changed the user to nonroot and specified ownership in the COPY command to avoid running with root privileges. In compose.yaml, added the cap_drop option to remove container capabilities, further enhancing security.
    takuya-o committed Dec 20, 2024
    Copy the full SHA
    008cfbb View commit details

Commits on Dec 29, 2024

  1. 🚀 feat: support for multiple instances and introduction of configurat…

    …ion file
    
    Version 3.0.0 introduces support for multiple bots in a single process, eliminating the need to run multiple Docker containers to use multiple LLMs. Additionally, configuration management has shifted from environment variables to a `config.yaml` file, enhancing flexibility and removing the need for manual environment variable settings. These changes were made to improve the scalability and ease of management of the application.
    takuya-o committed Dec 29, 2024
    Copy the full SHA
    9575c4b View commit details
  2. 📦 chore(package.json): update dependencies and devDependencies versio…

    …ns, add new screenshot image file
    
    Dependencies such as `@anthropic-ai/sdk`, `openai`, `@eslint/js`, and others have been updated to their latest versions to benefit from bug fixes and new features. Additionally, a new image file `multiBotInstance.png` has been added, which may be used as a visual element in project documentation or UI.
    takuya-o committed Dec 29, 2024
    Copy the full SHA
    0380742 View commit details

Commits on Dec 30, 2024

  1. ✨New feature: Support for environment variables to ensure compatibili…

    …ty with past settings
    
    Possible to use environment variables to config settings, again. This makes it possible to reuse past settings. Improved code readability by organizing variable names and comments.
    However, flexible configuration requires config.yaml.
    takuya-o committed Dec 30, 2024
    Copy the full SHA
    eb33e61 View commit details
  2. 🔧 Documentation and Code Improvement: Add compatibility for environme…

    …nt variables and implement token hiding
    
    In README.md, added explanations about backword compatibility with environment variables in version 3.0.1. For multi-instance setups, manual configuration in config.yaml is recommended. Also, added an environment variables column to clarify configuration options.
    
    In MultiInstance.mjs and MultiInstance.ts, added a hideTokens function to prevent tokens from being displayed in log outputs, enhancing security. Improved error messages when duplicate bot names are detected.
    
    Updated the version in package.json to 3.1.0 to reflect the addition of new features.
    takuya-o committed Dec 30, 2024
    Copy the full SHA
    a02221d View commit details

Commits on Dec 31, 2024

  1. 🔧 refactor: improve environment variable support and bot configuration

    Added sample API keys and tokens to .env-sample for enhanced security.
    Fixed version information in README.md.
    Improved asynchronous handling of bot configurations in MultiInstance.ts using Promise.all, and added error messages for when no bots are configured.
    Also, fixed the function to hide tokens to return a new object without altering the original configuration.
    takuya-o committed Dec 31, 2024
    Copy the full SHA
    d300de7 View commit details
  2. 📝 docs(README.md): clarify changes in configuration methods to suppor…

    …t multiple bots
    
    Clarified that the changes in configuration methods in version 3 are to support multiple bots.
    Additionally, added a heading to the table to emphasize the section for individual bot settings. This makes the guidelines clearer for users when configuring multiple bots.
    Fixed table collapse on GitHub.
    takuya-o committed Dec 31, 2024
    Copy the full SHA
    41d241a View commit details

Commits on Feb 3, 2025

  1. ♻️ Refactoring and Feature Enhancements (.devcontainer/devcontainer.j…

    …son, chatgpt-mattermost-bot.code-workspace, dist/MultiInstance.mjs, eslint.config.js, package.json, src/BotService.ts, src/MattermostClient.ts, src/MultiInstance.ts, src/OpenAIWrapper.ts, src/postMessage.ts): Improved development environment, strengthened error handling, o3-mini support, detailed token usage display, and enhanced support for multiple bots.
    
    This commit improves the development environment's Dockerfile configuration, adjusts ESLint settings to improve code quality, strengthens error handling, adds detailed token usage information to log output, adds support for multiple bots, and makes the Mattermost client configuration more flexible.  These changes are expected to improve development efficiency, enable earlier error detection, and enhance application robustness.
    takuya-o committed Feb 3, 2025
    Copy the full SHA
    d1a3b62 View commit details
Showing with 17,301 additions and 1,585 deletions.
  1. +108 −0 .codeclimate.yml
  2. +45 −0 .devcontainer/devcontainer.json
  3. +25 −0 .env-sample
  4. +1 −0 .gitallowed
  5. +3 −0 .github/copilot-instructions.md
  6. +125 −0 .gitignore
  7. +1 −0 .npmrc
  8. +4 −0 .prettierignore
  9. +7 −0 .prettierrc
  10. +63 −0 .textlintrc
  11. +56 −0 .vscode/launch.json
  12. +23 −10 Dockerfile
  13. +179 −59 README.md
  14. +3 −0 build.sh
  15. +248 −0 chatgpt-mattermost-bot.code-workspace
  16. +20 −0 compose.yaml
  17. +73 −0 config-sample.yaml
  18. +2,184 −0 dist/MultiInstance.mjs
  19. BIN dist/tiktoken-node.linux-x64-gnu.node
  20. +0 −12 docker-compose.yml
  21. +21 −0 esbuild.config.js
  22. +53 −0 eslint.config.js
  23. +1 −0 license.md
  24. BIN mattermost-gpt4v.png
  25. BIN multiBotInstance.png
  26. +10,971 −755 package-lock.json
  27. +73 −16 package.json
  28. +78 −0 prh.yml
  29. +95 −0 src/AIProvider.ts
  30. +485 −0 src/BotService.ts
  31. +98 −0 src/MattermostClient.ts
  32. +109 −0 src/MultiInstance.ts
  33. +592 −0 src/OpenAIWrapper.ts
  34. +51 −0 src/adapters/AnthropicAdapter.ts
  35. +232 −0 src/adapters/CohereAdapter.ts
  36. +395 −0 src/adapters/GoogleGeminiAdapter.ts
  37. +36 −0 src/adapters/OpenAIAdapter.ts
  38. +0 −233 src/botservice.ts
  39. +39 −0 src/config.ts
  40. +5 −5 src/logging.ts
  41. +0 −56 src/mm-client.ts
  42. +0 −157 src/openai-wrapper.ts
  43. +10 −11 src/plugins/ExitPlugin.ts
  44. +127 −113 src/plugins/GraphPlugin.ts
  45. +80 −66 src/plugins/ImagePlugin.ts
  46. +67 −45 src/plugins/MessageCollectPlugin.ts
  47. +27 −20 src/plugins/PluginBase.ts
  48. +13 −0 src/plugins/UnuseImagesPlugin.ts
  49. +293 −0 src/postMessage.ts
  50. +9 −0 src/tokenCount.ts
  51. +51 −13 src/types.d.ts
  52. +114 −14 tsconfig.json
  53. +8 −0 vite.config.ts
108 changes: 108 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# # SaaS版
# engines:
# # ... CONFIG CONTENT ...
# tslint:
# enabled: true
# # ... CONFIG CONTENT ...
# checks:
# comment-format:
# enabled: false
# whitespace:
# enabled: false
# semicolon:
# enabled: false
# no-console:
# enabled: false
# # ... CONFIG CONTENT ...
---
# https://docs.codeclimate.com/docs/advanced-configuration
version: "2"
checks:
# commenct is default
# argument-count:
# config:
# threshold: 4
# complex-logic:
# config:
# threshold: 4
# file-lines:
# config:
# threshold: 250
# method-complexity:
# config:
# threshold: 5
# method-count:
# config:
# threshold: 20
# method-lines:
# config:
# threshold: 25
# nested-control-flow:
# config:
# threshold: 4
# return-statements:
# config:
# threshold: 4
# similar-code:
# config:
# threshold: # language-specific defaults. an override will affect all languages.
# identical-code:
# config:
# threshold: # language-specific defaults. an override will affect all languages.
plugins:
# https://docs.codeclimate.com/docs/list-of-engines
# coffeelint:
# enabled: true
csslint:
enabled: true
duplication:
enabled: true
config:
# https://docs.codeclimate.com/docs/duplication
languages:
- typescript
# - ruby
- javascript
# - python
# - php
eslint:
# https://docs.codeclimate.com/docs/eslint
enabled: true
channel: "stable"
# config: .eslintrc.json
fixme:
enabled: true
#rubocop:
# enabled: true
##
## Community-Supported Plugins
##
markdownlint:
enabled: true
# semgrep:
# enabled: true
# tslint:
# https://docs.codeclimate.com/docs/tslint
# $ ./node_modules/.bin/tslint src/**/*.ts
# enabled: true
# config: tslint.json
exclude_patterns:
# https://docs.codeclimate.com/docs/excluding-files-and-folders#section-auto-generated-file-and-folder-exclusions
- config/
- db/
- dist/
- features/
- "**/node_modules/"
- script/
- "**/spec/"
- "**/test/"
- "**/tests/"
- Tests/
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"
# add
- "**/*.min.js"
- "**/*.min.css"
- "**/__tests__/"
- "**/__mocks__/"
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
},
"containerEnv": {
"TZ": "${localEnv:TZ:JST-9}" // ホストの環境変数TZの値がnullの場合、'JST-9'を設定
},

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-extra/features/apt-get-packages:1": {
"packages": "git-secrets,connect-proxy,netcat-openbsd"
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm ci"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
// 鍵についてはssh-add -l で確認
// 環境変数http_proxyや~/.gitconfigは、コンテナ作成時の値が自動的に登録されている。
// 新しいイメージを持ってきたら
// ID=$(docker ps |awk '$2~/^vsc-/{print $1}')
// docker cp ~/.ssh/config $ID:/home/node/.ssh/
// もしくは、コンテナ内で
// scp -p user@example.com:.ssh/config ~/.ssh/
// が必要
25 changes: 25 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CONFIG_FILE=./config.yaml

# Use environment variables to set API keys and tokens to manage them securely without storing them directly in the container as files.
# OPENAI__MATTERMOST_TOKEN=your-mattermost-token
# OPENAI_API_KEY=your-openai-api-key

# AZURE_MATTERMOST_TOKEN=your-mattermost-token-for-azure
# AZURE_OPENAI_API_KEY=your-azure-openai-api-key
# AZURE_OPENAI_API_IMAGE_KEY=your-azure-openai-vision-key
# AZURE_OPENAI_API_VISION_KEY=your-azure-openai-image-key

# COHERE_MATTERMOST_TOKEN=your-mattermost-token-for-cohere
# COHERE_API_KEY=your-cohere-api-key

# GOOGLE_MATTERMOST_TOKEN=your-mattermost-token-for-google
# GOOGLE_API_KEY=your-google-api-key


# Set the debug level and format
# DEBUG_LEVEL=INFO
# DEBUG_JSON=true
# DEBUG_COLORS=true

# CI_REGISTRY_IMAGE=gitlab.example.com/user/chatgpt-mattermost-bot
# CI_COMMIT_REF_NAME=local
1 change: 1 addition & 0 deletions .gitallowed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
3 changes: 3 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- 新たに生成するコメントは日本語にしてください。ただし元のコメントが英語の場合は英語にしてください。
- コード変更時に元からあるコメントは、そのまま残してください。
- JavaScriptやTypeScriptで行末のセミコロンは省略してください。
125 changes: 125 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,128 @@
/dist/
/*.crt
docker-compose.override.yml

!.env-sample
.env*
!config-sample.yaml
config*.yaml
# envFileを使えは問題なし /.vscode/launch.json
/out/

/.npm/

# Created by https://www.toptal.com/developers/gitignore/api/emacs,MacOS,Windows
# Edit at https://www.toptal.com/developers/gitignore?templates=emacs,MacOS,Windows

### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# cask packages
.cask/
dist/

# Flycheck
flycheck_*.el

# server auth directory
/server/

# projectiles files
.projectile

# directory configuration
.dir-locals.el

# network security
/network-security.data


### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/emacs,MacOS,Windows

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/build/
/dist/
/out/
/node_modules/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"arrowParens": "avoid"
}
63 changes: 63 additions & 0 deletions .textlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// see: https://www.forcia.com/blog/002374.html
{
"plugins": {
"@textlint/markdown": {
"extensions": [".md"], // マークダウン用の拡張
}
},
"filters": {},
"rules": {
// https://github.com/textlint-rule/textlint-rule-prh
"prh": { // 文字揺れ校正 prhをプラグインで使う
"checkBlockQuote": true,
"checkEmphasis": true,
"rulePaths": ["./prh.yml"],
},
// textlint-rule-preset-jtf-styleの設定
"preset-jtf-style": {
"1.2.1.句点(。)と読点(、)": false, // 文中のピリオドとカンマを許容
//"1.1.3.箇条書き": false, // 箇条書きの文末に句点(。)以外を許可
//"2.1.8.算用数字": false, // 算用数字以外も許容する。1桁は全角でも入力できるように。
"2.2.1.ひらがなと漢字の使い分け": true, // ひらがなにしたほうが良い漢字をサジェスト
"4.1.3.ピリオド(.)、カンマ(,)": false, // 文中のピリオドとカンマを許容
"4.2.2.疑問符(?)": false, //半角:を許容
"4.2.7.コロン(:)": false, //半角:を許容
"4.3.1.丸かっこ()": false, // 半角丸括弧を許容
"4.3.2.大かっこ[]": false, // 半角大括弧を許容
},
// textlint-rule-preset-ja-technical-writingの設定
// https://github.com/textlint-ja/textlint-rule-preset-ja-technical-writing
"preset-ja-technical-writing": {
"no-exclamation-question-mark": {
// https://github.com/textlint-rule/textlint-rule-no-exclamation-question-mark
// "allow": ["Yahoo!"],
"allowHalfWidthExclamation": true,
"allowHalfWidthQuestion": true,
"allowFullWidthExclamation": true,
"allowFullWidthQuestion": true,
},
"no-doubled-joshi": {
"strict": false,
"allow": ["か", "が", "に"], // これらの助詞は同一文中に多く登場しても許容
},
"max-ten": { "max": 5 }, // 文中の「、」の数は5個まで
"sentence-length": false, // 文の長さは指定なし
"ja-no-weak-phrase": false, // 弱い表現を許容
"max-comma": false, // カンマの数は指定なし
},
// textlint-rule-preset-ja-spacingの設定
"preset-ja-spacing": {
"ja-space-around-code": { // インラインコードの前後にスペースを入れなくてもよい
"before": false,
"after": false,
},
},

// textlint init
"no-mixed-zenkaku-and-hankaku-alphabet": true,
//"preset-ja-spacing": true,
//"preset-ja-technical-writing": true,
//"preset-jtf-style": true,
//"prh": true
}
}
Loading