openedx_ai_extensions.functions package#
Submodules#
openedx_ai_extensions.functions.decorators module#
LLM function definitions and utilities for AI-powered workflows.
- openedx_ai_extensions.functions.decorators.llm_tool(schema)#
Decorator to register a function as an LLM function.
This decorator can be applied to both regular functions and instance methods. For methods, the instance must be registered using
register_instance()before the method can be called viaAVAILABLE_TOOLS.- Parameters:
schema (dict) – JSON schema for the function.
Examples
Regular function example:
@llm_tool( schema={ "name": "my_function", "description": "Function description", "parameters": { "type": "object", "properties": { "param1": { "type": "string", "description": "..." } }, "required": ["param1"] } } ) def my_function(param1): """Function description.""" return result
Instance method example:
class MyClass: @llm_tool(schema={...}) def my_method(self, param1): """Method description.""" return result
Registering the instance:
my_instance = MyClass() register_instance(my_instance)
- openedx_ai_extensions.functions.decorators.register_instance(instance)#
Register a class instance to make its decorated methods available.
This should be called when a class with @llm_tool decorated methods is instantiated and you want those methods to be callable via AVAILABLE_TOOLS.
- Parameters:
instance – The class instance to register
Example
processor = OpenEdXProcessor(config) register_instance(processor)
openedx_ai_extensions.functions.external_function_example module#
LLM function definitions and utilities for AI-powered workflows.
- openedx_ai_extensions.functions.external_function_example.roll_dice(n_dice=1, **kwargs)#
Simulate rolling a specified number of six-sided dice.
Module contents#
Import function modules to ensure decorated functions are registered.