From 07c48ace16d8bee500cb57e6cfb0392030dd5ebf Mon Sep 17 00:00:00 2001 From: dusvyat <13661123+dusvyat@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:48:09 +0000 Subject: [PATCH] add support for default embedding model in kb. Ie user doesn't need to specify a model in query --- mindsdb_sql/parser/dialects/mindsdb/knowledge_base.py | 10 +++++----- tests/test_parser/test_mindsdb/test_knowledgebase.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mindsdb_sql/parser/dialects/mindsdb/knowledge_base.py b/mindsdb_sql/parser/dialects/mindsdb/knowledge_base.py index 0ea4b4d2..a9303bce 100644 --- a/mindsdb_sql/parser/dialects/mindsdb/knowledge_base.py +++ b/mindsdb_sql/parser/dialects/mindsdb/knowledge_base.py @@ -9,7 +9,7 @@ class CreateKnowledgeBase(ASTNode): def __init__( self, name, - model, + model=None, storage=None, from_select=None, params=None, @@ -37,13 +37,13 @@ def __init__( def to_tree(self, *args, level=0, **kwargs): ind = indent(level) storage_str = f"{ind} storage={self.storage.to_string()},\n" if self.storage else "" + model_str = f"{ind} model={self.model.to_string()},\n" if self.model else "" out_str = f""" {ind}CreateKnowledgeBase( {ind} if_not_exists={self.if_not_exists}, {ind} name={self.name.to_string()}, {ind} from_query={self.from_query.to_tree(level=level + 1) if self.from_query else None}, - {ind} model={self.model.to_string()}, - {storage_str}{ind} params={self.params} + {model_str}{storage_str}{ind} params={self.params} {ind}) """ return out_str @@ -56,13 +56,13 @@ def get_string(self, *args, **kwargs): f"FROM ({self.from_query.get_string()})" if self.from_query else "" ) storage_str = f" STORAGE = {self.storage.to_string()}" if self.storage else "" + model_str = f" MODEL = {self.model.to_string()},\n" if self.model else "" out_str = ( f"CREATE KNOWLEDGE_BASE {'IF NOT EXISTS' if self.if_not_exists else ''}{self.name.to_string()} " f"{from_query_str} " f"USING {using_str}," - f" MODEL = {self.model.to_string()}, " - f"{storage_str}" + f"{model_str}{storage_str}" ) return out_str diff --git a/tests/test_parser/test_mindsdb/test_knowledgebase.py b/tests/test_parser/test_mindsdb/test_knowledgebase.py index 944a7e33..b04c37fc 100644 --- a/tests/test_parser/test_mindsdb/test_knowledgebase.py +++ b/tests/test_parser/test_mindsdb/test_knowledgebase.py @@ -18,7 +18,7 @@ ) -def test_create_knowledeg_base(): +def test_create_knowledge_base(): # create without select sql = """ CREATE KNOWLEDGE_BASE my_knowledge_base