Convert the raw input messages to a list of dicts. Args: inputs: raw input messages. Returns: list(dict): The preprocessed input messages. Will return None if failed to preprocess the input.
(self, inputs)
| 102 | return 'unknown' |
| 103 | |
| 104 | def preproc_content(self, inputs): |
| 105 | """Convert the raw input messages to a list of dicts. |
| 106 | |
| 107 | Args: |
| 108 | inputs: raw input messages. |
| 109 | |
| 110 | Returns: |
| 111 | list(dict): The preprocessed input messages. Will return None if failed to preprocess the input. |
| 112 | """ |
| 113 | if self.check_content(inputs) == 'str': |
| 114 | return [dict(type='text', value=inputs)] |
| 115 | elif self.check_content(inputs) == 'dict': |
| 116 | assert 'type' in inputs and 'value' in inputs |
| 117 | return [inputs] |
| 118 | elif self.check_content(inputs) == 'liststr': |
| 119 | res = [] |
| 120 | for s in inputs: |
| 121 | mime, pth = parse_file(s) |
| 122 | if mime is None or mime == 'unknown': |
| 123 | res.append(dict(type='text', value=s)) |
| 124 | else: |
| 125 | res.append(dict(type=mime.split('/')[0], value=pth)) |
| 126 | return res |
| 127 | elif self.check_content(inputs) == 'listdict': |
| 128 | for item in inputs: |
| 129 | assert 'type' in item and 'value' in item |
| 130 | mime, s = parse_file(item['value']) |
| 131 | if mime is None: |
| 132 | assert item['type'] == 'text', item['value'] |
| 133 | else: |
| 134 | assert mime.split('/')[0] == item['type'] |
| 135 | item['value'] = s |
| 136 | return inputs |
| 137 | else: |
| 138 | return None |
| 139 | |
| 140 | # May exceed the context windows size, so try with different turn numbers. |
| 141 | def chat_inner(self, inputs, **kwargs): |
no test coverage detected