Improve Templates (#183)

* Improve Templates

* Fix test case

* Update AI GenerateTemplate

* update openai client and GPT completer

* composer.lock

* Update types and list json with script

* Template changes

* fix on draft template

* Finish opnform templates

---------

Co-authored-by: Forms Dev <chirag+new@notionforms.io>
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2023-09-08 16:30:28 +05:30
committed by GitHub
parent d93eca7410
commit 8e47b49e9a
36 changed files with 3130 additions and 1381 deletions

View File

@@ -95,6 +95,7 @@ class JsonFixer
*/
public function fix($json)
{
$json = preg_replace('/(?<!\\\\)(?:\\\\{2})*\p{C}+/u', '', $json);
list($head, $json, $tail) = $this->trim($json);
if (empty($json) || $this->isValid($json)) {
@@ -124,7 +125,7 @@ class JsonFixer
protected function isValid($json)
{
\json_decode($json);
\json_decode($json,true,512,JSON_INVALID_UTF8_SUBSTITUTE);
return \JSON_ERROR_NONE === \json_last_error();
}
@@ -265,6 +266,10 @@ class JsonFixer
return $json;
}
\Log::debug('Broken json received: ', [
'json' => $json
]);
throw new InvalidJsonException(
\sprintf('Could not fix JSON (tried padding `%s`)', \substr($tmpJson, $length), $json)
);