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.
This commit is contained in:
doria 2025-08-13 13:46:56 -04:00 committed by GitHub
parent fb45c607e5
commit 6efb950ef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -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,

View File

@ -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_card>
Peer ID: {peer_id}
{chr(10).join(peer_card)}
</peer_card>
"""

View File

@ -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",