diff --git a/.github/docs b/.github/docs new file mode 120000 index 0000000..c05e0fa --- /dev/null +++ b/.github/docs @@ -0,0 +1 @@ +../privet/ailabs/docs \ No newline at end of file diff --git a/privet/ailabs/README.md b/privet/ailabs/README.md index cc0356a..1d2d0b2 100644 --- a/privet/ailabs/README.md +++ b/privet/ailabs/README.md @@ -1,10 +1,111 @@ -# AI Labs +# AI Labs v 1.0.0 + +Incorporate AI into your phpBB board and get ready for an exciting experience. +Currently supported ChatGPT, DALL-E (OpenAI) and Stable Diffusion (Stability AI). +Midjourney support coming soon. + +Examples: + - [ChatGPT](https://privet.fun/viewtopic.php?t=2802) + - [ChatGPT, custom prompt](https://privet.fun/viewtopic.php?t=2799) + - [DALL-E](https://privet.fun/viewtopic.php?t=2800) + - [Stable Diffusion](https://privet.fun/viewtopic.php?t=2801) + - [Midjourney](https://privet.fun/viewtopic.php?t=2718) + +## Requirements +* php >=7.1 +* phpbb >= 3.2 +* only tested with MySQL/mariadb + +## Important notes + +* Installing of [Simple mentions phpBB extension](https://www.phpbb.com/customise/db/extension/simple_mentions/) 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](./docs/attachment_settings.png) + + Go to `ACP` > `Posting` > `Manage attachment extensions`, look for `webp`, add it if missing: + ![Attachment settings](./docs/attachment_webp.png) ## Installation -Copy the extension to phpBB/ext/privet/ailabs +Download https://github.com/privet-fun/phpbb_ailabs and copy `/privet/ailabs` to `phppp/ext` folder: +![Attachment settings](./docs/ext_location.png) -Go to "ACP" > "Customise" > "Extensions" and enable the "AI Labs" extension. +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](./docs/ailabs_settings.png) + +## ChatGPT basic 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-` a 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](./docs/chatgpt_setup.png) + + - 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](https://www.phpbb.com/customise/db/extension/simple_mentions) (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](./docs/chatgpt_example.png) + +* Fine-tuning can be done by adjusting following OpenAI API chat parameters https://platform.openai.com/docs/api-reference/chat + - `model`, default `gpt-3.5-turbo`, full list of models available at https://platform.openai.com/docs/models + - `temperature`, `top_p`, `frequency_penalty` and `presence_penalty` - see https://platform.openai.com/docs/api-reference/chat/create + +* 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 + +## 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](./docs/chatgpt_bender_example.png) +Notice we used `prefix` and `prefix_tokens` to fine-tune ChatGPT AI behaviour. +Our AI bot `Bender` will provide responses like [this](https://privet.fun/viewtopic.php?t=2799), mostly staying in a character. + +## DALL-E setup + +Setup mostly the same as for ChatGPT above: +![Attachment settings](./docs/dalle_setup.png) + +Refer to https://platform.openai.com/docs/api-reference/images/create to learn more about `n` and `size` parameters. +[Examples](https://privet.fun/viewtopic.php?p=355594) + +## 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](https://privet.fun/viewtopic.php?p=355600#p355600): + - 1024x1024 + - 512x512 + - 256x256 + + * To create [variations](https://platform.openai.com/docs/api-reference/images/create-variation) of the image simply post image url to the prompt, [example](https://privet.fun/viewtopic.php?p=355596#p355596) + +## Stable Diffusion setup + +* You will need Stability AI account, follow official instructions https://platform.stability.ai/docs/getting-started/authentication to create account and obtain API key. + +* Create new board user, let's say `Stable Diffusion` and create configuration: + ![Attachment settings](./docs/stablediffusion_setup.png) + [Examples](https://privet.fun/viewtopic.php?t=2801) + +* Refer to https://api.stability.ai/docs#tag/v1generation/operation/textToImage to learn more about configuration JSON parameters. + +## Support and suggestions + +This extension is currently being actively developed. For communication, please use https://github.com/privet-fun/phpbb_ailabs/issues. ## License diff --git a/privet/ailabs/composer.json b/privet/ailabs/composer.json index 8677265..404149e 100644 --- a/privet/ailabs/composer.json +++ b/privet/ailabs/composer.json @@ -4,12 +4,18 @@ "description": "AI Labs", "homepage": "https://privet.fun", "version": "1.0.0", - "time": "2023-02-12", + "time": "2023-05-28", "keywords": [ "phpbb", "extension", + "privet", + "privet.fun", "ailabs", "chatgpt", + "dalle", + "openai", + "stable diffusion", + "midjourney", "ai" ], "license": "GPL-2.0-only", diff --git a/privet/ailabs/docs/ailabs_settings.png b/privet/ailabs/docs/ailabs_settings.png new file mode 100644 index 0000000..bd3bcd0 Binary files /dev/null and b/privet/ailabs/docs/ailabs_settings.png differ diff --git a/privet/ailabs/docs/attachment_settings.png b/privet/ailabs/docs/attachment_settings.png new file mode 100644 index 0000000..3b5f4a6 Binary files /dev/null and b/privet/ailabs/docs/attachment_settings.png differ diff --git a/privet/ailabs/docs/attachment_webp.png b/privet/ailabs/docs/attachment_webp.png new file mode 100644 index 0000000..abab2aa Binary files /dev/null and b/privet/ailabs/docs/attachment_webp.png differ diff --git a/privet/ailabs/docs/chatgpt_bender_example.png b/privet/ailabs/docs/chatgpt_bender_example.png new file mode 100644 index 0000000..a29b748 Binary files /dev/null and b/privet/ailabs/docs/chatgpt_bender_example.png differ diff --git a/privet/ailabs/docs/chatgpt_example.png b/privet/ailabs/docs/chatgpt_example.png new file mode 100644 index 0000000..1f92de5 Binary files /dev/null and b/privet/ailabs/docs/chatgpt_example.png differ diff --git a/privet/ailabs/docs/chatgpt_setup.png b/privet/ailabs/docs/chatgpt_setup.png new file mode 100644 index 0000000..d0bab3b Binary files /dev/null and b/privet/ailabs/docs/chatgpt_setup.png differ diff --git a/privet/ailabs/docs/dalle_setup.png b/privet/ailabs/docs/dalle_setup.png new file mode 100644 index 0000000..5823cd9 Binary files /dev/null and b/privet/ailabs/docs/dalle_setup.png differ diff --git a/privet/ailabs/docs/ext_location.png b/privet/ailabs/docs/ext_location.png new file mode 100644 index 0000000..d79e1ec Binary files /dev/null and b/privet/ailabs/docs/ext_location.png differ diff --git a/privet/ailabs/docs/stablediffusion_setup.png b/privet/ailabs/docs/stablediffusion_setup.png new file mode 100644 index 0000000..69f3f17 Binary files /dev/null and b/privet/ailabs/docs/stablediffusion_setup.png differ