From 6efb950ef59f7b8075f1478bfda26f611f7326dd Mon Sep 17 00:00:00 2001 From: doria <93405247+dr-frmr@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:46:56 -0400 Subject: [PATCH] feat: enhance critical analysis functionality by adding peer_id parameter (#191) - Updated `critical_analysis_call` and `critical_analysis_prompt` to include a new `peer_id` parameter for improved context in analysis. - Modified the `CertaintyReasoner` class to pass the sender's name as `peer_id` during analysis calls. - Adjusted test cases to reflect the inclusion of `peer_id`, ensuring comprehensive coverage of the new functionality. --- src/deriver/deriver.py | 3 +++ src/deriver/prompts.py | 3 +++ tests/test_llm_mock.py | 1 + 3 files changed, 7 insertions(+) diff --git a/src/deriver/deriver.py b/src/deriver/deriver.py index 541782e7..dd43a0ac 100644 --- a/src/deriver/deriver.py +++ b/src/deriver/deriver.py @@ -63,6 +63,7 @@ logging.getLogger("sqlalchemy.engine.Engine").disabled = True retry_attempts=3, ) async def critical_analysis_call( + peer_id: str, peer_card: list[str] | None, message_created_at: datetime.datetime, working_representation: str | None, @@ -70,6 +71,7 @@ async def critical_analysis_call( new_turn: str, ): return critical_analysis_prompt( + peer_id=peer_id, peer_card=peer_card, message_created_at=message_created_at, working_representation=working_representation, @@ -328,6 +330,7 @@ class CertaintyReasoner: try: response_obj = await critical_analysis_call( + peer_id=self.ctx.sender_name, peer_card=speaker_peer_card, message_created_at=self.ctx.created_at, working_representation=formatted_working_representation, diff --git a/src/deriver/prompts.py b/src/deriver/prompts.py index 426329c2..2fb4370c 100644 --- a/src/deriver/prompts.py +++ b/src/deriver/prompts.py @@ -13,6 +13,7 @@ from mirascope import prompt_template @prompt_template() def critical_analysis_prompt( + peer_id: str, peer_card: list[str] | None, message_created_at: datetime.datetime, working_representation: str | None, @@ -23,6 +24,7 @@ def critical_analysis_prompt( Generate the critical analysis prompt for the deriver. Args: + peer_id (str): The ID of the user being analyzed. peer_card (list[str] | None): The bio card of the user being analyzed. message_created_at (datetime.datetime): Timestamp of the message. working_representation (str | None): Current user understanding context. @@ -37,6 +39,7 @@ def critical_analysis_prompt( f""" The user's known biographical information: +Peer ID: {peer_id} {chr(10).join(peer_card)} """ diff --git a/tests/test_llm_mock.py b/tests/test_llm_mock.py index 6ce690d5..55fc55dd 100644 --- a/tests/test_llm_mock.py +++ b/tests/test_llm_mock.py @@ -15,6 +15,7 @@ async def test_generic_honcho_llm_call_mock(): # Call the decorated function - this should use our mock result = await critical_analysis_call( + peer_id="test_peer_id", peer_card=["test_peer_card"], message_created_at=datetime(2023, 1, 1, 0, 0, 0, tzinfo=timezone.utc), working_representation="test working representation",