Mul test, valdidation works, but printing it doesnt

This commit is contained in:
Lennart J. Kurzweg (Nx2)
2024-08-05 14:09:06 +02:00
parent 52a180b936
commit abd6320ce9
6 changed files with 99 additions and 31 deletions

View File

@@ -10,11 +10,11 @@ def system_human_answer_match(test: Test, answer: str, base_url: str) -> bool:
prompt = ChatPromptTemplate.from_messages([
SystemMessagePromptTemplate.from_template(template="""Rate the answer as correct, if the answer is
{validation_info}
{validation_input}
else as incorrect. Only use the rate tool. Do not answer conversationally."""),
# SystemMessagePromptTemplate.from_template(template="""You are a rating machine. You are given 3 things: The system message, the Human query, and the AI response. You evaluate the response as correct if
# {validation_info}
# {validation_input}
# If the answer does not match these criteria, rate the answer as incorrect. If the answer is a "refusal" or a "declaration of incapability", the answer is automatically incorrect.
@@ -31,9 +31,9 @@ Answer:
{answer}
""")
]).invoke({
"validation_info": test.validation_info,
"system_msg": test.system_msg,
"human_msg": test.human_msg,
"validation_input": test.validation_input,
"system_msg": test.runnable_input['system_msg'],
"human_msg": test.runnable_input['human_msg'],
"answer": answer
})
@@ -51,3 +51,11 @@ Answer:
print(f"\033[0;31mValidation Error \033[0mof {test.name} <{ai_msg.content[:20]}...> Retrying...")
return system_human_answer_match(test=test, answer=answer)
from re import search
def regex_match_any(test: Test, answer: str, base_url: str) -> bool:
match = False
for pattern in test.validation_input['patterns']:
if search(pattern, answer):
match = True
return match