Skip to content

Commit

Permalink
Add some UT comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jieguangzhou committed Dec 29, 2023
1 parent 2a90a24 commit 7c615d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions superduperdb/ext/llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ def post_create(self, db: "Datalayer") -> None:
from superduperdb.backends.ibis.field_types import dtype

if isinstance(db.databackend, IbisDataBackend) and self.encoder is None:
self.encoder = dtype('str')
self.encoder = dtype("str")

# since then the `.add` clause is not necessary
output_component = db.databackend.create_model_table_or_collection(self) # type: ignore[arg-type]
output_component = db.databackend.create_model_table_or_collection(
self # type: ignore[arg-type]
)

if output_component is not None:
db.add(output_component)

Expand Down
13 changes: 12 additions & 1 deletion test/unittest/ext/llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def check_predict(db, llm):
"""Test chat."""
"""Test whether db can call model prediction normally."""
db.add(llm)
result = db.predict(llm.identifier, "1+1=")[0].content
assert isinstance(result, str)
Expand All @@ -24,6 +24,7 @@ def check_predict(db, llm):


def check_llm_as_listener_model(db, llm):
"""Test whether the model can predict the data in the database normally"""
collection_name = "question"
datas = [Document({"question": f"1+{i}=", "id": str(i)}) for i in range(10)]
if isinstance(db.databackend, MongoDataBackend):
Expand Down Expand Up @@ -60,3 +61,13 @@ def check_llm_as_listener_model(db, llm):
except KeyError:
output = result.unpack()[f'_outputs.question.{llm.identifier}.0']
assert isinstance(output, str)


# TODO: add test for llm_cdc
def check_llm_cdc(db, llm):
"""Test whether the model predicts normally for incremental data"""
pass


# TODO: Expanded into a test tool class,
# Used to test whether all model objects are normally compatible with superduperdb

0 comments on commit 7c615d2

Please sign in to comment.