1.0.2
This commit is contained in:
parent
d8aece5f8c
commit
1e4c06f497
7 changed files with 47 additions and 40 deletions
|
@ -1,4 +1,5 @@
|
||||||
# AI Labs v 1.0.1 RC
|
# AI Labs v 1.0.2 RC
|
||||||
|
##### [Changelog](#changelog)
|
||||||
|
|
||||||
Incorporate AI into your phpBB board and get ready for an exciting experience.
|
Incorporate AI into your phpBB board and get ready for an exciting experience.
|
||||||
Currently supported ChatGPT, DALL-E (OpenAI) and Stable Diffusion (Stability AI).
|
Currently supported ChatGPT, DALL-E (OpenAI) and Stable Diffusion (Stability AI).
|
||||||
|
@ -108,7 +109,14 @@ Refer to https://platform.openai.com/docs/api-reference/images/create to learn m
|
||||||
|
|
||||||
This extension is currently being actively developed. For communication, please use https://github.com/privet-fun/phpbb_ailabs/issues.
|
This extension is currently being actively developed. For communication, please use https://github.com/privet-fun/phpbb_ailabs/issues.
|
||||||
|
|
||||||
## Changelog
|
## <a name="changelog"></a>Changelog
|
||||||
|
|
||||||
|
* 1.0.2 June 1, 2023
|
||||||
|
- Only apply `utf8_encode_ucr` if present, reported by [Vlad__](https://www.phpbbguru.net/community/viewtopic.php?p=561158#p561158)
|
||||||
|
This will allow phpBB 3.2.1 support without any modifications.
|
||||||
|
- Removed `...` and `array` to support php 7.1, reported by [Vlad__](https://www.phpbbguru.net/community/viewtopic.php?p=561163#p561163)
|
||||||
|
- Added missing `reply` processing for chatgpt controller, reported by [Vlad__](https://www.phpbbguru.net/community/viewtopic.php?p=561205#p561205)
|
||||||
|
- Added board prefix to all links, reported by [Miri4ever](https://www.phpbb.com/community/viewtopic.php?p=15958961#p15958961)
|
||||||
|
|
||||||
* 1.0.1 May 29, 2023
|
* 1.0.1 May 29, 2023
|
||||||
- Fixed issues reported by [Miri4ever](https://www.phpbb.com/community/viewtopic.php?p=15958523#p15958523)
|
- Fixed issues reported by [Miri4ever](https://www.phpbb.com/community/viewtopic.php?p=15958523#p15958523)
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"type": "phpbb-extension",
|
"type": "phpbb-extension",
|
||||||
"description": "AI Labs",
|
"description": "AI Labs",
|
||||||
"homepage": "https://privet.fun",
|
"homepage": "https://privet.fun",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"time": "2023-05-29",
|
"time": "2023-06-01",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"phpbb",
|
"phpbb",
|
||||||
"extension",
|
"extension",
|
||||||
|
|
|
@ -90,8 +90,9 @@ class chatgpt extends AIController
|
||||||
$posts = [];
|
$posts = [];
|
||||||
$post_first_taken = null;
|
$post_first_taken = null;
|
||||||
$post_first_discarded = null;
|
$post_first_discarded = null;
|
||||||
|
$mode = $this->job['post_mode'];
|
||||||
|
|
||||||
if ($this->job['post_mode'] == 'quote') {
|
if ($mode == 'reply' || $mode == 'quote') {
|
||||||
$history = ['post_text' => $this->job['post_text']];
|
$history = ['post_text' => $this->job['post_text']];
|
||||||
|
|
||||||
$pattern = '/<QUOTE\sauthor="' . $this->job['ailabs_username'] . '"\spost_id="(.*)"\stime="(.*)"\suser_id="' . $this->job['ailabs_user_id'] . '">/';
|
$pattern = '/<QUOTE\sauthor="' . $this->job['ailabs_username'] . '"\spost_id="(.*)"\stime="(.*)"\suser_id="' . $this->job['ailabs_user_id'] . '">/';
|
||||||
|
@ -144,15 +145,11 @@ class chatgpt extends AIController
|
||||||
$post_first_taken = $postid;
|
$post_first_taken = $postid;
|
||||||
$history_tokens += $count_tokens;
|
$history_tokens += $count_tokens;
|
||||||
|
|
||||||
$post_messages = [
|
array_unshift(
|
||||||
|
$messages,
|
||||||
['role' => 'user', 'content' => trim($history['request'])],
|
['role' => 'user', 'content' => trim($history['request'])],
|
||||||
['role' => 'assistant', 'content' => trim($history['response'])],
|
['role' => 'assistant', 'content' => trim($history['response'])]
|
||||||
];
|
);
|
||||||
|
|
||||||
$messages = [
|
|
||||||
...$post_messages,
|
|
||||||
...$messages
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!empty($history));
|
} while (!empty($history));
|
||||||
|
@ -164,16 +161,13 @@ class chatgpt extends AIController
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->cfg->prefix)) {
|
if (!empty($this->cfg->prefix)) {
|
||||||
$messages = [
|
array_unshift(
|
||||||
|
$messages,
|
||||||
['role' => 'system', 'content' => $this->cfg->prefix],
|
['role' => 'system', 'content' => $this->cfg->prefix],
|
||||||
...$messages
|
);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = [
|
$messages[] = ['role' => 'user', 'content' => trim($this->job['request'])];
|
||||||
...$messages,
|
|
||||||
['role' => 'user', 'content' => trim($this->job['request'])]
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->log['request.messages'] = $messages;
|
$this->log['request.messages'] = $messages;
|
||||||
$this->log_flush();
|
$this->log_flush();
|
||||||
|
|
|
@ -18,7 +18,7 @@ class log extends AIController
|
||||||
{
|
{
|
||||||
public function view_log($post_id)
|
public function view_log($post_id)
|
||||||
{
|
{
|
||||||
if ($this->user->data['user_id'] == ANONYMOUS || $this->user->data['is_bot']) {
|
if ($this->user->data['user_id'] == ANONYMOUS || $this->user->data['is_bot'] || !$this->auth->acl_get('a_', 'm_')) {
|
||||||
throw new http_exception(401);
|
throw new http_exception(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,11 @@ class log extends AIController
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
foreach($data as &$row)
|
foreach ($data as &$row) {
|
||||||
{
|
$row['poster_user_url'] = generate_board_url() . '/' . append_sid("memberlist.$this->php_ext", 'mode=viewprofile&u=' . $row['poster_id'], true, '');
|
||||||
$row['poster_user_url'] = '/' . append_sid("memberlist.$this->php_ext", 'mode=viewprofile&u=' . $row['poster_id'], true, '');
|
$row['ailabs_user_url'] = generate_board_url() . '/' . append_sid("memberlist.$this->php_ext", 'mode=viewprofile&u=' . $row['ailabs_user_id'], true, '');
|
||||||
$row['ailabs_user_url'] = '/' . append_sid("memberlist.$this->php_ext", 'mode=viewprofile&u=' . $row['ailabs_user_id'], true, '');
|
|
||||||
if (!empty($row['response_post_id'])) {
|
if (!empty($row['response_post_id'])) {
|
||||||
$row['response_url'] = '/viewtopic.php?p=' . $row['response_post_id'] . '#p' . $row['response_post_id'];
|
$row['response_url'] = generate_board_url() . '/' . append_sid('viewtopic.php?p=' . $row['response_post_id'] . '#p' . $row['response_post_id'], true, '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,12 @@ class listener implements EventSubscriberInterface
|
||||||
// Remove leading and trailing spaces as well as all doublespaces
|
// Remove leading and trailing spaces as well as all doublespaces
|
||||||
$request = trim(str_replace(' ', ' ', $request));
|
$request = trim(str_replace(' ', ' ', $request));
|
||||||
|
|
||||||
|
// utf8_encode_ucr added in phpBB v3.2.7
|
||||||
|
// See comments at http://area51.phpbb.com/code-changes/3.2.7/side-by-side/3.2.11/phpbb-includes-utf-utf_tools.php.html
|
||||||
|
if (function_exists('utf8_encode_ucr')) {
|
||||||
|
$request = utf8_encode_ucr($request);
|
||||||
|
}
|
||||||
|
|
||||||
// https://area51.phpbb.com/docs/dev/master/db/dbal.html
|
// https://area51.phpbb.com/docs/dev/master/db/dbal.html
|
||||||
foreach ($ailabs_users as $user) {
|
foreach ($ailabs_users as $user) {
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -306,9 +312,9 @@ class listener implements EventSubscriberInterface
|
||||||
$ailabs = array();
|
$ailabs = array();
|
||||||
|
|
||||||
foreach ($jobs as $key => $value) {
|
foreach ($jobs as $key => $value) {
|
||||||
$value->user_url = '/' . append_sid("memberlist.$this->php_ext", 'mode=viewprofile&u=' . $value->ailabs_user_id, true, '');
|
$value->user_url = generate_board_url() . '/' . append_sid("memberlist.$this->php_ext", 'mode=viewprofile&u=' . $value->ailabs_user_id, true, '');
|
||||||
if (!empty($value->response_post_id)) {
|
if (!empty($value->response_post_id)) {
|
||||||
$value->response_url = '/viewtopic.php?p=' . $value->response_post_id . '#p' . $value->response_post_id;
|
$value->response_url = generate_board_url() . '/' . append_sid('viewtopic.php?p=' . $value->response_post_id . '#p' . $value->response_post_id, true, '');
|
||||||
}
|
}
|
||||||
$value->status = $this->get_status(empty($value->status) ? null : $value->status);
|
$value->status = $this->get_status(empty($value->status) ? null : $value->status);
|
||||||
array_push($ailabs, $value);
|
array_push($ailabs, $value);
|
||||||
|
|
|
@ -13,15 +13,15 @@ namespace privet\ailabs\includes;
|
||||||
|
|
||||||
class GenericCurl
|
class GenericCurl
|
||||||
{
|
{
|
||||||
private array $headers;
|
private $headers;
|
||||||
private array $contentTypes;
|
private $contentTypes;
|
||||||
private int $timeout = 0;
|
private int $timeout = 0;
|
||||||
private object $stream_method;
|
private object $stream_method;
|
||||||
private string $proxy = "";
|
private string $proxy = "";
|
||||||
private array $curlInfo = [];
|
private $curlInfo = [];
|
||||||
public int $retryCount;
|
public int $retryCount;
|
||||||
public int $timeoutBeforeRetrySec;
|
public int $timeoutBeforeRetrySec;
|
||||||
public array $responseCodes = [];
|
public $responseCodes = [];
|
||||||
|
|
||||||
public function __construct($API_KEY, $retryCount = 3, $timeoutBeforeRetrySec = 10)
|
public function __construct($API_KEY, $retryCount = 3, $timeoutBeforeRetrySec = 10)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ class GenericCurl
|
||||||
* @param array $header
|
* @param array $header
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setHeader(array $header)
|
public function setHeader($header)
|
||||||
{
|
{
|
||||||
if ($header) {
|
if ($header) {
|
||||||
foreach ($header as $key => $value) {
|
foreach ($header as $key => $value) {
|
||||||
|
@ -86,7 +86,7 @@ class GenericCurl
|
||||||
* @param array $opts
|
* @param array $opts
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public function sendRequest(string $url, string $method, array $opts = [])
|
public function sendRequest(string $url, string $method, $opts = [])
|
||||||
{
|
{
|
||||||
$this->responseCodes = [];
|
$this->responseCodes = [];
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,5 @@ namespace privet\ailabs\includes;
|
||||||
class resultSubmit
|
class resultSubmit
|
||||||
{
|
{
|
||||||
public string $response;
|
public string $response;
|
||||||
public array $responseCodes;
|
public $responseCodes;
|
||||||
};
|
};
|
Loading…
Reference in a new issue