diff --git a/ProcessMaker/Ai/Handlers/LanguageTranslationHandler.php b/ProcessMaker/Ai/Handlers/LanguageTranslationHandler.php index fda05562ff..c76af32094 100644 --- a/ProcessMaker/Ai/Handlers/LanguageTranslationHandler.php +++ b/ProcessMaker/Ai/Handlers/LanguageTranslationHandler.php @@ -39,6 +39,11 @@ public function setProcessId($processId) $this->processId = $processId; } + public function getPromptsPath() + { + return app_path() . '/Ai/Prompts/'; + } + public function getPromptFile($type = null) { return file_get_contents($this->getPromptsPath() . 'language_translation_' . $type . '.md'); diff --git a/ProcessMaker/Ai/Handlers/NlqToCategoryHandler.php b/ProcessMaker/Ai/Handlers/NlqToCategoryHandler.php deleted file mode 100644 index c89c17d1dd..0000000000 --- a/ProcessMaker/Ai/Handlers/NlqToCategoryHandler.php +++ /dev/null @@ -1,87 +0,0 @@ -config = [ - 'model' => 'text-davinci-003', - 'max_tokens' => 20, - 'temperature' => 0, - 'top_p' => 1, - 'n' => 1, - 'frequency_penalty' => 0, - 'presence_penalty' => 0, - 'stop' => 'END_', - ]; - } - - public function getPromptFile($type = null) - { - return file_get_contents($this->getPromptsPath() . 'nlq_to_category.md'); - } - - public function generatePrompt(String $type = null, String $question) : Object - { - $this->question = $question; - $prompt = $this->getPromptFile($type); - $prompt = $this->replaceQuestion($prompt, $question); - $prompt = $this->replaceStopSequence($prompt); - $prompt = $this->replaceDefaultType($prompt, $type); - - $this->config['prompt'] = $prompt; - - return $this; - } - - public function execute() - { - $client = app(Client::class); - $response = $client - ->completions() - ->create(array_merge($this->getConfig())); - - return $this->formatResponse($response); - } - - private function formatResponse($response) - { - $result = ltrim($response->choices[0]->text); - - return [strtolower($result), $response->usage, $this->question]; - } - - public function replaceStopSequence($prompt) - { - $replaced = str_replace('{stopSequence}', $this->config['stop'] . " \n", $prompt); - - return $replaced; - } - - public function replaceQuestion($prompt, $question) - { - $replaced = str_replace('{question}', $question . " \n", $prompt); - - return $replaced; - } - - public function replaceWithCurrentYear($prompt) - { - $currentYearReplaced = str_replace('{currentYear}', date('Y'), $prompt); - $pastYearReplaced = str_replace('{pastYear}', date('Y') - 1, $currentYearReplaced); - - return $pastYearReplaced; - } - - public function replaceDefaultType($prompt, $type) - { - $replaced = str_replace('{type}', $type, $prompt); - - return $replaced; - } -} diff --git a/ProcessMaker/Ai/Handlers/NlqToPmqlHandler.php b/ProcessMaker/Ai/Handlers/NlqToPmqlHandler.php deleted file mode 100644 index 81d43b4dc3..0000000000 --- a/ProcessMaker/Ai/Handlers/NlqToPmqlHandler.php +++ /dev/null @@ -1,83 +0,0 @@ -config = [ - 'model' => 'text-davinci-003', - 'max_tokens' => 1900, - 'temperature' => 0, - 'top_p' => 1, - 'n' => 1, - 'frequency_penalty' => 0, - 'presence_penalty' => 0, - 'stop' => 'END_', - ]; - } - - public function getPromptFile($type = null) - { - return file_get_contents($this->getPromptsPath() . 'nlq_to_pmql_' . $type . '.md'); - } - - public function generatePrompt(String $type = null, String $question) : Object - { - $this->question = $question; - $prompt = $this->getPromptFile($type); - $prompt = $this->replaceQuestion($prompt, $question); - $prompt = $this->replaceStopSequence($prompt); - $prompt = $this->replaceWithCurrentYear($prompt); - - $this->config['prompt'] = $prompt; - - return $this; - } - - public function execute() - { - $client = app(Client::class); - $response = $client - ->completions() - ->create(array_merge($this->getConfig())); - - return $this->formatResponse($response); - } - - private function formatResponse($response) - { - $result = ltrim($response->choices[0]->text); - $result = explode('Question:', $result)[0]; - $result = rtrim(rtrim(str_replace("\n", '', $result))); - $result = str_replace('\'', '', $result); - - return [$result, $response->usage, $this->question]; - } - - public function replaceStopSequence($prompt) - { - $replaced = str_replace('{stopSequence}', $this->config['stop'] . " \n", $prompt); - - return $replaced; - } - - public function replaceQuestion($prompt, $question) - { - $replaced = str_replace('{question}', $question . " \n", $prompt); - - return $replaced; - } - - public function replaceWithCurrentYear($prompt) - { - $currentYearReplaced = str_replace('{currentYear}', date('Y'), $prompt); - $pastYearReplaced = str_replace('{pastYear}', date('Y') - 1, $currentYearReplaced); - - return $pastYearReplaced; - } -} diff --git a/ProcessMaker/Ai/Handlers/OpenAiHandler.php b/ProcessMaker/Ai/Handlers/OpenAiHandler.php index d7dea95e2c..876f9c6fac 100644 --- a/ProcessMaker/Ai/Handlers/OpenAiHandler.php +++ b/ProcessMaker/Ai/Handlers/OpenAiHandler.php @@ -15,14 +15,14 @@ public function __construct() { } - public function getPromptsPath() + public function getConfig() { - return app_path() . '/Ai/Prompts/'; + return $this->config; } - public function getConfig() + public function getQuestion() { - return $this->config; + return $this->question; } public function setModel(String $model) @@ -65,16 +65,6 @@ public function setPresencePenalty(float $presencePenalty) $this->config['presence_penalty'] = $presencePenalty; } - public function saveResponse(string $type, string $response) - { - $aiSearch = new AiSearch(); - $aiSearch->type = $type; - $aiSearch->search = $this->question; - $aiSearch->response = $response; - $aiSearch->user_id = \Auth::user()->id; - $aiSearch->save(); - } - abstract public function getPromptFile($type = null); abstract public function generatePrompt(String $type = null, String $description); diff --git a/ProcessMaker/Ai/Prompts/nlq_to_category.md b/ProcessMaker/Ai/Prompts/nlq_to_category.md deleted file mode 100644 index 9d92a27166..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_category.md +++ /dev/null @@ -1,16 +0,0 @@ -You are a classification AI that can return one of the following categories in lower case. If can't fit in some of the following 4 categories please return {type}: -requests, tasks, collections, processes. - -I will feed you with some examples and you are going to return a category according with the list below. - -Examples: -Question: Show me all the requests that are greater than 1 -Response: requests -Question: Show the tasks assigned to me -Response: tasks -Question: Return the last processes that starts with P -Response: processes -Question: Return all the collections where age greater than 30 -Response: collections -Question: {question} -Response: {stopSequence} \ No newline at end of file diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_collections.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_collections.md deleted file mode 100644 index ee10914659..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_collections.md +++ /dev/null @@ -1,91 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find collection records information. -## -Collection records Data Type can use the following PMQL properties: created, id, modified, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -Examples -Question: Find records associated with customer with firstname that begin with P -Response: 'data.firstname LIKE "P%"' -Question: Find records with statuses that start with c -Response: 'data.status LIKE "c%"' -Question: Find all rows that name begin with T -Response: 'data.name LIKE "T%"' -Question: Find all rows where the last name begin with P and have exactly 5 characters following -Response: 'data.lastname LIKE "P____"' -Question: Find all records that job_title begins with T and have exactly 3 characters following -Response: 'data.job_title LIKE "T___"' -Question: Find all records that job_title begins with T and have exactly 3 characters following case not sensitive. -Response: 'lower(data.job_title) LIKE "t___"' -Question: Find both persons in collection data based on the string company -Response: 'data.Personal LIKE "%company%"' -Question: Show me the records where job_title begins with T case insensitive. -Response: 'lower(data.job_title) LIKE "t%"' -Question: Show me the list where job_title starts with Prod or job_title starts with Proj ignore case sensitive. -Response: 'lower(data.job_title) LIKE "prod%" OR lower(data.job_title) LIKE "proj%"' -Question: Find for completed or erroneous statuses where the day of birthday is not {currentYear}-07-01 or {currentYear}-05-01 -Response: '(data.status IN ["Completed", "Error"]) AND data.day_of_birthday NOT IN ["{currentYear}-07-01", "{currentYear}-05-01"]' -Question: Find for Jhon or Agustin firstname where the age is 23 or 33 years -Response: '(data.firstname IN ["Jhon", "Agustin"]) AND (data.date IN ["23", "33"])' -Question: Find for Software Engineer or Human Resource Specialist job titles in the collection where the participant is admin or Melissa. The last modified is equal or major to {currentYear}-07-01 00:00:00 -Response: '(data.participant IN ["admin", "Melissa"]) AND (data.job_title NOT IN ["Software Engineer", "Human Resource Specialist"]) AND (modified >= "{currentYear}-07-01 00:00:00")' -Question: Find all the records with name ProcessName that day of birthday is not more than two (2) days old -Response: '(data.day_of_birthday > NOW -2 day) AND (data.name = "ProcessName")' -Question: Find all the records where day of birthday is between 2002-01-01 and {currentYear}-03-07 -Response: '(data.day_of_birthday >= 2002-01-01) AND (data.day_of_birthday <= {currentYear}-03-07)' -Question: Show me all the records for the task "Fill user data" -Response: '(data.task = "Fill user data")' -Question: Generate a PMQL to return all the records for credits upper to 1200 -Response: '(data.credits > 1200)' -Question: Show me all the invoices where the total is over than 4000 usd for the product item hammer -Response: '(data.total > 4000) AND (data.item.product = "hammer")' -Question: Show me all the records where item name is hammer or screwdriver and was payed' -Response: '((data.item.name = "hammer") OR (data.item.name = "screwdriver")) AND (data.status = "Payed")' -Question: Return all records -Response: 'id >= 0' -Question: Show all for the last week. -Response: 'modified > NOW -7 day' -Question: Show all for the last 2 weeks. -Response: 'modified > NOW -14 day' -Question: Show all for the last month. -Response: 'modified > NOW -30 day' -Question: Show all for the last 2 months. -Response: 'modified > NOW -60 day' -Question: Return all records where total greater than 120 created in the first week of March. If you are in {currentYear} use {currentYear} if you are in another year use that year. -Response: '(data.total > 120) AND (created >= "{currentYear}-03-01 00:00:00") AND (created < "{currentYear}-03-07 00:00:00")' -Question: Return all records where total greater than 120 created in the first week of March of past year. -Response: '(data.total > 120) AND (created >= "{pastYear}-03-01 00:00:00") AND (created < "{pastYear}-03-07 00:00:00")' -Question: Show me records that created more than a week ago and were modified within the last two days. -Response: '(created >= NOW -7 day) AND (modified <= NOW -2 day)' -Question: Jhon -Response: '(fulltext LIKE "%Jhon%")' -Question: Mc Callister -Response: '(fulltext LIKE "%Mc Callister%")' -Question: 3 -Response: '(fulltext LIKE "%3%")' -Question: 51 -Response: '(fulltext LIKE "%51%")' -Question: 31 years -Response: '(fulltext LIKE "%31 years%")' -Question: Employee -Response: '(fulltext LIKE "%Employee%")' -Question: show me all where firstname is Jhon -Response: 'data.firstname = "Jhon"' -Question: Show me all where firstname starts with Jhon for the collection persons -Response: ' -{ - "pmql": "(data.firstname LIKE \"Jhon%\")", - "collectionName": "persons" -} -' -Question: {currentYear}-09-03 -Response: '(fulltext LIKE "%{currentYear}-09-03%")'{stopSequence} -Question: {question} -{stopSequence} -Response: \ No newline at end of file diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_collections_w_mustaches.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_collections_w_mustaches.md deleted file mode 100644 index b9c7c37baa..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_collections_w_mustaches.md +++ /dev/null @@ -1,99 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find collection records information. -## -Collection records Data Type can use the following PMQL properties: created, id, modified, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -Examples -Question: Show records where "country" is equal to selectlist "selectedCountry" -Response: 'data.country = "{{ selectedCountry }}"' -Question: Show records where "country" is equal to select list "selectedCountry" -Response: 'data.country = "{{ selectedCountry }}"' -Question: Show records where "country" is equal to variable "selectedCountry" -Response: 'data.country = "{{ selectedCountry }}"' -Question: Show all where "league" is "selectedLeague" variable and "state" is "state" variable -Response: 'data.league = "{{ selectedLeague }}" AND data.state = "{{ state }}"' -Question: Find records associated with customer with firstname that begin with P -Response: 'data.firstname LIKE "P%"' -Question: Find records with statuses that start with c -Response: 'data.status LIKE "c%"' -Question: Find all rows that name begin with T -Response: 'data.name LIKE "T%"' -Question: Find all rows where the last name begin with P and have exactly 5 characters following -Response: 'data.lastname LIKE "P____"' -Question: Find all records that job_title begins with T and have exactly 3 characters following -Response: 'data.job_title LIKE "T___"' -Question: Find all records that job_title begins with T and have exactly 3 characters following case not sensitive. -Response: 'lower(data.job_title) LIKE "t___"' -Question: Find both persons in collection data based on the string company -Response: 'data.Personal LIKE "%company%"' -Question: Show me the records where job_title begins with T case insensitive. -Response: 'lower(data.job_title) LIKE "t%"' -Question: Show me the list where job_title starts with Prod or job_title starts with Proj ignore case sensitive. -Response: 'lower(data.job_title) LIKE "prod%" OR lower(data.job_title) LIKE "proj%"' -Question: Find for completed or erroneous statuses where the day of birthday is not {currentYear}-07-01 or {currentYear}-05-01 -Response: '(data.status IN ["Completed", "Error"]) AND data.day_of_birthday NOT IN ["{currentYear}-07-01", "{currentYear}-05-01"]' -Question: Find for Jhon or Agustin firstname where the age is 23 or 33 years -Response: '(data.firstname IN ["Jhon", "Agustin"]) AND (data.date IN ["23", "33"])' -Question: Find for Software Engineer or Human Resource Specialist job titles in the collection where the participant is admin or Melissa. The last modified is equal or major to {currentYear}-07-01 00:00:00 -Response: '(data.participant IN ["admin", "Melissa"]) AND (data.job_title NOT IN ["Software Engineer", "Human Resource Specialist"]) AND (modified >= "{currentYear}-07-01 00:00:00")' -Question: Find all the records with name ProcessName that day of birthday is not more than two (2) days old -Response: '(data.day_of_birthday > NOW -2 day) AND (data.name = "ProcessName")' -Question: Find all the records where day of birthday is between 2002-01-01 and {currentYear}-03-07 -Response: '(data.day_of_birthday >= 2002-01-01) AND (data.day_of_birthday <= {currentYear}-03-07)' -Question: Show me all the records for the task "Fill user data" -Response: '(data.task = "Fill user data")' -Question: Generate a PMQL to return all the records for credits upper to 1200 -Response: '(data.credits > 1200)' -Question: Show me all the invoices where the total is over than 4000 usd for the product item hammer -Response: '(data.total > 4000) AND (data.item.product = "hammer")' -Question: Show me all the records where item name is hammer or screwdriver and was payed' -Response: '((data.item.name = "hammer") OR (data.item.name = "screwdriver")) AND (data.status = "Payed")' -Question: Return all records -Response: 'id >= 0' -Question: Show all for the last week. -Response: 'modified > NOW -7 day' -Question: Show all for the last 2 weeks. -Response: 'modified > NOW -14 day' -Question: Show all for the last month. -Response: 'modified > NOW -30 day' -Question: Show all for the last 2 months. -Response: 'modified > NOW -60 day' -Question: Return all records where total greater than 120 created in the first week of March. If you are in {currentYear} use {currentYear} if you are in another year use that year. -Response: '(data.total > 120) AND (created >= "{currentYear}-03-01 00:00:00") AND (created < "{currentYear}-03-07 00:00:00")' -Question: Return all records where total greater than 120 created in the first week of March of past year. -Response: '(data.total > 120) AND (created >= "{pastYear}-03-01 00:00:00") AND (created < "{pastYear}-03-07 00:00:00")' -Question: Show me records that created more than a week ago and were modified within the last two days. -Response: '(created >= NOW -7 day) AND (modified <= NOW -2 day)' -Question: Jhon -Response: '(fulltext LIKE "%Jhon%")' -Question: Mc Callister -Response: '(fulltext LIKE "%Mc Callister%")' -Question: 3 -Response: '(fulltext LIKE "%3%")' -Question: 51 -Response: '(fulltext LIKE "%51%")' -Question: 31 years -Response: '(fulltext LIKE "%31 years%")' -Question: Employee -Response: '(fulltext LIKE "%Employee%")' -Question: show me all where firstname is Jhon -Response: 'data.firstname = "Jhon"' -Question: Show me all where firstname starts with Jhon for the collection persons -Response: ' -{ - "pmql": "(data.firstname LIKE \"Jhon%\")", - "collectionName": "persons" -} -' -Question: {currentYear}-09-03 -Response: '(fulltext LIKE "%{currentYear}-09-03%")'{stopSequence} -Question: {question} -{stopSequence} -Response: \ No newline at end of file diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_processes.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_processes.md deleted file mode 100644 index 187e85dd77..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_processes.md +++ /dev/null @@ -1,54 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find Processes information. -## -Request Data Type can use the following PMQL properties: process, name, status, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -Examples -Question: Show me all the process. -Response: 'id > 0' -Question: Show me the process Leave of absence. -Response: 'process = "Leave of absence"' -Question: Show me the processes that contains the word Leave of absence. -Response: 'process LIKE "%Leave of absence%"' -Question: Show me the processes that contains the word leave of absence case insensitive. -Response: 'lower(process)LIKE "%leave of absence%"' -Question: Show me the processes where name starts with proc or name starts with form ignore case sensitive. -Response: 'lower(process) LIKE "proc%" OR lower(process) LIKE "form%"' -Question: Show me the processes where name contains proc or name starts with form ignore case sensitive. -Response: 'lower(process) LIKE "%proc%" OR lower(process) LIKE "form%"' -Question: Find processes that begin with P -Response: 'process LIKE "P%"' -Question: Find processes where status is active -Response: 'status = "ACTIVE"' -Question: Find active processes -Response: 'status = "ACTIVE"' -Question: Find inactive processes -Response: 'status = "ARCHIVED"' -Question: Find all processes where begin with A and have exactly 5 characters following' -Response: 'process LIKE "A____"' -Question: Find processes that begin with T and have exactly 3 characters following' -Response: 'process LIKE "T___"' -Question: 'Find for active processes where the name is form or my process -Response: '(status = ACTIVE") AND (process IN ["form", "my process"]) -Question: Jhon -Response: '(fulltext LIKE "%Jhon%")' -Question: My test process -Response: '(fulltext LIKE "%My test process%")' -Question: Completed -Response: '(fulltext LIKE "%Completed%")' -Question: 56 -Response: '(fulltext LIKE "%56%")' -Question: 188 -Response: '(fulltext LIKE "%188%")' -Question: Leave of absence -Response: '(fulltext LIKE "%Leave of absence%")'{stopSequence} -Question: {question} -{stopSequence} -Response: diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_requests.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_requests.md deleted file mode 100644 index 705ec4669d..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_requests.md +++ /dev/null @@ -1,90 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find Requests information. -## -Request Data Type can use the following PMQL properties: completed, created, id, modified, participant, request, requester, started, status, process_id, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -Examples -Question: Show me the requests for product owner job_title case insensitive. -Response: 'lower(data.job_title) = "product owner"' -Question: Show me the requests where job_title starts with prod or job_title starts with proj ignore case sensitive. -Response: 'lower(data.job_title) LIKE "prod%" OR lower(data.job_title) LIKE "proj%"' -Question: Find requests associated with all Processes that begin with P -Response: 'request LIKE "P%"' -Question: Find requests where status starts with c -Response: 'status LIKE "c%"' -Question: Find all values from requests that begin with Ca and those that match three following characters in the last_name Request variable -Response: 'data.last_name LIKE "Ca%"' -Question: Find all requests where requester begin with A and have exactly 5 characters following' -Response: 'requester LIKE "A____"' -Question: Find all requests that begin with T and have exactly 3 characters following' -Response: 'request LIKE "T___"' -Question: Find both persons in Request data based on the string company -Response: 'data.Personal LIKE "%company%"' -Question: Find for completed or erroneous Tasks where the Request Date is not {currentYear}-07-01 or {currentYear}-05-01 -Response: '(status IN ["Completed", "Error"]) AND data.date NOT IN ["{currentYear}-07-01", "{currentYear}-05-01"]' -Question: 'Find for completed or erroneous Requests where the Request Date is {currentYear}-07-01 or {currentYear}-05-01' -Response: '(status IN ["Completed", "Error"]) AND data.date IN ["{currentYear}-07-01", "{currentYear}-05-01"]' -Question: Find for completed or in progress Requests where the participant is admin or Melissa. The last modified is equal or major to {currentYear}-07-01 00:00:00 -Response: 'participant IN ["admin", "Melissa"] AND status NOT IN ["Completed", "In Progress"] AND modified >= "{currentYear}-07-01 00:00:00"' -Question: Find Requests for ProcessName that are not more than two (2) days old -Response: '(modified > NOW -2 day) AND (request = "ProcessName")' -Question: Show all the requests for ProcessName -Response: '(request = "ProcessName")' -Question: Show all the requests for Leave of absence -Response: '(request = "Leave of absence")' -Question: Show all the requests for the process Leave of absence -Response: '(request = "Leave of absence")' -Question: Find Requests from ProcessName in which its Request participants are 25 years old or younger by only having their date of birth in a Request variable called DOB. Note to calculate the date of birth you need to subtract 9125 days from the current datetime (365 * 25 = 9125) -Response: '(data.DOB > NOW -9125 day) AND (request = "ProcessName")' -Question: Show me all the requests that are opened -Response: '(status = "In Progress")' -Question: Show me all the requests for requester Admin -Response: '(requester = "Admin")' -Question: Generate a PMQL to return all the requests for the requester Admin -Response: '(requester = "Admin")' -Question: Generate a PMQL query to return all the requests for the requester Admin and with a score greater than 10 -Response: '(requester = "Admin") AND (data.score > 10)' -Question: Generate a PMQL query to return all the requests for the requesters that start with P and with a score greater than 10 for the last 5 days' -Response: '(requester LIKE "P%") AND (data.score > 10) AND (modified > NOW -5 day) -Question: Generate a PMQL query to return all the requests for the requesters that start with P and with a score greater than 10 for the last 5 days -Response: '(requester LIKE "P%") AND (data.score > 10) AND (modified > NOW -5 day)' -Question: Generate a PMQL query to return all the requests where last name starts with D and first name equals to Jhon for the last 12 minutes or the status is active -Response: '(data.last_name LIKE "D%") AND (data.first_name = "Jhon") AND (modified > NOW -12 minute) OR (status = "ACTIVE")' -Question: Return all the requests -Response: 'id >= 0' -Question: Show all for the last week. -Response: 'modified > NOW -7 day' -Question: Show all for the last 2 weeks. -Response: 'modified > NOW -14 day' -Question: Show all for the last month. -Response: 'modified > NOW -30 day' -Question: Show all for the last 2 months. -Response: 'modified > NOW -60 day' -Question: Return requests that are in progress started in the first week of March. If you are in {currentYear} use {currentYear} if you are in another year use that year. -Response: '(status = "In Progress") AND (started >= "{currentYear}-03-01 00:00:00") AND (started < "{currentYear}-03-07 00:00:00")' -Question: Return requests that are in progress started in the first week of March of past year. -Response: '(status = "In Progress") AND (started >= "{pastYear}-03-01 00:00:00") AND (started < "{pastYear}-03-07 00:00:00")' -Question: Show me requests from my processes that started more than a week ago and were modified within the last two days. -Response: '(started >= NOW -7 day) AND (modified <= NOW -2 day)' -Question: Jhon -Response: '(fulltext LIKE "%Jhon%")' -Question: My test process -Response: '(fulltext LIKE "%My test process%")' -Question: Completed -Response: '(fulltext LIKE "%Completed%")' -Question: 56 -Response: '(fulltext LIKE "%56%")' -Question: 188 -Response: '(fulltext LIKE "%188%")' -Question: Leave of absence -Response: '(fulltext LIKE "%Leave of absence%")'{stopSequence} -Question: {question} -{stopSequence} -Response: diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_security_logs.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_security_logs.md deleted file mode 100644 index 985fada852..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_security_logs.md +++ /dev/null @@ -1,109 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find security logs information. -## -Security Logs Data Type can use the following PMQL properties: event, ip, meta, user_id, ocurred_at, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -Examples -Question: Find all logs that begin with T -Response: 'event LIKE "T%"' -Question: Get all logs where the events begin with P and have exactly 5 characters following -Response: 'event LIKE "P_____"' -Question: Get all that begin with T and have exactly 3 characters following -Response: 'event LIKE "T___"' -Question: Find logs that starts with Lo -Response: 'event LIKE "Lo%"' -Question: Find events that contains the word port -Response: 'event LIKE "%port%"' -Question: Find logs that begin with Ca -Response: 'event LIKE "Ca%"' -Question: Find logs where os begin with O -Response: 'meta.os.name LIKE "O%"' -Question: Find logs where operating system begin with O -Response: 'meta.os.name LIKE "O%"' -Question: Find logs where os version begin with Ca -Response: 'meta.os.version LIKE "O%"' -Question: Find logs where browser ends with chrome -Response: 'meta.browser.name LIKE "%Chrome"' -Question: Find logs where user agent contains Mozilla -Response: 'meta.user_agent LIKE "%Mozilla%"' -Question: Find all logs that ip begins with 194.0 and have exactly 6 characters following -Response: 'ip LIKE "194.0______"' -Question: Find all logs that ip ends with .244 and have exactly 11 characters' -Response: 'ip LIKE "_______.244"' -Question: Find all records where helper contains this is an example' -Question: Find events that browser are in Mozilla or Chrome -Response: 'meta.browser.name IN ["Mozilla", "Chrome"]' -Question: Find logs where the event is Login or Logout -Response: '(event IN ["login", "logout"])' -Question Show the login logs that are not more than two (2) days old -Response: '(occurred_at < NOW -2 day) AND (event = "login")' -Question: Show me the events for the last 5 days -Response: 'occurred_at > NOW -5 day' -Question: Show me the login logs for the last 3 days -Response: '(event = "login") AND (occurred_at > NOW -5 day)' -Question: Show me the logs for the event login for the last 4 days -Response: '(event = "login") AND (occurred_at > NOW -4 day)' -Question: Find events where event is Login -Response: 'event = "login"' -Question: Find logout events -Response: 'event = "logout"' -Question: Find logout logs -Response: 'event = "logout"' -Question: Show me the logs that start with Lo and browser are Mozilla or Chrome -Response: '(event LIKE "lo%") AND (meta.browser.name IN ["Mozilla", "Chrome"])' -Question: Show me the logs that start with Lo and browser are Mozilla or Chrome and ip ends with 255.12 -Response: '(event LIKE "lo%") AND (meta.browser.name IN ["Mozilla", "Chrome"]) AND (ip LIKE "%255.12")' -Question: Show me the logs for ip 127.0.0.1 -Response: 'ip = "127.0.0.1"' -Question: Show me the logs for Windows os -Response: 'meta.os.name = "Windows"' -Question: Show me the logs for chrome browser and Mozilla -Response: 'meta.browser.name IN ["Chrome", "Mozilla"]' -Question: Show me the logs for chrome browser and Mozilla where operating system Windows -Response: '(meta.browser.name IN ["Chrome", "Mozilla"]) AND (meta.os.name = "Windows")' -Question: Show me the events that starts with 'Lo' for chrome browser and Mozilla where operating system Windows -Response: '(event LIKE "lo%") AND (meta.browser.name IN ["Chrome", "Mozilla"]) AND (meta.os.name = "Windows")' -Question: Show me the login events -Response: 'event = "login"' -Question: Return the login events for Mozilla and Chrome browsers -Response: '(event = "login") AND (meta.browser.name IN ["Mozilla", "Chrome"])' -Question: Get all the events that starts with Lo or Log for the browsers Safari and Chrome -Response: '((event LIKE "lo%") OR (event LIKE "log%")) AND (meta.browser.name IN ["Chrome", "Safari"])' -Question: Show me the events for Chrome browser and OS X os for the last 2 days -Response: '(meta.browser.name = "Chrome") AND (meta.os.name = "OS X") AND (occurred_at > NOW -2 day)' -Question: Show all for the last week. -Response: 'occurred_at > NOW -7 day' -Question: Show all for the last 2 weeks. -Response: 'occurred_at > NOW -14 day' -Question: Show all for the last month. -Response: 'occurred_at > NOW -30 day' -Question: Show all for the last 2 months. -Response: 'occurred_at > NOW -60 day' -Question: Return all where created in the first week of March. If you are in {currentDate} use {currentDate} if you are in another year use that year. -Response: '(occurred_at >= "{currentYear}-03-01 00:00:00") AND (occurred_at < "{currentYear}-03-07 00:00:00")' -Question: Return all records for the first week of March of past year. -Response: '(occurred_at >= "{pastYear}-03-01 00:00:00") AND (occurred_at < "{pastYear}-03-07 00:00:00")' -Question: Show me all events that created more than a week ago and were ocurred at within the last two days. -Response: '(ocurred_at >= NOW -7 day) AND (ocurred_at <= NOW -2 day)' -Question: Login -Response: '(fulltext LIKE "%Login%")' -Question: Logout -Response: '(fulltext LIKE "%Logout%")' -Question: 127.0.0.1 -Response: '(fulltext LIKE "%127.0.0.1%")' -Question: Chrome -Response: '(fulltext LIKE "%Chrome%")' -Question: OS X -Response: '(fulltext LIKE "%OS X%")' -Question: SSL Certificate -Response: '(fulltext LIKE "%SSL Certificate%")'{stopSequence} -Question: {question} -{stopSequence} -Response: \ No newline at end of file diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_settings.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_settings.md deleted file mode 100644 index 9dae63320e..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_settings.md +++ /dev/null @@ -1,61 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find settings information. -## -Settings Data Type can use the following PMQL properties: event, ip, meta, user_id, ocurred_at, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -If I ask to 'find settings that start with...' or 'show settings for...' you should use the column name by default. -## -## -Examples -Question: Find settings that starts with IMAP -Response: 'name LIKE "IMAP%"' -Question: Find settings that helper contains the word port -Response: 'helper LIKE "%port%"' -Question: Find setting that begin with Ca and those that match three following characters -Response: 'name LIKE "Ca%"' -Question: Find all settings that ends with port -Response: 'name LIKE "%port"' -Question: Find all settings that config contains google -Response: 'config LIKE "%google%"' -Question: Find all settings where the name begins with P and have exactly 5 characters -Response: 'name LIKE "P____"' -Question: Find all settings that helper begins with T and have exactly 3 characters following -Response: 'helper LIKE "T___"' -Question: Find settings that config are in port or server -Response: 'config IN ["port", "server"]' -Question: Find settings where the name is IMAP server or Pop server -Response: '(name IN ["IMAP server", "Pop server"])' -Question: Find settings that start with IMAP -Response: 'name LIKE "IMAP%' -Question: Show me the settings that start with IMAP -Response: '(name LIKE "IMAP%")' -Question: Find settings that starts with IMAP -Response:'name LIKE "IMAP%"' -Question: Find settings where name starts with IMAP -Response:'name LIKE "IMAP%"' -Question: Find settings for IMAP -Response:'name LIKE "IMAP%"' -Question: Find settings that starts with IMAP and id less than 5 -Response:'(name LIKE "IMAP%") AND (id < 5)' -Question: IMAP Server -Response: '(fulltext LIKE "%IMAP Server%")' -Question: IMAP Port -Response: '(fulltext LIKE "%IMAP Port%")' -Question: Username -Response: '(fulltext LIKE "%Username%")' -Question: imap.mail.yahoo.com -Response: '(fulltext LIKE "%imap.mail.yahoo.com%")' -Question: 1 -Response: '(fulltext LIKE "%1%")' -Question: SSL Certificate -Response: '(fulltext LIKE "%SSL Certificate%")'{stopSequence} -Question: {question} -{stopSequence} -Response: \ No newline at end of file diff --git a/ProcessMaker/Ai/Prompts/nlq_to_pmql_tasks.md b/ProcessMaker/Ai/Prompts/nlq_to_pmql_tasks.md deleted file mode 100644 index ea604eba55..0000000000 --- a/ProcessMaker/Ai/Prompts/nlq_to_pmql_tasks.md +++ /dev/null @@ -1,82 +0,0 @@ -For the rest of this conversation, I will feed you search queries. Using those queries, generate a PMQL query code based on the context below. Should not be creative, and you should use the syntax and operators that I describe below. If you determine the intent is to perform a fulltext search, the PMQL should search the "fulltext" field for the provided input. If the intent is to perform a complex query, use the PMQL to do so. If all else fails, fallback to the fulltext search behavior. -### -Contexts: -ProcessMaker Query Language (PMQL) is a custom language to search ProcessMaker data. Use PMQL to find tasks information. -## -Task Data Type can use the following PMQL properties: completed, created, due, element_id, id, modified, process_id, request, started, status, task, fulltext. -Data types never can be used with the prefix 'data.' -## -The NOW keyword represents the current datetime. Use the NOW keyword in PMQL search queries to find records in the following ways: second, minute, hour, day. -Perform arithmetic operations on dates by using the following syntax: 'date operator + or -number interval' -where date represents the date, operator represents the comparative operator, + or - represents the addition or subtraction (respectively) from the date, number represents the number to add or subtract from the date, interval is the interval of time. -## -Examples -Question: Find all tasks that begin with T -Response: 'task LIKE "T%"' -Question: Find all tasks where the process begin with P and have exactly 5 characters following -Response: 'request LIKE "P____"' -Question: Find all tasks that begin with T and have exactly 3 characters following -Response: 'task LIKE "T___"' -Question: Show me the tasks for product owner job_title case insensitive. -Response: 'lower(data.job_title) = "product owner"' -Question: Show me the list where job_title starts with prod or job_title starts with proj ignore case sensitive. -Response: 'lower(data.job_title) LIKE "prod%" OR lower(data.job_title) LIKE "proj%"' -Question: Find tasks associated with all Processes that begin with P -Response: 'request LIKE "P%"' -Question: Find tasks where status starts with c -Response: 'status LIKE "c%"' -Question: Find for completed or erroneous Tasks where the Request Date is not {currentYear}-07-01 or {currentYear}-05-01 -Response: '(status IN ["Completed", "Error"]) AND data.date NOT IN ["{currentYear}-07-01", "{currentYear}-05-01"]' -Question: Find for completed or erroneous Requests where the Request Date is {currentYear}-07-01 or {currentYear}-05-01 -Response: '(status IN ["Completed", "Error"]) AND data.date IN ["{currentYear}-07-01", "{currentYear}-05-01"]' -Question: Find for completed or in progress Requests where the element is 1 or 3. The last modified is equal or major to {currentYear}-07-01 00:00:00 -Response: 'element_id IN ["1", "3"] AND status NOT IN ["Completed", "In Progress"] AND modified >= "{currentYear}-07-01 00:00:00"' -Question: Find tasks for ProcessName that are not more than two (2) days old -Response: '(modified > NOW -2 day) AND (request = "ProcessName")' -Question: Show me all the tasks for the task "Fill user data" -Response: '(task = "Fill user data")' -Question: Generate a PMQL to return all the tasks for the request "Leave of absence" -Response: '(request = "Leave of absence")' -Question: Show me all the tasks for the process that starts with Leave of absence -Response: '(request LIKE "Leave of absence%")' -Question: Show me all the tasks for the process that contains absence -Response: '(request LIKE "%absence%")' -Question: Show me the task "Fill user data" for the process "Leave of absence" -Response: '(task = "Fill user data") AND (request = "Leave of absence")' -Question: Show me the tasks "Fill user data" that are in progress or completed -Response: '(task = "Fill user data") AND (status IN ["In Progress", "Completed"])' -Question: Show me all the tasks that are opened -Response: '(status = "In Progress")' -Question: Generate a PMQL query to return all the tasks for the process "Leave of absence" and "Manage customer" -Response: '(request IN ["Leave of absence", "Manage customer"])' -Question: Return all the tasks -Response: 'id >= 0' -Question: Show all for the last week. -Response: 'modified > NOW -7 day' -Question: Show all for the last 2 weeks. -Response: 'modified > NOW -14 day' -Question: Show all for the last month. -Response: 'modified > NOW -30 day' -Question: Show all for the last 2 months. -Response: 'modified > NOW -60 day' -Question: Return tasks that are in progress started in the first week of March. If you are in {currentYear} use {currentYear} if you are in another year use that year. -Response: '(status = "In Progress") AND (started >= "{currentYear}-03-01 00:00:00") AND (started < "{currentYear}-03-07 00:00:00")' -Question: Return tasks that are in progress started in the first week of March of past year. -Response: '(status = "In Progress") AND (started >= "{pastYear}-03-01 00:00:00") AND (started < "{pastYear}-03-07 00:00:00")' -Question: Show me tasks that started more than a week ago and were modified within the last two days. -Response: '(started >= NOW -7 day) AND (modified <= NOW -2 day)' -Question: Jhon -Response: '(fulltext LIKE "%Jhon%")' -Question: My test task -Response: '(fulltext LIKE "%My test task%")' -Question: Completed -Response: '(fulltext LIKE "%Completed%")' -Question: 56 -Response: '(fulltext LIKE "%56%")' -Question: 188 -Response: '(fulltext LIKE "%188%")' -Question: Leave of absence form -Response: '(fulltext LIKE "%Leave of absence form%")'{stopSequence} -Question: {question} -{stopSequence} -Response: \ No newline at end of file diff --git a/ProcessMaker/Http/Controllers/Api/OpenAIController.php b/ProcessMaker/Http/Controllers/Api/OpenAIController.php index fd9aa53e5b..a4a6a8ae92 100644 --- a/ProcessMaker/Http/Controllers/Api/OpenAIController.php +++ b/ProcessMaker/Http/Controllers/Api/OpenAIController.php @@ -4,94 +4,14 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use OpenAI\Client; -use ProcessMaker\Ai\Handlers\NlqToCategoryHandler; -use ProcessMaker\Ai\Handlers\NlqToPmqlHandler; use ProcessMaker\Http\Controllers\Controller; -use ProcessMaker\Models\AiSearch; use ProcessMaker\Models\Process; use ProcessMaker\Models\ProcessTranslationToken; -use ProcessMaker\Plugins\Collections\Models\Collection; use ProcessMaker\ProcessTranslations\BatchesJobHandler; use ProcessMaker\ProcessTranslations\ProcessTranslation; class OpenAIController extends Controller { - public function NLQToPMQL(Client $client, Request $request) - { - /** - * Types: requests, tasks, collections, settings, security_logs - **/ - $nlqToPmqlHandler = new NlqToPmqlHandler(); - [$result, $usage, $originalQuestion] = $nlqToPmqlHandler->generatePrompt( - $request->input('type'), - $request->input('question') - )->execute(); - - return response()->json([ - 'result' => $result, - 'usage' => $usage, - 'question' => $originalQuestion, - ]); - } - - public function NLQToCategory(Client $client, Request $request) - { - $defaultType = $request->input('type'); - $nlqToCategoryHandler = new NlqToCategoryHandler(); - [$type, $classifierUsage, $originalQuestion] = $nlqToCategoryHandler->generatePrompt($defaultType, - $request->input('question') - )->execute(); - - // Route to the specific prompt - $nlqToPmqlHandler = new NlqToPmqlHandler(); - [$result, $usage, $originalQuestion] = $nlqToPmqlHandler->generatePrompt( - $type, - $originalQuestion - )->execute(); - - // Calc total usage - $usage->classifierTotalTokens = $classifierUsage->totalTokens; - $usage->total = $usage->totalTokens + $classifierUsage->totalTokens; - - // If response is json (needed for collections when asking for specific one) - $resultDecoded = json_decode($result, true); - if (json_last_error() === JSON_ERROR_NONE) { - // Search for collection - if (array_key_exists('collectionName', $resultDecoded)) { - $collection = Collection::where('name', 'like', '%' . mb_strtolower($resultDecoded['collectionName']) . '%')->first(); - - if ($collection) { - $resultDecoded['collection'] = $collection; - } else { - $resultDecoded['collectionError'] = _('We could not find a collection that match with the name "' . $resultDecoded['collectionName'] . '". You can search the collection manually and use the following PMQL query: '); - } - - $result = json_encode($resultDecoded); - } - } else { - $result = json_encode(['pmql' => $result]); - } - - // Save the response - $nlqToPmqlHandler->saveResponse($type, $result); - - // Return recent searched - $recentSearches = AiSearch::where('user_id', Auth::user()->id) - ->latest() - ->take(5) - ->get(); - - return response()->json([ - 'usage' => $usage, - 'result' => json_decode($result, true), - 'question' => $originalQuestion, - 'lastSearch' => $recentSearches->first(), - 'collection' => isset($collection) ? $collection : null, - 'recentSearches' => $recentSearches, - ]); - } - public function languageTranslation(Request $request) { // Find process to translate @@ -141,26 +61,4 @@ public function languageTranslation(Request $request) 'screensTranslations' => $screensTranslations, ]); } - - public function recentSearches(Request $request) - { - // Return recent searched - $quantity = $request->input('quantity'); - $recentSearches = AiSearch::where('user_id', Auth::user()->id) - ->latest() - ->take($quantity) - ->get(); - - return response()->json([ - 'recentSearches' => $recentSearches, - ]); - } - - public function deleteRecentSearches(Request $request) - { - $deleted = AiSearch::where('user_id', Auth::user()->id) - ->delete(); - - return $deleted; - } } diff --git a/ProcessMaker/Models/AiSearch.php b/ProcessMaker/Models/AiSearch.php deleted file mode 100644 index f41f4faee4..0000000000 --- a/ProcessMaker/Models/AiSearch.php +++ /dev/null @@ -1,18 +0,0 @@ - -
-
-
- -
-
-
- - - - diff --git a/resources/views/layouts/navbar.blade.php b/resources/views/layouts/navbar.blade.php index 1db27f08b8..8b0179108f 100644 --- a/resources/views/layouts/navbar.blade.php +++ b/resources/views/layouts/navbar.blade.php @@ -121,9 +121,10 @@ class="btn btn-primary" - @if (config('app.open_ai_nlq_to_pmql') && shouldShow('globalSearchBar')) + @if(hasPackage('package-ai')) @endif + @if (shouldShow('requestButton')) @endif diff --git a/routes/api.php b/routes/api.php index 471c5ac146..f88ff77de6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -277,10 +277,6 @@ Route::get('/test_acknowledgement', [TestStatusController::class, 'testAcknowledgement'])->name('test.acknowledgement'); - // OpenAI - Route::middleware('throttle:30,1')->post('openai/nlq-to-pmql', [OpenAIController::class, 'NLQToPMQL'])->name('openai.nlq-to-pmql'); - Route::middleware('throttle:30,1')->post('openai/nlq-to-category', [OpenAIController::class, 'NLQToCategory'])->name('openai.nlq-to-category'); + // OpenAI Translations Route::middleware('throttle:30,1')->post('openai/language-translation', [OpenAIController::class, 'languageTranslation'])->name('openai.language-translation')->middleware('can:view-process-translations'); - Route::get('openai/recent-searches', [OpenAIController::class, 'recentSearches'])->name('openai.recent-searches'); - Route::delete('openai/recent-searches', [OpenAIController::class, 'deleteRecentSearches'])->name('openai.recent-searches.delete'); });