Update app.py
Browse files
app.py
CHANGED
@@ -381,11 +381,18 @@ else:
|
|
381 |
# Function to replace code blocks with formatted versions
|
382 |
def replace_code_block(match):
|
383 |
code = match.group(1).strip()
|
384 |
-
|
|
|
|
|
385 |
|
386 |
# Replace code blocks
|
387 |
formatted_response = re.sub(r'```(.*?)```', replace_code_block, response, flags=re.DOTALL)
|
388 |
|
|
|
|
|
|
|
|
|
|
|
389 |
return formatted_response
|
390 |
async def run_github_editor(query: str, thread_id: str = "default"):
|
391 |
inputs = {"messages": [HumanMessage(content=query)]}
|
|
|
381 |
# Function to replace code blocks with formatted versions
|
382 |
def replace_code_block(match):
|
383 |
code = match.group(1).strip()
|
384 |
+
# Remove language specifier if present
|
385 |
+
code = re.sub(r'^(python|typescript|javascript)\n', '', code, flags=re.IGNORECASE)
|
386 |
+
return f"\n```\n{code}\n```\n"
|
387 |
|
388 |
# Replace code blocks
|
389 |
formatted_response = re.sub(r'```(.*?)```', replace_code_block, response, flags=re.DOTALL)
|
390 |
|
391 |
+
# Ensure proper formatting for file paths and inline code
|
392 |
+
formatted_response = re.sub(r'`([^`\n]+)`', r'`\1`', formatted_response)
|
393 |
+
|
394 |
+
return formatted_response
|
395 |
+
|
396 |
return formatted_response
|
397 |
async def run_github_editor(query: str, thread_id: str = "default"):
|
398 |
inputs = {"messages": [HumanMessage(content=query)]}
|