Skip to content
Open
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
4 changes: 2 additions & 2 deletions backend/openedx_ai_extensions/processors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Processors module - handles data extraction and AI processing
"""

from .educator_assistant_processor import EducatorAssistantProcessor
from .llm_processor import LLMProcessor
from .llm.educator_assistant_processor import EducatorAssistantProcessor
from .llm.llm_processor import LLMProcessor
from .openedx.content_libraries_processor import ContentLibraryProcessor
from .openedx.openedx_processor import OpenEdXProcessor
from .openedx.submission_processor import SubmissionProcessor
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from litellm import completion

from openedx_ai_extensions.processors.litellm_base_processor import LitellmProcessor
from openedx_ai_extensions.processors.llm_providers import adapt_to_provider
from openedx_ai_extensions.processors.llm.litellm_base_processor import LitellmProcessor
from openedx_ai_extensions.processors.llm.providers import adapt_to_provider

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from litellm import completion, responses

from openedx_ai_extensions.functions.decorators import AVAILABLE_TOOLS
from openedx_ai_extensions.processors.litellm_base_processor import LitellmProcessor
from openedx_ai_extensions.processors.llm_providers import adapt_to_provider, after_tool_call_adaptations
from openedx_ai_extensions.processors.llm.litellm_base_processor import LitellmProcessor
from openedx_ai_extensions.processors.llm.providers import adapt_to_provider, after_tool_call_adaptations

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from opaque_keys.edx.locator import CourseLocator

from openedx_ai_extensions.functions.decorators import llm_tool, register_instance
from openedx_ai_extensions.processors.component_extractors import (
from openedx_ai_extensions.processors.openedx.utils.component_extractors import (
COMPONENT_EXTRACTORS,
extract_generic_info,
extract_problem_info,
Expand Down
Empty file.
9 changes: 6 additions & 3 deletions backend/tests/test_component_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from bs4 import BeautifulSoup
from django.conf import settings

from openedx_ai_extensions.processors.component_extractors import (
from openedx_ai_extensions.processors.openedx.utils.component_extractors import (
_assemble_problem_text,
_check_show_answer,
_clean_noisy_tags,
Expand Down Expand Up @@ -110,7 +110,10 @@ def test_html_to_text_with_embeds():

def test_html_to_text_invalid_html():
"""Test html_to_text returns raw HTML if parsing fails."""
with patch("openedx_ai_extensions.processors.component_extractors.BeautifulSoup", side_effect=Exception):
with patch(
"openedx_ai_extensions.processors.openedx.utils.component_extractors.BeautifulSoup",
side_effect=Exception,
):
assert html_to_text("<bad>") == "<bad>"


Expand Down Expand Up @@ -530,7 +533,7 @@ def test_process_problem_html_empty_input():
assert _process_problem_html(None, False) == ""


@patch("openedx_ai_extensions.processors.component_extractors.BeautifulSoup")
@patch("openedx_ai_extensions.processors.openedx.utils.component_extractors.BeautifulSoup")
def test_process_problem_html_exception_handling(mock_bs):
"""Test that if processing fails, raw HTML is returned."""
# Force an exception during processing
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/test_integration_base_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def mock_streaming_response():
final_chunk.usage = MagicMock(total_tokens=150)
yield final_chunk

with patch("openedx_ai_extensions.processors.llm_processor.completion") as mock_completion, \
with patch("openedx_ai_extensions.processors.llm.llm_processor.completion") as mock_completion, \
patch("openedx_ai_extensions.processors.openedx.openedx_processor.OpenEdXProcessor.process") as mock_openedx:

mock_completion.return_value = mock_streaming_response()
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_library_questions_assistant_profile_integration(
}

educator_path = (
"openedx_ai_extensions.processors.educator_assistant_processor."
"openedx_ai_extensions.processors.llm.educator_assistant_processor."
"EducatorAssistantProcessor.process"
)
openedx_path = (
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/test_litellm_base_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.contrib.auth import get_user_model

from openedx_ai_extensions.functions.decorators import TOOLS_SCHEMA
from openedx_ai_extensions.processors.litellm_base_processor import LitellmProcessor
from openedx_ai_extensions.processors.llm.litellm_base_processor import LitellmProcessor

User = get_user_model()

Expand Down Expand Up @@ -598,7 +598,7 @@ def test_streaming_with_tools_disables_streaming(mock_settings): # pylint: disa
"enabled_tools": ["roll_dice"],
}
}
with patch('openedx_ai_extensions.processors.litellm_base_processor.logger') as mock_logger:
with patch('openedx_ai_extensions.processors.llm.litellm_base_processor.logger') as mock_logger:
processor = LitellmProcessor(config=config, user_session=None)

# Verify streaming was disabled
Expand Down
26 changes: 13 additions & 13 deletions backend/tests/test_llm_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import BlockUsageLocator

from openedx_ai_extensions.processors.llm_processor import LLMProcessor
from openedx_ai_extensions.processors.llm.llm_processor import LLMProcessor
from openedx_ai_extensions.workflows.models import AIWorkflowProfile, AIWorkflowScope, AIWorkflowSession

User = get_user_model()
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self, content, is_stream=True):
# ============================================================================

@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.responses")
@patch("openedx_ai_extensions.processors.llm.llm_processor.responses")
def test_chat_with_context_initialization_non_stream(
mock_responses, llm_processor, user_session # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_chat_with_context_initialization_non_stream(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.responses")
@patch("openedx_ai_extensions.processors.llm.llm_processor.responses")
def test_chat_with_context_continuation_non_stream(
mock_responses, llm_processor, user_session # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -199,7 +199,7 @@ def test_chat_with_context_continuation_non_stream(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_summarize_content_non_stream(
mock_completion, llm_processor # pylint: disable=redefined-outer-name
):
Expand All @@ -223,7 +223,7 @@ def test_summarize_content_non_stream(
# ============================================================================

@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.responses")
@patch("openedx_ai_extensions.processors.llm.llm_processor.responses")
def test_chat_with_context_streaming(
mock_responses, llm_processor # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -260,7 +260,7 @@ def test_chat_with_context_streaming(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_summarize_content_streaming(
mock_completion, llm_processor # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_summarize_content_streaming(
# ============================================================================

@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.responses")
@patch("openedx_ai_extensions.processors.llm.llm_processor.responses")
def test_chat_error_handling(
mock_responses, llm_processor # pylint: disable=redefined-outer-name
):
Expand All @@ -314,7 +314,7 @@ def test_chat_error_handling(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_completion_error_handling_stream(
mock_completion, llm_processor # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -488,7 +488,7 @@ def test_mcp_configs_empty_allowed_list(user_session, settings): # pylint: disa
# ============================================================================

@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_call_with_custom_prompt_function(
mock_completion, user_session, settings # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -529,7 +529,7 @@ def test_call_with_custom_prompt_function(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_call_with_custom_prompt_when_function_not_specified(
mock_completion, user_session, settings # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -563,7 +563,7 @@ def test_call_with_custom_prompt_when_function_not_specified(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_custom_prompt_overrides_system_role_in_completion(
mock_completion, user_session, settings # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -602,7 +602,7 @@ def test_custom_prompt_overrides_system_role_in_completion(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.responses")
@patch("openedx_ai_extensions.processors.llm.llm_processor.responses")
def test_custom_prompt_in_chat_with_context(
mock_responses, user_session, settings # pylint: disable=redefined-outer-name
):
Expand Down Expand Up @@ -645,7 +645,7 @@ def test_custom_prompt_in_chat_with_context(


@pytest.mark.django_db
@patch("openedx_ai_extensions.processors.llm_processor.completion")
@patch("openedx_ai_extensions.processors.llm.llm_processor.completion")
def test_call_with_custom_prompt_streaming(
mock_completion, user_session, settings # pylint: disable=redefined-outer-name
):
Expand Down