-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/phpdoc1
- Loading branch information
Showing
108 changed files
with
393 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
/* Copyright (C) 2024 MDW <[email protected]> | ||
* Copyright (C) 2024 Frédéric France <[email protected]> | ||
*/ | ||
define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); | ||
define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); | ||
|
@@ -535,7 +536,8 @@ | |
// 'PhanTypeInvalidThrowsIsInterface', | ||
// 'PhanPluginRedundantAssignmentInLoop', | ||
// 'PhanInvalidCommentForDeclarationType', | ||
//'PhanParamSignatureMismatchInternal', | ||
// 'PhanParamSignatureMismatchInternal', | ||
// 'PhanParamSignatureMismatch', | ||
// 'PhanPluginEmptyStatementForeachLoop', | ||
// 'PhanCompatibleDimAlternativeSyntax', | ||
'PhanInvalidFQSENInClasslike', | ||
|
@@ -656,5 +658,4 @@ | |
'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', | ||
'zip' => PHAN_DIR . '/stubs/zip.phan_php', | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<?php | ||
/* Copyright (C) 2024 MDW <[email protected]> | ||
* Copyright (C) 2024 Frédéric France <[email protected]> | ||
*/ | ||
|
||
// Uncomment require_once to enable corresponding fixer | ||
|
||
|
@@ -7,8 +10,6 @@ | |
//require_once __DIR__.'/plugins/UrlEncodeStringifyFixer.php'; | ||
require_once __DIR__.'/plugins/SelectDateFixer.php'; | ||
|
||
/* Copyright (C) 2024 MDW <[email protected]> | ||
*/ | ||
define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); | ||
define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); | ||
define('PHAN_DIR', __DIR__); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<?php | ||
/* Copyright (C) 2008-2011 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2005-2016 Regis Houssin <[email protected]> | ||
* Copyright (C) 2012 J. Fernando Lagrange <[email protected]> | ||
* Copyright (C) 2015 Raphaël Doursenaud <[email protected]> | ||
* Copyright (C) 2023 Eric Seigne <[email protected]> | ||
/* Copyright (C) 2024 Laurent Destailleur <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -26,7 +22,6 @@ | |
*/ | ||
class Ai | ||
{ | ||
|
||
/** | ||
* @var DoliDB $db Database object | ||
*/ | ||
|
@@ -57,13 +52,18 @@ public function __construct($db) | |
/** | ||
* Generate response of instructions | ||
* | ||
* @param string $instructions instruction for generate content | ||
* @param string $model model name ('gpt-3.5-turbo') | ||
* @param string $function code of the feature we want to use ('emailing', 'transcription', 'audiotext', 'imagegeneration', 'translation') | ||
* @param string $instructions Instruction to generate content | ||
* @param string $model Model name ('gpt-3.5-turbo', 'gpt-4-turbo', 'dall-e-3', ...) | ||
* @param string $function Code of the feature we want to use ('textgeneration', 'transcription', 'audiotext', 'imagegeneration', 'translation') | ||
* @param string $format Format for output ('', 'html', ...) | ||
* @return mixed $response | ||
*/ | ||
public function generateContent($instructions, $model = 'auto', $function = 'textgeneration') | ||
public function generateContent($instructions, $model = 'auto', $function = 'textgeneration', $format = '') | ||
{ | ||
if (empty($this->apiKey)) { | ||
return array('error' => true, 'message' => 'API key is no defined'); | ||
} | ||
|
||
if (empty($this->apiEndpoint)) { | ||
if ($function == 'textgeneration') { | ||
$this->apiEndpoint = 'https://api.openai.com/v1/chat/completions'; | ||
|
@@ -97,6 +97,8 @@ public function generateContent($instructions, $model = 'auto', $function = 'tex | |
} | ||
} | ||
|
||
dol_syslog("Call API for apiEndpoint=".$this->apiEndpoint." apiKey=".substr($this->apiKey, 0, 3).'***********, model='.$model); | ||
|
||
try { | ||
$configurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT'); | ||
$configurations = json_decode($configurationsJson, true); | ||
|
@@ -144,6 +146,11 @@ public function generateContent($instructions, $model = 'auto', $function = 'tex | |
// Extraction content | ||
$generatedEmailContent = $decodedResponse['choices'][0]['message']['content']; | ||
|
||
// If content is not HTML, we convert it into HTML | ||
if (!dol_textishtml($generatedEmailContent)) { | ||
$generatedEmailContent = dol_nl2br($generatedEmailContent); | ||
} | ||
|
||
return $generatedEmailContent; | ||
} catch (Exception $e) { | ||
return array('error' => true, 'message' => $e->getMessage()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <[email protected]> | ||
* Copyright (C) 2004-2019 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <[email protected]> | ||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> | ||
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -45,6 +45,7 @@ | |
|
||
// Security check | ||
$socid = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('socid'); | ||
/** @var User $user */ | ||
if ($user->socid > 0) { | ||
$socid = $user->socid; | ||
} | ||
|
@@ -55,7 +56,7 @@ | |
} | ||
$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); | ||
|
||
$permissiontocreate = ($user->rights->societe->creer || $user->rights->facture->creer); | ||
$permissiontocreate = ($user->hasRight('societe', 'creer') || $user->hasRight('facture', 'creer')); | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.