Skip to content

Commit

Permalink
add support for default embedding model in kb. Ie user doesn't need t…
Browse files Browse the repository at this point in the history
…o specify a model in query
  • Loading branch information
dusvyat committed Dec 4, 2023
1 parent c1876c3 commit 07c48ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions mindsdb_sql/parser/dialects/mindsdb/knowledge_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreateKnowledgeBase(ASTNode):
def __init__(
self,
name,
model,
model=None,
storage=None,
from_select=None,
params=None,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parser/test_mindsdb/test_knowledgebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)


def test_create_knowledeg_base():
def test_create_knowledge_base():
# create without select
sql = """
CREATE KNOWLEDGE_BASE my_knowledge_base
Expand Down

0 comments on commit 07c48ac

Please sign in to comment.