Deadmon commited on
Commit
c9fc375
·
verified ·
1 Parent(s): 973a89e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -476,8 +476,13 @@ async def generate_and_edit(source_text, target_start, target_end, response_prom
476
  if "error" in response:
477
  return "Error: Failed to generate response", ""
478
  response_text = response["content"]
479
- api.editor.clipboard = response_text # Set clipboard to the API-generated response
480
- logger.info(f"Generated and set response to clipboard: {response_text}")
 
 
 
 
 
481
 
482
  # Step 4: Paste response into the target hole
483
  paste_result = api.editor.paste(chunk_id, target_start)
 
476
  if "error" in response:
477
  return "Error: Failed to generate response", ""
478
  response_text = response["content"]
479
+ # Extract only the response part after "Response for [TARGET]:" if present
480
+ response_match = re.search(r"Response for \[TARGET\]:\s*(.+)", response_text, re.DOTALL)
481
+ if response_match:
482
+ api.editor.clipboard = response_match.group(1).strip()
483
+ else:
484
+ api.editor.clipboard = response_text.strip() # Fallback to full response if no match
485
+ logger.info(f"Generated and set response to clipboard: {api.editor.clipboard}")
486
 
487
  # Step 4: Paste response into the target hole
488
  paste_result = api.editor.paste(chunk_id, target_start)