From 282fd3cf7ae082460a8ad43e4a4a07902ebf2e93 Mon Sep 17 00:00:00 2001 From: Alfred Nutile <365385+alnutile@users.noreply.github.com> Date: Mon, 15 May 2023 13:18:19 -0400 Subject: [PATCH] ok the generator for a Response type is working --- app/ResponseType/ResponseTypeEnum.php | 1 - config/larachain.php | 234 ++++++++++++-------------- tests/Feature/EnumTransformerTest.php | 2 +- 3 files changed, 108 insertions(+), 129 deletions(-) diff --git a/app/ResponseType/ResponseTypeEnum.php b/app/ResponseType/ResponseTypeEnum.php index ed7118c..b5c5b99 100644 --- a/app/ResponseType/ResponseTypeEnum.php +++ b/app/ResponseType/ResponseTypeEnum.php @@ -24,4 +24,3 @@ public function label(): string }; } } - diff --git a/config/larachain.php b/config/larachain.php index eb3f980..0c94561 100644 --- a/config/larachain.php +++ b/config/larachain.php @@ -1,129 +1,109 @@ - array( - 'web_file' => - array( - 'title' => 'Web File Source Type', - 'description' => 'Points to one or more URLs to download files from the internet for later parsing. All configuration data is encrypted.', - 'icon' => 'ArrowDownTrayIcon', - 'background' => 'bg-indigo-500', - ), - 'web' => - array( - 'title' => 'Scrape a Web Page', - 'description' => 'Simple scraper to fetch the desired data from a web page and pass it to LLM.', - 'icon' => 'Bars4Icon', - 'background' => 'bg-sky-500', - ), - 'web_hook' => - array( - 'title' => 'Create a Webhook to Send Data', - 'description' => 'Add a webhook here to send logs or other data.', - 'icon' => 'Bars4Icon', - 'background' => 'bg-sky-500', - ), - 's3_directory' => - array( - 'title' => 'S3 Directory to Get Files From', - 'description' => 'Retrieve files from an S3 directory.', - 'icon' => 'Bars4Icon', - 'background' => 'bg-red-500', - ), - ), - 'transformers' => - array( - 'pdf_transformer' => - array( - 'title' => 'Break Pages of PDF into Text and Document Chunks', - 'description' => 'If you have a PDF as a source, use this transformer to extract pages and text.', - 'icon' => 'DocumentIcon', - 'background' => 'bg-blue-500', - ), - 'embed_transformer' => - array( - 'title' => 'Vectorize Your Data', - 'description' => 'Create embeddings out of all your document chunks.', - 'icon' => 'ArrowsRightLeftIcon', - 'background' => 'bg-red-700', - ), - ), - 'outbounds' => - array( - 'chat_ui' => - array( - 'title' => 'Add a ChatUI to the Project Page', - 'description' => 'Users can use the chosen Chat LLM to interact with the related data.', - 'icon' => 'ChatBubbleLeftIcon', - 'background' => 'bg-sky-500', - ), - 'api' => - array( - 'title' => 'Add an API', - 'description' => 'Attach a secure API to communicate with your data from any other app.', - 'icon' => 'PhoneIcon', - 'background' => 'bg-green-500', - ), - ), - 'response_types' => - array( - 'embed_question' => - array( - 'title' => 'Convert Incoming Question/Request into an Embedding', - 'description' => 'This allows you to search the vector database if you have vectorized your data.', - 'icon' => 'MegaphoneIcon', - 'route' => 'embed_question', - 'requires' => - array( - 0 => 'transformers:embed_transformer', - ), - 'background' => 'bg-sky-500', - 'active' => 1, - ), - 'vector_search' => - array( - 'title' => 'Search Vector Database', - 'description' => 'Search the vector database with your request and pass it on to the next response type or to the user', - 'icon' => 'MagnifyingGlassIcon', - 'route' => 'vector_search', - 'requires' => - array( - 0 => 'embed_question', - ), - 'background' => 'bg-green-500', - 'active' => 1, - ), - 'combine_content' => - array( - 'title' => 'Combine Content', - 'description' => 'This will merge together the document chunks that result from a search to make sure they fit in a prompt', - 'icon' => 'ArrowsPointingInIcon', - 'route' => 'combine_content', - 'requires' => - array( - 0 => 'embed_question', - ), - 'background' => 'bg-slate-800', - 'active' => 1, - ), - 'trim_text' => - array( - 'title' => 'Trim Text', - 'description' => 'designed to help you trim text inputs, making it easier to fit more content within GPT’s context window. By tokenizing, stemming, and removing spaces, this library prepares your text inputs for efficient processing with GPT models.', - 'icon' => 'DocumentTextIcon', - 'route' => 'trim_text', - 'background' => 'bg-slate-800', - 'active' => 1, - ), - 'chat_ui' => - array( - 'title' => 'Integrate with Chat LLM APIs', - 'description' => 'Create a chat system with platforms like OpenAI or others. It will pass any info into the {context} token in the prompt_token', - 'icon' => 'ChatBubbleLeftIcon', - 'route' => 'chat_ui', - 'background' => 'bg-pink-400', - 'active' => 1, - ), - ), -); +return [ + 'sources' => [ + 'web_file' => [ + 'title' => 'Web File Source Type', + 'description' => 'Points to one or more URLs to download files from the internet for later parsing. All configuration data is encrypted.', + 'icon' => 'ArrowDownTrayIcon', + 'background' => 'bg-indigo-500', + ], + 'web' => [ + 'title' => 'Scrape a Web Page', + 'description' => 'Simple scraper to fetch the desired data from a web page and pass it to LLM.', + 'icon' => 'Bars4Icon', + 'background' => 'bg-sky-500', + ], + 'web_hook' => [ + 'title' => 'Create a Webhook to Send Data', + 'description' => 'Add a webhook here to send logs or other data.', + 'icon' => 'Bars4Icon', + 'background' => 'bg-sky-500', + ], + 's3_directory' => [ + 'title' => 'S3 Directory to Get Files From', + 'description' => 'Retrieve files from an S3 directory.', + 'icon' => 'Bars4Icon', + 'background' => 'bg-red-500', + ], + ], + 'transformers' => [ + 'pdf_transformer' => [ + 'title' => 'Break Pages of PDF into Text and Document Chunks', + 'description' => 'If you have a PDF as a source, use this transformer to extract pages and text.', + 'icon' => 'DocumentIcon', + 'background' => 'bg-blue-500', + ], + 'embed_transformer' => [ + 'title' => 'Vectorize Your Data', + 'description' => 'Create embeddings out of all your document chunks.', + 'icon' => 'ArrowsRightLeftIcon', + 'background' => 'bg-red-700', + ], + ], + 'outbounds' => [ + 'chat_ui' => [ + 'title' => 'Add a ChatUI to the Project Page', + 'description' => 'Users can use the chosen Chat LLM to interact with the related data.', + 'icon' => 'ChatBubbleLeftIcon', + 'background' => 'bg-sky-500', + ], + 'api' => [ + 'title' => 'Add an API', + 'description' => 'Attach a secure API to communicate with your data from any other app.', + 'icon' => 'PhoneIcon', + 'background' => 'bg-green-500', + ], + ], + 'response_types' => [ + 'embed_question' => [ + 'title' => 'Convert Incoming Question/Request into an Embedding', + 'description' => 'This allows you to search the vector database if you have vectorized your data.', + 'icon' => 'MegaphoneIcon', + 'route' => 'embed_question', + 'requires' => [ + 0 => 'transformers:embed_transformer', + ], + 'background' => 'bg-sky-500', + 'active' => 1, + ], + 'vector_search' => [ + 'title' => 'Search Vector Database', + 'description' => 'Search the vector database with your request and pass it on to the next response type or to the user', + 'icon' => 'MagnifyingGlassIcon', + 'route' => 'vector_search', + 'requires' => [ + 0 => 'embed_question', + ], + 'background' => 'bg-green-500', + 'active' => 1, + ], + 'combine_content' => [ + 'title' => 'Combine Content', + 'description' => 'This will merge together the document chunks that result from a search to make sure they fit in a prompt', + 'icon' => 'ArrowsPointingInIcon', + 'route' => 'combine_content', + 'requires' => [ + 0 => 'embed_question', + ], + 'background' => 'bg-slate-800', + 'active' => 1, + ], + 'trim_text' => [ + 'title' => 'Trim Text', + 'description' => 'designed to help you trim text inputs, making it easier to fit more content within GPT’s context window. By tokenizing, stemming, and removing spaces, this library prepares your text inputs for efficient processing with GPT models.', + 'icon' => 'DocumentTextIcon', + 'route' => 'trim_text', + 'background' => 'bg-slate-800', + 'active' => 1, + ], + 'chat_ui' => [ + 'title' => 'Integrate with Chat LLM APIs', + 'description' => 'Create a chat system with platforms like OpenAI or others. It will pass any info into the {context} token in the prompt_token', + 'icon' => 'ChatBubbleLeftIcon', + 'route' => 'chat_ui', + 'background' => 'bg-pink-400', + 'active' => 1, + ], + ], +]; diff --git a/tests/Feature/EnumTransformerTest.php b/tests/Feature/EnumTransformerTest.php index 2bed90e..eb5734a 100644 --- a/tests/Feature/EnumTransformerTest.php +++ b/tests/Feature/EnumTransformerTest.php @@ -35,7 +35,7 @@ enum ResponseTypeEnum: string $this->assertStringContainsString("case FooBar = 'foo_bar'", $content); $this->assertStringContainsString("case EmbedQuestion = 'embed_question'", $content); $this->assertStringContainsString('enum ResponseTypeEnum: string', $content); - $this->assertEquals(1, substr_count($content, "case FooBar")); + $this->assertEquals(1, substr_count($content, 'case FooBar')); return true; });