This commit is contained in:
Harrison Chase
2023-03-13 09:20:14 -07:00
parent 735d465abf
commit c8dca75ae3
12 changed files with 26 additions and 105 deletions

View File

@@ -3,6 +3,7 @@ from typing import List
import pytest
from langchain.guards.restriction import RestrictionGuard
from langchain.guards.restriction_prompt import RESTRICTION_PROMPT
from tests.unit_tests.llms.fake_llm import FakeLLM
@@ -19,7 +20,7 @@ def test_restriction_guard() -> None:
) -> str:
concatenated_restrictions = ", ".join(restrictions)
queries = {
RestrictionGuard.prompt.format(
RESTRICTION_PROMPT.format(
restrictions=concatenated_restrictions, function_output=llm_input_output
): "restricted because I said so :) (¥)"
if restricted
@@ -27,7 +28,7 @@ def test_restriction_guard() -> None:
}
restriction_guard_llm = FakeLLM(queries=queries)
@RestrictionGuard(
@RestrictionGuard.from_llm(
restrictions=restrictions, llm=restriction_guard_llm, retries=0
)
def example_func(prompt: str) -> str:

View File

@@ -2,7 +2,7 @@ from typing import List
import pytest
from langchain.output_parsing.boolean import BooleanOutputParser
from langchain.output_parsers.boolean import BooleanOutputParser
GOOD_EXAMPLES = [
("0", False, ["1"], ["0"]),