Skip to content

Commit

Permalink
Merge pull request #203 from emcie-co/feature/mc-485-fix-small-mistak…
Browse files Browse the repository at this point in the history
…es-in-guideline-proposition-tests

Guideline Proposer - fixed  tests, reverted GPT version
  • Loading branch information
mc-dorzo authored Dec 25, 2024
2 parents 55af308 + 34b3eca commit 53bdca1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/parlant/adapters/nlp/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import tiktoken

from parlant.adapters.nlp.common import normalize_json_output
from parlant.core.engines.alpha.guideline_proposer import GuidelinePropositionsSchema
from parlant.core.logging import Logger
from parlant.core.nlp.policies import policy, retry
from parlant.core.nlp.tokenization import EstimatingTokenizer
Expand Down Expand Up @@ -380,7 +381,7 @@ def __init__(

@override
async def get_schematic_generator(self, t: type[T]) -> OpenAISchematicGenerator[T]:
if t == GuidelineConnectionPropositionsSchema:
if t == GuidelineConnectionPropositionsSchema or t == GuidelinePropositionsSchema:
return GPT_4o_24_08_06[t](self._logger) # type: ignore
return GPT_4o[t](self._logger) # type: ignore

Expand Down
22 changes: 15 additions & 7 deletions tests/core/unstable/engines/alpha/test_guideline_proposer.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@
"condition": "the customer asked a question about birds",
"action": "answer their question enthusiastically, while not using punctuation. Also say that the kingfisher is your favorite bird",
},
"second_thanks": {
"condition": "the customer is thanking you for the second time in the interaction",
"action": "compliment the customer for their manners",
},
}


Expand Down Expand Up @@ -392,25 +396,28 @@ def test_that_many_guidelines_are_classified_correctly( # a stress test
"ai_agent",
"Got it! Your blue 'City Cruiser' skateboard and black medium helmet are ready for checkout. How would you like to pay?",
),
("customer", "I'll pay with a credit card, thanks."),
("customer", "I'll pay with a credit card, thank you very much!"),
(
"ai_agent",
"Thank you for your order! Your skateboard and helmet will be shipped shortly. Enjoy your ride!",
),
("customer", "That's great! Thanks!"),
]

exceptions = ["credit_payment1", "credit_payment2", "cow_response"]
exceptions = [
"credit_payment1",
"credit_payment2",
"cow_response",
"thankful_customer",
"payment_process",
]

conversation_guideline_names: list[str] = [
guideline_name
for guideline_name in GUIDELINES_DICT.keys()
if guideline_name not in exceptions
]
relevant_guideline_names = [
"announce_shipment",
"thankful_customer",
]
relevant_guideline_names = ["announce_shipment", "second_thanks"]
base_test_that_correct_guidelines_are_proposed(
context,
agent,
Expand Down Expand Up @@ -510,13 +517,14 @@ def test_that_guideline_that_needs_to_be_reapplied_is_proposed(
]

conversation_guideline_names: list[str] = ["large_pizza_crust"]
relevant_guideline_names = conversation_guideline_names
base_test_that_correct_guidelines_are_proposed(
context,
agent,
customer,
conversation_context,
conversation_guideline_names,
[],
relevant_guideline_names,
context_variables=[],
)

Expand Down

0 comments on commit 53bdca1

Please sign in to comment.