fix bug and test

This commit is contained in:
co tran 2025-03-31 21:50:05 +00:00
parent cc0845bce4
commit afe7cc9e9e
3 changed files with 36 additions and 79 deletions

View file

@ -416,15 +416,14 @@ class ArchFunctionHandler(ArchBaseHandler):
has_tool_calls, has_hallucination = None, False
for _ in self.hallucination_state:
# check if the first token is <tool_call>
if len(self.hallucination_state.tokens) > 5 and has_tool_calls is None:
content = "".join(self.hallucination_state.tokens)
if "tool_calls" in content:
logger.info(
f"[Content]: {content}"
)
has_tool_calls = True
else:
has_tool_calls = False
content = "".join(self.hallucination_state.tokens)
if "tool_calls" in content:
logger.info(
f"[Content]: {content}"
)
has_tool_calls = True
else:
has_tool_calls = False
# if the model is hallucinating, start parameter gathering

View file

@ -36,8 +36,8 @@ class MaskToken(Enum):
HALLUCINATION_THRESHOLD_DICT = {
"entropy": 0.28,
"varentropy": 1.4,
"entropy": 0.35,
"varentropy": 1.1,
"probability": 0.8,
}