MCPcopy
hub / github.com/OS-Copilot/OS-Copilot / extract_information

Method extract_information

oscopilot/modules/base_module.py:16–36  ·  view source on GitHub ↗

Extracts substrings from a message that are enclosed within specified begin and end markers. Args: 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.

(self, message, begin_str='[BEGIN]', end_str='[END]')

Source from the content-addressed store, hash-verified

14 self.system_version = get_os_version()
15
16 def extract_information(self, message, begin_str='[BEGIN]', end_str='[END]'):
17 """
18 Extracts substrings from a message that are enclosed within specified begin and end markers.
19
20 Args:
21 message (str): The message from which information is to be extracted.
22 begin_str (str): The marker indicating the start of the information to be extracted.
23 end_str (str): The marker indicating the end of the information to be extracted.
24
25 Returns:
26 list[str]: A list of extracted substrings found between the begin and end markers.
27 """
28 result = []
29 _begin = message.find(begin_str)
30 _end = message.find(end_str)
31 while not (_begin == -1 or _end == -1):
32 result.append(message[_begin + len(begin_str):_end])
33 message = message[_end + len(end_str):]
34 _begin = message.find(begin_str)
35 _end = message.find(end_str)
36 return result
37
38 def extract_json_from_string(self, text):
39 """

Callers 4

update_toolMethod · 0.80
generate_toolMethod · 0.80
repair_toolMethod · 0.80
tool_code_filterMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected