Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Simplify msg for Assert

Shangyint716e3e611909
diff --git a/assert_hotpotqa.py b/assert_hotpotqa.py
index 927bdc169..838b11831 100644
--- a/assert_hotpotqa.py
+++ b/assert_hotpotqa.py
@@ -108,12 +108,12 @@ class SimplifiedBaleen(dspy.Module):
dspy.Assert(
len(query) <= 100,
- msg="Query should be short and less than 100 characters",
+ "Query should be short and less than 100 characters",
)
dspy.Assert(
validate_query_distinction_local(prev_queries, query),
- msg="Query should not be the following: "
+ "Query should not be the following: "
+ "; ".join(
f"{idx+1}) {query}" for idx, query in enumerate(prev_queries)
),
diff --git a/dspy/primitives/assertions.py b/dspy/primitives/assertions.py
index 3fbdd3e49..5cd43cce2 100644
--- a/dspy/primitives/assertions.py
+++ b/dspy/primitives/assertions.py
@@ -16,16 +16,10 @@ class DSPyAssertionError(AssertionError):
class Assert:
"""DSPy Assertion"""
- def __init__(self, assert_fun_res: bool, **kwargs):
+ def __init__(self, assert_fun_res: bool, msg: str = ""):
self.assert_fun_res = assert_fun_res
- if "msg" in kwargs:
- self.msg = kwargs["msg"]
- del kwargs["msg"]
- else:
- self.msg = ""
-
- self.kwargs = kwargs
+ self.msg = msg
self.__call__()
def __call__(self) -> bool: