-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing bug 857 (regression from 0.1.14 to 0.1.15) #858
base: main
Are you sure you want to change the base?
Changes from 3 commits
1c04d57
9a7d627
37c8883
1624a85
7dea7d2
5eda1c9
0347516
cf2bf6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
from guidance import capture, models, one_or_more, select, guidance | ||
from guidance import capture, models, one_or_more, select, guidance, user | ||
import pytest | ||
|
||
from ..utils import get_model | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def instruct_model(selected_model, selected_model_name): | ||
if selected_model_name in ["transformers_phi3cpu_mini_4k_instruct"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the only model for which the test works? I thought that some of the others supported the role tags? Perhaps move the fixture to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah it appears so! It looks like there's both transformers and non transformers of phi3 mini instruct 4k, as well as a couple other instruct versions I recognized. Good idea to move it to the conftest.py file though, I can definitely see situations where we could use more tests specifically for models that utilize roles. |
||
return selected_model | ||
else: | ||
pytest.skip("Requires Phi3 4k Instruct model") | ||
|
||
|
||
|
||
def test_capture(): | ||
model = models.Mock() | ||
model += "This is" + capture(select(options=["bad", "quite bad"]), name="my_var") | ||
|
@@ -44,4 +54,11 @@ def raw_fn(lm): | |
|
||
assert str(lm_nocap).endswith("|the end") | ||
assert str(lm_cap_arg).endswith("|the end") | ||
assert str(lm_cap_kwarg).endswith("|the end") | ||
assert str(lm_cap_kwarg).endswith("|the end") | ||
|
||
def test_capture_within_role(instruct_model: guidance.models.Model): | ||
lm = instruct_model | ||
test_text = "This is some text in a role." | ||
with user(): | ||
lm += capture(test_text, "test") | ||
assert lm["test"] == test_text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly concerned that this appears to be relying on ChatML tags, which not all models use