Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dakennguyen committed Jul 19, 2023
1 parent d0a5859 commit 36029eb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/services/guidance_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ def test_query_success(mocker):
assert result.text_content == "the output"


def test_query_using_truncate_function(mocker):
mocker.patch.object(
GuidanceWrapper,
"_get_llm",
return_value=guidance.llms.Mock("the output"),
)

handlebars = """{{#user~}}I want a response to the following query:
{{query}}{{~/user}}{{#assistant~}}
{{gen 'answer' temperature=0.0 max_tokens=500}}{{~/assistant}}
{{set 'response' (truncate answer 3)}}
"""

guidance_wrapper = GuidanceWrapper(
model=llm_model_config,
handlebars=handlebars,
parameters={"query": "Some query"},
)

result = guidance_wrapper.query()

assert isinstance(result, Content)
assert result.type == ContentType.TEXT
assert result.text_content == "the"


@pytest.mark.skip(
reason="This tests library behavior changed by Guidance version bump"
)
Expand Down

0 comments on commit 36029eb

Please sign in to comment.