Base Module¶
- class oscopilot.modules.base_module.BaseModule[source]¶
Bases:
object- extract_information(message, begin_str='[BEGIN]', end_str='[END]')[source]¶
Extracts substrings from a message that are enclosed within specified begin and end markers.
- Parameters:
message (str) – The message from which information is to be extracted.
begin_str (str) – The marker indicating the start of the information to be extracted.
end_str (str) – The marker indicating the end of the information to be extracted.
- Returns:
A list of extracted substrings found between the begin and end markers.
- Return type:
list[str]
- extract_json_from_string(text)[source]¶
Identifies and extracts JSON data embedded within a given string.
This method searches for JSON data within a string, specifically looking for JSON blocks that are marked with
`json`notation. It attempts to parse and return the first JSON object found.- Parameters:
text (str) – The text containing the JSON data to be extracted.
- Returns:
The parsed JSON data as a dictionary if successful. str: An error message indicating a parsing error or that no JSON data was found.
- Return type:
dict
- extract_list_from_string(text)[source]¶
Extracts a list of task descriptions from a given string containing enumerated tasks. This function ensures that only text immediately following a numbered bullet is captured, and it stops at the first newline character or at the next number, preventing the inclusion of subsequent non-numbered lines or empty lines.
Parameters: text (str): A string containing multiple enumerated tasks. Each task is numbered and followed by its description.
Returns: list[str]: A list of strings, each representing the description of a task extracted from the input string.