phpbb_ailabs/.github
2023-05-28 15:07:04 -07:00
..
docs Updated readme and release date 2023-05-28 14:56:08 -07:00
license.txt license.txt symlink 2023-05-28 15:07:04 -07:00
README.md Readme 2023-05-27 18:52:14 -07:00

AI Labs v 1.0.6

Incorporate AI into your phpBB board and get ready for an exciting experience.
Currently supported Midjourney, ChatGPT, DALL-E (OpenAI) and Stable Diffusion (Stability AI).

Table of Contents

  1. Examples
  2. Requirements
  3. Important notes
  4. Installation
  5. Midjourney setup
  6. ChatGPT setup
  7. ChatGPT advanced setup
  8. DALL-E setup
  9. DALL-E advanced features
  10. Stable Diffusion setup
  11. Troubleshooting
  12. Support and suggestions
  13. Changelog
  14. License

Examples

Requirements

  • php >=7.4
  • phpbb >= 3.2

Important notes

  • Installing of Simple mentions phpBB extension strongly suggested.
    @mention feature makes it really easy to talk to AI bots and other board users.

  • If you are planning to use image generation AI (eg DALL-E or Stable Diffusion) make sure to adjust attachment settings to support large images and verify that webp image extension configured.

    Go to ACP > General > Attachment settings and adjust Total attachment quota, Maximum file size and Maximum file size messaging: Attachment settings

    Go to ACP > Posting > Manage attachment extensions, look for webp, add it if missing:
    Attachment settings

    Above does not apply to Midjourney, as all generated images are actually stored on your Discord account and served via the Discord CDN.

  • If you have extensions installed that require users to log in, such as Login Required you will need to whitelist /ailabs/* and /app.php/ailabs/* since AI Labs extension uses callbacks.

  • Adjust PHP configuration to allow longer script execution. ChatGPT API responses may take up to 90 seconds to respond in certain cases. If you have the default settings, your SQL connection will be closed after 30 seconds, preventing the extension from functioning properly.
    Suggested values for php.ini:

    max_execution_time = 180
    max_input_time = 90

Installation

Download https://github.com/privet-fun/phpbb_ailabs and copy /privet/ailabs to phppp/ext folder:
Attachment settings

If you have a previous version of this extension installed, you will need to disable it and then enable it again after the new version has been copied over.

Go to ACP > Customise > Manage extensions and enable the AI Labs extension.

Finally go to ACP > Extensions > AI Labs > Settings and add desired AI configurations: Attachment settings

Midjourney setup

  • You'll need Midjourney Discord and useapi.net accounts with active subscriptions.
    Follow instructions at https://www.useapi.net/docs/start-here to setup and verify both.

  • Create new board user who will act as AI bot, for our example we will use user Midjourney.
    Make sure this user account is activated and fully functional.

  • Got to ACP > Extensions > AI Labs > Settings and add new configuration, select midjourney from AI dropdown:
    Attachment settings

    • Use Load default configuration/template to get defaults.
      Replace Configuration JSON api-key, discord, server and channel with your values.
    • Select forums where you want Midjourney AI user to reply to new posts and/or to quoted and @mention (if you are using Simple mentions extension) posts.
  • Save changes, navigate to forum configured above and create new post (if you configured Reply on a post) or quote/@mention Midjourney user:
    Attachment settings

  • Images generated by Midjourney Discord bot via useapi.net stored and served from Discord CDN.

ChatGPT setup

  • You will need OpenAI account, sign up at https://platform.openai.com/.
    To obtain API key go to https://platform.openai.com/account/api-keys, click on Create new secret key, copy and save in a safe place generated API key.
    Open AI key starts with sk- and look something like this sk-rb5yW9j6Nm2kP3Fhe7CPzT1QczwDZ5LvnlBfYU2EoqyX1dWs.

  • Create new board user who will act as AI bot, for our example we will use user ChatGPT.
    Make sure this user account is activated and fully functional.

  • Got to ACP > Extensions > AI Labs > Settings and add new configuration, select chatgpt from AI dropdown:
    Attachment settings

    • Use Load default configuration/template to get defaults.
      Replace Configuration JSON api-key with your Open AI key.
    • Select forums where you want ChatGPT AI user to reply to new posts and/or to quoted and @mention (if you are using Simple mentions extension) posts.
  • Save changes, navigate to forum configured above and create new post (if you configured Reply on a post) or quote/@mention ChatGPT user:
    Attachment settings

  • Fine-tuning can be done by adjusting following OpenAI API chat parameters https://platform.openai.com/docs/api-reference/chat

  • Additional setting used by ChatGPT AI

    • message_tokens, default 4096, limit maximum size of the entire conversation thread
    • max_tokens, default 1024, define size reserved for AI reply when quoted
    • prefix, default empty, can be used to prompt model
    • prefix_tokens, default 0, copy above prefix to https://platform.openai.com/tokenizer to get size of your prefix in tokens and update prefix_tokens with number returned by tokenizer
    • max_quote_length, if provided, the quoted response text will be truncated to the number of words defined by the max_quote_length value. Set it to 0 to remove all quoted text entirely.

ChatGPT advanced setup

You can setup ChatGPT to pretend it is somebody else.
Let's create new board user Bender and configure as shown below:
Attachment settings
Notice we used prefix and prefix_tokens to fine-tune ChatGPT AI behavior.
Our AI bot Bender will provide responses like this, mostly staying in a character.

DALL-E setup

Setup mostly the same as for ChatGPT above:
Attachment settings

Refer to https://platform.openai.com/docs/api-reference/images/create to learn more about n and size parameters.
Examples

DALL-E advanced features

  • To generate an image of the desired size, you can specify one of the following sizes anywhere within the prompt, example:

    • 1024x1024
    • 512x512
    • 256x256
  • To create variations of the image simply post image url to the prompt, example

Stable Diffusion setup

Troubleshooting

AI Labs extension maintains internal logs, you should have admin or moderator rights to see log icon:
Attachment settings

You can see entire AI communication history in the log:
Attachment settings
If Log entry is empty it usually means that /ailabs/* or /app.php/ailabs/* routes blocked by one of phpBB extensions (eg Login Required) and you will need to add /ailabs/* or /app.php/ailabs/* to extension whitelist.
You can examine Log response (JSON) to see details for AI response.
Please feel free to post your questions or concerns at https://github.com/privet-fun/phpbb_ailabs/issues.

Support and suggestions

This extension is currently being actively developed. For communication, please use https://github.com/privet-fun/phpbb_ailabs/issues.

Changelog

  • 1.0.6 October 7, 2023

    • Minor internal changes to address phpBB extension certification
  • 1.0.5 October 1, 2023

    • Midjourney support added
    • max_quote_length option added for ChatGPT
  • 1.0.4 June 4, 2023

    • Troubleshooting section added
    • Added configuration for reply in topics
    • Fixed links generation for cases where cookies disabled
    • AI Labs internal controllers (/ailabs/*) will attempt to establish session to deal with phpBB extensions like Login Required
    • Better descriptions added to help with setup
    • Minor bugfixes
  • 1.0.3 June 1, 2023

    • bumped php requirements to >= 7.4
    • Comma removed, reported by Vlad__
  • 1.0.2 June 1, 2023

    • Only apply utf8_encode_ucr if present, reported by Vlad__
      This will allow phpBB 3.2.1 support without any modifications.
    • Removed ... and array to support php 7.x, reported by Vlad__
    • Added missing reply processing for chatgpt controller, reported by Vlad__
    • Added board prefix to all links, reported by Miri4ever
  • 1.0.1 May 29, 2023

    • Fixed issues reported by Miri4ever
    • Removed all MySQL specific SQL, going forward extension should be SQL server agnostic
    • Better language management
    • Minor code cleanup
  • 1.0.0 May 28, 2023

    • Public release

License

GPLv2