MCPcopy Create free account
hub / github.com/GPTScan/GPTScan / split_answer_section

Function split_answer_section

src/utils.py:12–29  ·  view source on GitHub ↗

Split the response into sections based on the answer keys.

(answer_keys:List[str], response:str)

Source from the content-addressed store, hash-verified

10logger = logging.getLogger(__name__)
11
12def split_answer_section(answer_keys:List[str], response:str) -> Dict[str, str]:
13 """
14 Split the response into sections based on the answer keys.
15 """
16 current_section = None
17 answer = {}
18 for line in response.splitlines():
19 is_key_flag = False
20 for key in answer_keys:
21 if line.startswith(key):
22 current_section = key
23 answer[key] = line[len(key)+1:].strip()
24 is_key_flag = True
25 break
26 if not is_key_flag and current_section is not None:
27 answer[current_section] += line
28
29 return answer
30
31def try_to_handle_too_long_code(render_target_func:Callable, code_segments:List[str], statements:List[str], *args) -> List[str]:
32 """

Callers 1

ask_for_staticFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected