forked from Rockachopa/Timmy-time-dashboard
fix: make confidence visible to users when below 0.7 threshold (#259)
Co-authored-by: rockachopa <alexpaynex@gmail.com> Co-committed-by: rockachopa <alexpaynex@gmail.com>
This commit is contained in:
@@ -110,6 +110,10 @@ async def chat(message: str, session_id: str | None = None) -> str:
|
||||
confidence = estimate_confidence(response_text)
|
||||
logger.debug("Response confidence: %.2f", confidence)
|
||||
|
||||
# Make confidence visible to user when below threshold (SOUL.md requirement)
|
||||
if confidence is not None and confidence < 0.7:
|
||||
response_text += f"\n\n[confidence: {confidence:.0%}]"
|
||||
|
||||
# Record Timmy response after getting it
|
||||
session_logger.record_message("timmy", response_text, confidence=confidence)
|
||||
|
||||
@@ -148,6 +152,13 @@ async def chat_with_tools(message: str, session_id: str | None = None):
|
||||
)
|
||||
confidence = estimate_confidence(response_text) if response_text else None
|
||||
logger.debug("Response confidence: %.2f", confidence)
|
||||
|
||||
# Make confidence visible to user when below threshold (SOUL.md requirement)
|
||||
if confidence is not None and confidence < 0.7:
|
||||
response_text += f"\n\n[confidence: {confidence:.0%}]"
|
||||
# Update the run_output content to reflect the modified response
|
||||
run_output.content = response_text
|
||||
|
||||
session_logger.record_message("timmy", response_text, confidence=confidence)
|
||||
session_logger.flush()
|
||||
return run_output
|
||||
@@ -187,6 +198,13 @@ async def continue_chat(run_output, session_id: str | None = None):
|
||||
response_text = result.content if hasattr(result, "content") and result.content else ""
|
||||
confidence = estimate_confidence(response_text) if response_text else None
|
||||
logger.debug("Response confidence: %.2f", confidence)
|
||||
|
||||
# Make confidence visible to user when below threshold (SOUL.md requirement)
|
||||
if confidence is not None and confidence < 0.7:
|
||||
response_text += f"\n\n[confidence: {confidence:.0%}]"
|
||||
# Update the result content to reflect the modified response
|
||||
result.content = response_text
|
||||
|
||||
session_logger.record_message("timmy", response_text, confidence=confidence)
|
||||
session_logger.flush()
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user