MCPcopy Index your code
hub / github.com/algorithmicsuperintelligence/optillm / extract_code_from_prompt

Function extract_code_from_prompt

optillm/rto.py:8–16  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

6logger = logging.getLogger(__name__)
7
8def extract_code_from_prompt(text):
9 pattern = r'```(?:[\w-]+)?\n(.*?)```'
10 match = re.search(pattern, text, re.DOTALL)
11
12 if match:
13 return match.group(1).strip()
14 else:
15 logger.warning("Could not extract code from prompt. Returning original text.")
16 return text
17
18def round_trip_optimization(system_prompt: str, initial_query: str, client, model: str, request_config: dict = None, request_id: str = None) -> str:
19 rto_completion_tokens = 0

Callers 1

round_trip_optimizationFunction · 0.85

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected