vet

Mirror of Vet, an AI code review tool
git clone git://git.laack.co/vet.git
Log | Files | Refs | README | LICENSE

conversation_single_prompt_test.py (2833B)


      1 import pytest
      2 
      3 from vet.imbue_core.data_types import IssueCode
      4 from vet.imbue_tools.get_conversation_history.input_data_types import ConversationInputs
      5 from vet.imbue_tools.get_conversation_history.input_data_types import IdentifierInputs
      6 from vet.imbue_tools.get_conversation_history.input_data_types import IdentifierInputsMissingError
      7 from vet.issue_identifiers.harnesses.conversation_single_prompt import ConversationSinglePromptHarness
      8 from vet.issue_identifiers.identification_guides import ISSUE_IDENTIFICATION_GUIDES_BY_ISSUE_CODE
      9 from vet.vet_types.chat_state import TextBlock
     10 from vet.vet_types.ids import AssistantMessageID
     11 from vet.vet_types.messages import AgentMessageSource
     12 from vet.vet_types.messages import ChatInputUserMessage
     13 from vet.vet_types.messages import LLMModel
     14 from vet.vet_types.messages import ResponseBlockAgentMessage
     15 
     16 
     17 def test_to_required_inputs() -> None:
     18     harness = ConversationSinglePromptHarness()
     19     classifier = harness.make_issue_identifier(
     20         identification_guides=(ISSUE_IDENTIFICATION_GUIDES_BY_ISSUE_CODE[IssueCode.MISLEADING_BEHAVIOR],)
     21     )
     22 
     23     # should support inputs where only the conversation history is present
     24     conversation_history_inputs = IdentifierInputs(
     25         maybe_conversation_history=(
     26             ChatInputUserMessage(
     27                 text="fake content",
     28                 model_name=LLMModel.CLAUDE_4_SONNET,
     29             ),
     30         )
     31     )
     32     cvi = classifier.to_required_inputs(conversation_history_inputs)
     33     assert isinstance(cvi, ConversationInputs)
     34 
     35     # and inputs where the conversation history and commit message are present
     36     conversation_history_and_commit_message_inputs = IdentifierInputs(
     37         maybe_conversation_history=(
     38             ResponseBlockAgentMessage(
     39                 source=AgentMessageSource.AGENT,
     40                 role="assistant",
     41                 assistant_message_id=AssistantMessageID("fake_message_id"),
     42                 content=(TextBlock(text="fake content"),),
     43             ),
     44         ),
     45         maybe_goal="test",
     46         maybe_diff="test",
     47     )
     48     cvi = classifier.to_required_inputs(conversation_history_and_commit_message_inputs)
     49     assert isinstance(cvi, ConversationInputs)
     50     assert cvi.maybe_goal == "test"
     51     assert cvi.maybe_diff == "test"
     52 
     53     # should not support inputs where the conversation history is absent
     54     commit_inputs = IdentifierInputs(maybe_goal="test", maybe_diff="test")
     55     with pytest.raises(IdentifierInputsMissingError):
     56         classifier.to_required_inputs(commit_inputs)
     57     file_inputs = IdentifierInputs(maybe_files=("test.py",))
     58     with pytest.raises(IdentifierInputsMissingError):
     59         classifier.to_required_inputs(file_inputs)
     60     no_inputs = IdentifierInputs()
     61     with pytest.raises(IdentifierInputsMissingError):
     62         classifier.to_required_inputs(no_inputs)