Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vera_mh/generate/conversation_turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from langchain_core.messages import AIMessage, BaseMessage, HumanMessage

from vera_mh.llm_clients.llm_interface import Role
from vera_mh.utils.role import Role


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion src/vera_mh/generate/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import AbstractSet, Any, Dict, List, Optional, Tuple

from vera_mh.llm_clients import LLMFactory
from vera_mh.llm_clients.llm_interface import LLMGenerationFailed, Role
from vera_mh.llm_clients.llm_interface import LLMGenerationFailed
from vera_mh.utils.conversation_layout import resolve_conversation_input
from vera_mh.utils.logging_utils import (
cleanup_logger,
Expand All @@ -31,6 +31,7 @@
TRANSCRIPT_RUN_SUFFIX_RE,
persona_token_for_transcript_stem,
)
from vera_mh.utils.role import Role

from .conversation_simulator import ConversationSimulator
from .utils import DEFAULT_USER_LANGUAGE, load_prompts_from_csv
Expand Down
3 changes: 2 additions & 1 deletion src/vera_mh/judge/llm_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
log_llm_failure_metadata,
log_llm_response_metadata,
)
from vera_mh.llm_clients import LLMFactory, Role
from vera_mh.llm_clients import LLMFactory
from vera_mh.llm_clients.llm_interface import JudgeLLM, LLMGenerationFailed
from vera_mh.utils.ratings import BEST_PRACTICE, DAMAGING, NEUTRAL
from vera_mh.utils.role import Role


class LLMJudge:
Expand Down
3 changes: 1 addition & 2 deletions src/vera_mh/llm_clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

from .config import Config
from .llm_factory import LLMFactory
from .llm_interface import JudgeLLM, LLMGenerationFailed, LLMInterface, Role
from .llm_interface import JudgeLLM, LLMGenerationFailed, LLMInterface

__all__ = [
"LLMInterface",
"JudgeLLM",
"LLMFactory",
"Config",
"Role",
"LLMGenerationFailed",
]
2 changes: 1 addition & 1 deletion src/vera_mh/llm_clients/azure_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from langchain_core.messages import HumanMessage, SystemMessage
from pydantic import BaseModel

from vera_mh.llm_clients import Role
from vera_mh.utils.conversation_utils import build_langchain_messages
from vera_mh.utils.debug import debug_print
from vera_mh.utils.role import Role

from .config import Config
from .llm_interface import (
Expand Down
2 changes: 1 addition & 1 deletion src/vera_mh/llm_clients/claude_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

from vera_mh.utils.conversation_utils import build_langchain_messages
from vera_mh.utils.debug import debug_print
from vera_mh.utils.role import Role

from .config import Config
from .llm_interface import (
JudgeLLM,
Role,
ensure_pydantic_response,
extract_structured_invoke_result,
)
Expand Down
3 changes: 2 additions & 1 deletion src/vera_mh/llm_clients/endpoint_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import aiohttp

from vera_mh.utils.conversation_utils import build_langchain_messages
from vera_mh.utils.role import Role

from .config import Config
from .llm_interface import LLMInterface, Role
from .llm_interface import LLMInterface


class EndpointLLM(LLMInterface):
Expand Down
2 changes: 1 addition & 1 deletion src/vera_mh/llm_clients/gemini_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

from vera_mh.utils.conversation_utils import build_langchain_messages
from vera_mh.utils.debug import debug_print
from vera_mh.utils.role import Role

from .config import Config
from .llm_interface import (
JudgeLLM,
Role,
ensure_pydantic_response,
extract_structured_invoke_result,
)
Expand Down
4 changes: 3 additions & 1 deletion src/vera_mh/llm_clients/llm_factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Optional

from .llm_interface import JudgeLLM, LLMInterface, Role
from vera_mh.utils.role import Role

from .llm_interface import JudgeLLM, LLMInterface


class LLMFactory:
Expand Down
11 changes: 2 additions & 9 deletions src/vera_mh/llm_clients/llm_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from abc import ABC, abstractmethod
from collections.abc import Awaitable, Callable
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Protocol, Type, TypeVar

from pydantic import BaseModel, ValidationError

from vera_mh.utils.role import Role

T = TypeVar("T", bound=BaseModel)
R = TypeVar("R")

Expand Down Expand Up @@ -113,14 +114,6 @@ class LLMGenerationFailed(Exception):
"""Raised when an LLM call fails after all retry attempts are exhausted."""


class Role(Enum):
"""Role of the LLM in a conversation."""

PERSONA = "persona" # User roleplaying as a human seeking help
PROVIDER = "provider" # Chatbot providing support
JUDGE = "judge" # Judge role, used for judge operations


# Default prompt sent to the LLM when starting a conversation (no first_message set).
DEFAULT_START_PROMPT = "Start the conversation based on the system prompt"

Expand Down
3 changes: 2 additions & 1 deletion src/vera_mh/llm_clients/ollama_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

from vera_mh.utils.conversation_utils import format_conversation_as_string
from vera_mh.utils.debug import debug_print
from vera_mh.utils.role import Role

from .config import Config
from .llm_interface import LLMInterface, Role
from .llm_interface import LLMInterface


class OllamaLLM(LLMInterface):
Expand Down
2 changes: 1 addition & 1 deletion src/vera_mh/llm_clients/openai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from vera_mh.utils.conversation_utils import build_langchain_messages
from vera_mh.utils.debug import debug_print
from vera_mh.utils.role import Role

from .config import Config
from .llm_interface import (
JudgeLLM,
Role,
ensure_pydantic_response,
extract_structured_invoke_result,
)
Expand Down
2 changes: 1 addition & 1 deletion src/vera_mh/utils/conversation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from langchain_core.messages import AIMessage, BaseMessage, HumanMessage

from vera_mh.llm_clients.llm_interface import Role
from vera_mh.utils.naming import add_timestamp_to_path
from vera_mh.utils.role import Role

from .debug import debug_print

Expand Down
11 changes: 11 additions & 0 deletions src/vera_mh/utils/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Who is speaking in a conversation, or judging one."""

from enum import Enum


class Role(Enum):
"""Role of the LLM in a conversation."""

PERSONA = "persona" # User roleplaying as a human seeking help

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be user/chatbot or are we making the change later?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change will be made leter

PROVIDER = "provider" # Chatbot providing support
JUDGE = "judge" # Judge role, used for judge operations
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def mock_llm() -> MockLLM:
@pytest.fixture
def mock_persona() -> MockLLM:
"""Mock LLM configured as a persona."""
from vera_mh.llm_clients.llm_interface import Role
from vera_mh.utils.role import Role

return MockLLM(
name="mock-persona",
Expand All @@ -152,7 +152,7 @@ def mock_persona() -> MockLLM:
@pytest.fixture
def mock_agent() -> MockLLM:
"""Mock LLM configured as a chatbot agent."""
from vera_mh.llm_clients.llm_interface import Role
from vera_mh.utils.role import Role

return MockLLM(
name="mock-agent",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_conversation_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from tests.mocks.mock_llm import MockLLM
from vera_mh.generate.runner import ConversationRunner
from vera_mh.llm_clients.llm_interface import Role
from vera_mh.utils.role import Role


def create_test_runner(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_vera_pipeline_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

from tests.mocks.mock_llm import MockLLM
from vera_mh import cli as vera
from vera_mh.llm_clients import Role
from vera_mh.llm_clients.config import Config
from vera_mh.llm_clients.llm_factory import LLMFactory
from vera_mh.utils.role import Role
from vera_mh.vera_cli import config as cli_config

# Read from Config so tests/integration/test_model_availability.py catches a
Expand Down
3 changes: 2 additions & 1 deletion tests/mocks/mock_llm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Dict, List, Optional, Type, TypeVar

from vera_mh.llm_clients.llm_interface import JudgeLLM, LLMGenerationFailed, Role
from vera_mh.llm_clients.llm_interface import JudgeLLM, LLMGenerationFailed
from vera_mh.utils.role import Role

T = TypeVar("T")

Expand Down
3 changes: 2 additions & 1 deletion tests/safe_changes/full_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
)
from vera_mh.judge.rubric_config import RubricConfig
from vera_mh.llm_clients.llm_factory import LLMFactory
from vera_mh.llm_clients.llm_interface import JudgeLLM, Role
from vera_mh.llm_clients.llm_interface import JudgeLLM
from vera_mh.utils.conversation_utils import format_conversation_summary
from vera_mh.utils.role import Role
from vera_mh.vera_cli import config as cli_config

REPO_ROOT = Path(__file__).resolve().parents[2]
Expand Down
3 changes: 2 additions & 1 deletion tests/safe_changes/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

from vera_mh import cli as vera
from vera_mh.llm_clients.llm_factory import LLMFactory
from vera_mh.llm_clients.llm_interface import JudgeLLM, Role
from vera_mh.llm_clients.llm_interface import JudgeLLM
from vera_mh.utils.role import Role
from vera_mh.vera_cli import config as cli_config

REPO_ROOT = Path(__file__).resolve().parents[2]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/generate/test_conversation_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from vera_mh.llm_clients.llm_interface import (
DEFAULT_START_PROMPT,
LLMGenerationFailed,
Role,
)
from vera_mh.utils.role import Role


@pytest.mark.unit
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/generate/test_conversation_turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from langchain_core.messages import AIMessage, HumanMessage

from vera_mh.generate.conversation_turn import ConversationTurn
from vera_mh.llm_clients import Role
from vera_mh.utils.role import Role


class TestConversationTurnCreation:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ from unittest.mock import patch

import pytest

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.my_provider_llm import MyProviderLLM
from vera_mh.utils.role import Role

from .test_base_llm import TestJudgeLLMBase
from .test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import pytest

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.config import Config
from vera_mh.utils.role import Role

# ============================================================================
# Mock Response Factories
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_azure_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import pytest
from pydantic import BaseModel, Field

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.azure_llm import AzureLLM
from vera_mh.llm_clients.config import Config
from vera_mh.llm_clients.llm_interface import LLMGenerationFailed
from vera_mh.utils.role import Role

from .test_base_llm import TestJudgeLLMBase
from .test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_base_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def get_mock_patches(self):
import pytest
from pydantic import BaseModel, Field

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.llm_interface import (
JudgeLLM,
LLMGenerationFailed,
LLMInterface,
)
from vera_mh.utils.role import Role

from .test_helpers import (
assert_iso_timestamp,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_claude_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import pytest

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.claude_llm import ClaudeLLM
from vera_mh.llm_clients.config import Config
from vera_mh.llm_clients.llm_interface import LLMGenerationFailed
from vera_mh.utils.role import Role

from .test_base_llm import TestJudgeLLMBase
from .test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_endpoint_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import pytest

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.endpoint_llm import EndpointLLM
from vera_mh.llm_clients.llm_interface import DEFAULT_START_PROMPT, LLMGenerationFailed
from vera_mh.utils.role import Role

from .test_base_llm import TestLLMBase
from .test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_gemini_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import pytest
from langchain_core.messages import AIMessage

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.config import Config
from vera_mh.llm_clients.gemini_llm import (
_STRUCTURED_OUTPUT_MAX_LOG_CHARS,
GeminiLLM,
)
from vera_mh.llm_clients.llm_interface import LLMGenerationFailed
from vera_mh.utils.role import Role

from .test_base_llm import TestJudgeLLMBase
from .test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from datetime import datetime
from typing import Any, Dict, Optional

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.llm_interface import LLMGenerationFailed, LLMInterface
from vera_mh.utils.role import Role

# ============================================================================
# Metadata Assertions
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_llm_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import pytest

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.azure_llm import AzureLLM
from vera_mh.llm_clients.claude_llm import ClaudeLLM
from vera_mh.llm_clients.gemini_llm import GeminiLLM
from vera_mh.llm_clients.llm_factory import LLMFactory
from vera_mh.llm_clients.ollama_llm import OllamaLLM
from vera_mh.llm_clients.openai_llm import OpenAILLM
from vera_mh.utils.role import Role


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/llm_clients/test_llm_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import pytest
from pydantic import BaseModel

from vera_mh.llm_clients import Role
from vera_mh.llm_clients.llm_interface import (
LLMGenerationFailed,
LLMInterface,
ensure_pydantic_response,
extract_structured_invoke_result,
)
from vera_mh.utils.role import Role


class ConcreteLLM(LLMInterface):
Expand Down
Loading
Loading