(text)
| 6 | logger = logging.getLogger(__name__) |
| 7 | |
| 8 | def 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 | |
| 18 | def 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 |
no test coverage detected