Skip to content

Commit

Permalink
correctly filter default model
Browse files Browse the repository at this point in the history
  • Loading branch information
noobHappylife committed Nov 28, 2024
1 parent 1cd1446 commit ce08702
Show file tree
Hide file tree
Showing 34 changed files with 796 additions and 759 deletions.
33 changes: 7 additions & 26 deletions clients/python/src/jamaibase/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,46 +1719,27 @@ class ActionTableSchemaCreate(TableSchemaCreate):


class AddActionColumnSchema(ActionTableSchemaCreate):
# TODO: Deprecate this
pass


class KnowledgeTableSchemaCreate(TableSchemaCreate):
# TODO: Maybe deprecate this and use EmbedGenConfig instead ?
embedding_model: str

@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
num_text_cols = sum(c.id.lower() in ("text", "title", "file id") for c in self.cols)
if num_text_cols != 0:
raise ValueError("Schema cannot contain column names: 'Text', 'Title', 'File ID'.")
return self


class AddKnowledgeColumnSchema(TableSchemaCreate):
@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
num_text_cols = sum(c.id.lower() in ("text", "title", "file id") for c in self.cols)
if num_text_cols != 0:
raise ValueError("Schema cannot contain column names: 'Text', 'Title', 'File ID'.")
return self
# TODO: Deprecate this
pass


class ChatTableSchemaCreate(TableSchemaCreate):
@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
num_text_cols = sum(c.id.lower() in ("user", "ai") for c in self.cols)
if num_text_cols != 2:
raise ValueError("Schema must contain column names: 'User' and 'AI'.")
return self
pass


class AddChatColumnSchema(TableSchemaCreate):
@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
return self
# TODO: Deprecate this
pass


class TableMeta(TableBase):
Expand Down
45 changes: 38 additions & 7 deletions clients/python/tests/oss/gen_table/test_table_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"str": '"Arrival" is a 2016 science fiction film. "Arrival" è un film di fantascienza del 2016. 「Arrival」は2016年のSF映画です。',
}
KT_FIXED_COLUMN_IDS = ["Title", "Title Embed", "Text", "Text Embed", "File ID"]
CT_FIXED_COLUMN_IDS = ["User"]

TABLE_ID_A = "table_a"
TABLE_ID_B = "table_b"
Expand Down Expand Up @@ -1430,6 +1431,21 @@ def test_kt_drop_invalid_columns(client_cls: Type[JamAI]):
)


@flaky(max_runs=5, min_passes=1, rerun_filter=_rerun_on_fs_error_with_delay)
@pytest.mark.parametrize("client_cls", CLIENT_CLS)
def test_ct_drop_invalid_columns(client_cls: Type[JamAI]):
table_type = "chat"
jamai = client_cls()
with _create_table(jamai, table_type) as table:
assert isinstance(table, p.TableMetaResponse)
for col in CT_FIXED_COLUMN_IDS:
with pytest.raises(RuntimeError):
jamai.table.drop_columns(
table_type,
p.ColumnDropRequest(table_id=table.id, column_names=[col]),
)


@flaky(max_runs=5, min_passes=1, rerun_filter=_rerun_on_fs_error_with_delay)
@pytest.mark.parametrize("client_cls", CLIENT_CLS)
@pytest.mark.parametrize("table_type", TABLE_TYPES)
Expand All @@ -1450,7 +1466,7 @@ def test_rename_columns(
assert isinstance(table, p.TableMetaResponse)
assert all(isinstance(c, p.ColumnSchema) for c in table.cols)
# Test rename on empty table
table = jamai.rename_columns(
table = jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(y="z")),
)
Expand All @@ -1475,7 +1491,7 @@ def test_rename_columns(
_add_row(jamai, table_type, False, data=dict(x="True", z="<dummy>"))
# Test rename table with data
# Test also auto gen config reference update
table = jamai.rename_columns(
table = jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(x="a")),
)
Expand Down Expand Up @@ -1503,14 +1519,14 @@ def test_rename_columns(

# Repeated new column names
with pytest.raises(RuntimeError):
jamai.rename_columns(
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(a="b", z="b")),
)

# Overlapping new and old column names
with pytest.raises(RuntimeError):
jamai.rename_columns(
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(a="b", z="a")),
)
Expand All @@ -1525,7 +1541,22 @@ def test_kt_rename_invalid_columns(client_cls: Type[JamAI]):
assert isinstance(table, p.TableMetaResponse)
for col in KT_FIXED_COLUMN_IDS:
with pytest.raises(RuntimeError):
jamai.rename_columns(
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map={col: col}),
)


@flaky(max_runs=5, min_passes=1, rerun_filter=_rerun_on_fs_error_with_delay)
@pytest.mark.parametrize("client_cls", CLIENT_CLS)
def test_ct_rename_invalid_columns(client_cls: Type[JamAI]):
table_type = "chat"
jamai = client_cls()
with _create_table(jamai, table_type) as table:
assert isinstance(table, p.TableMetaResponse)
for col in CT_FIXED_COLUMN_IDS:
with pytest.raises(RuntimeError):
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map={col: col}),
)
Expand Down Expand Up @@ -1582,7 +1613,7 @@ def test_reorder_columns(
cols = [c.id for c in table.cols]
assert cols == expected_order, cols
# Test reorder empty table
table = jamai.reorder_columns(
table = jamai.table.reorder_columns(
table_type,
p.ColumnReorderRequest(table_id=TABLE_ID_A, column_names=column_names),
)
Expand Down Expand Up @@ -1692,7 +1723,7 @@ def test_reorder_columns_invalid(
else:
raise ValueError(f"Invalid table type: {table_type}")
with pytest.raises(RuntimeError, match="referenced an invalid source column"):
jamai.reorder_columns(
jamai.table.reorder_columns(
table_type,
p.ColumnReorderRequest(table_id=TABLE_ID_A, column_names=column_names),
)
Expand Down
1 change: 1 addition & 0 deletions scripts/remove_cloud_modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ function quiet_rm($item)
quiet_rm "services/app/ecosystem.config.cjs"
quiet_rm "services/appecosystem.json"
quiet_rm ".github/workflows/trigger-push-gh-image.yml"
quiet_rm ".github/workflows/ci.cloud.yml"
1 change: 1 addition & 0 deletions scripts/remove_cloud_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ find . -type d -name "(cloud)" -exec rm -rf {} +
rm -f services/app/ecosystem.config.cjs
rm -f services/app/ecosystem.json
rm -f .github/workflows/trigger-push-gh-image.yml
rm -f .github/workflows/ci.cloud.yml
2 changes: 1 addition & 1 deletion services/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ dependencies = [
"sqlmodel~=0.0.21",
"srsly~=2.4.8",
# starlette 0.38.3 and 0.38.4 seem to have issues with background tasks
"starlette==0.38.2",
"starlette~=0.41.3",
"stripe~=9.12.0",
"tantivy~=0.22.0",
"tenacity~=8.5.0",
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/owl/configs/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"id": "ellm/BAAI/bge-small-en-v1.5",
"name": "ELLM BAAI BGE Small EN v1.5",
"context_length": 512,
"embedding_size": 1024,
"embedding_size": 384,
"languages": ["mul"],
"capabilities": ["embed"],
"deployments": [
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/owl/configs/models_aipc.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"id": "ellm/BAAI/bge-small-en-v1.5",
"name": "ELLM BAAI BGE Small EN v1.5",
"context_length": 512,
"embedding_size": 1024,
"embedding_size": 384,
"languages": ["mul"],
"capabilities": ["embed"],
"deployments": [
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/owl/configs/models_ollama.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"id": "ellm/BAAI/bge-small-en-v1.5",
"name": "ELLM BAAI BGE Small EN v1.5",
"context_length": 512,
"embedding_size": 1024,
"embedding_size": 384,
"languages": ["mul"],
"capabilities": ["embed"],
"deployments": [
Expand Down
Loading

0 comments on commit ce08702

Please sign in to comment.