openedx_ai_extensions.processors.llm package#
Subpackages#
Submodules#
openedx_ai_extensions.processors.llm.educator_assistant_processor module#
LLM Processing using LiteLLM for multiple providers
- class openedx_ai_extensions.processors.llm.educator_assistant_processor.EducatorAssistantProcessor(user=None, context=None, **kwargs)#
Bases:
LitellmProcessorHandles AI/LLM processing operations
- generate_quiz_questions(input_data)#
Generate quiz questions based on the content provided
- process(*args, **kwargs)#
Process based on configured function
- refine_quiz_question(input_data)#
Refine an existing quiz question instead of generating a new one.
openedx_ai_extensions.processors.llm.litellm_base_processor module#
Base processor for LiteLLM-based processors
- class openedx_ai_extensions.processors.llm.litellm_base_processor.LitellmProcessor(config=None, user_session=None, extra_params=None)#
Bases:
objectBase class for processors that use LiteLLM for AI/LLM operations
- get_provider()#
Return the configured provider
- get_usage()#
Return usage data if available
- process(*args, **kwargs)#
Process based on configured function - must be implemented by subclasses
openedx_ai_extensions.processors.llm.llm_processor module#
Responses processor for threaded AI conversations using LiteLLM
- class openedx_ai_extensions.processors.llm.llm_processor.LLMProcessor(config=None, user_session=None, extra_params=None)#
Bases:
LitellmProcessorHandles AI processing using LiteLLM with support for threaded conversations.
This processor accepts an optional extra_params argument in its constructor, which is passed directly to the LitellmProcessor base class. This allows you to configure advanced LiteLLM parameters such as:
model: str (e.g., ‘openai/gpt-4’)
temperature: float (e.g., 0.7)
max_tokens: int (e.g., 150)
api_key: str
response_format: dict
and any other parameters supported by the underlying LiteLLM client
- answer_question()#
Answer a specific question based on the provided content
- call_with_custom_prompt()#
Call LLM with a completely custom prompt provided in custom_prompt config.
- chat_with_context()#
Chat with context given from OpenEdx course content. Either initializes a new thread or continues an existing one.
- Parameters:
context – Course content context
input_data – Optional input data to continue conversation
- Returns:
Response from the API
- Return type:
- explain_like_five()#
Explain content in very simple terms, like explaining to a 5-year-old Short, simple language that anyone can understand
- fetch_remote_thread(response_id)#
Fetch the full remote conversation thread by walking the previous_response_id chain via LiteLLM.
Uses provider credentials from self.extra_params resolved during __init__.
- Parameters:
response_id – The LiteLLM-wrapped response ID.
- Returns:
- Chronologically ordered list of response dicts, each containing
id, created_at, model, tokens, input messages, and output messages.
- Return type:
- generate_flashcards()#
Example method showing how to generate flashcards from content.
- greet_from_llm()#
Simple test to greet from the LLM and mention which model is being used.
- process(*args, **kwargs)#
Process based on configured function
- summarize_content()#
Summarize content using LiteLLM
openedx_ai_extensions.processors.llm.tool_executor module#
Stateless helpers for executing LLM tool calls and accumulating streaming tool-call deltas.
Extracted from LLMProcessor so they can be tested in isolation and reused by any processor that needs function-calling support.
- class openedx_ai_extensions.processors.llm.tool_executor.ToolExecutor#
Bases:
objectPure-logic helper for LLM tool / function-call handling.
Every method is either a static method or a class method — the class carries no instance state. Instantiate it (or call the methods directly via the class) from any processor that needs tool execution or streaming-delta accumulation.
- static accumulate_tool_call_chunk(buffer: dict, tc_chunk) None#
Merge a single streaming tool-call delta into buffer.