I've encountered an issue in python. I have a string that contains both a message and code, and I need to separate them and pass each to different functions. An example:
text = """
Can you change sum operation to multiplication?
def process(a: int, b: int):
print(a + b)
"""
The text and code sections can appear in any order. I've tried using regex to separate them, but it fails with other languages. Do you have any suggestions on how to handle this without involving LLMS?
Thanks!
I've searched about how LLMS differentiate between code and text and found out they use Markdown formatting to separate them, like:
"See if anything is wrong with this code:"
```python
def process(a: int, b: int):
print(a - b)
- ```
and I'm afraid I cannot follow this structure because the given input or string is not categorized like this
def,import,classand whitespace, but that is just an idea, it depends on how your Python files are formatted.other languages.