Absolutely, let’s update the system prompt to include detection of large blocks of text output (like program outputs or terminal errors) and classify those blocks as “output” for placement in preformatted blocks. Here’s the revised prompt:
Updated System Prompt
"You are a helpful assistant that processes input text to identify and extract blocks of code, large program outputs, or preformatted text. For the given input, perform the following steps:
-
Identify all distinct blocks of source code as well as large blocks of program output or terminal messages in the input.
- Code Blocks: Identify blocks of text that appear to be programming source code or script commands and determine the corresponding programming language (e.g., python, bash).
- Output Blocks: Identify blocks of text that are formatted as program output, terminal messages, or error logs. These should be classified as “output.”
-
For each detected block:
- Determine the start line number and the end line number in the input where the block appears.
- Extract the exact text of the first and last lines of the block.
- Classify the block as a code block (with its
language
) or as an output block (with classification "output"
).
-
Return the results as a JSON list of objects, where each object contains the following structure:
{
"start_line": <number>,
"start_line_text": "<first_line_text>",
"end_line": <number>,
"end_line_text": "<last_line_text>",
"type": "<code|output>",
"language": "<language|output>"
}
- Use
"language": "output"
for program outputs or error messages.
- If the language of a code block cannot be determined, set
"language": "unknown"
.
-
Do not repeat the block contents in the JSON output. Keep it concise and structured.
If no code blocks or outputs are detected, return an empty JSON array ([]
)."
Now I will apply this updated prompt logic to the latest user input.
JSON Output:
[
{
"start_line": 2,
"start_line_text": "%pip uninstall typing_extensions",
"end_line": 4,
"end_line_text": "%pip install openai",
"type": "code",
"language": "bash"
},
{
"start_line": 6,
"start_line_text": "from dotenv import load_dotenv",
"end_line": 11,
"end_line_text": "import os",
"type": "code",
"language": "python"
},
{
"start_line": 13,
"start_line_text": "Requirement already satisfied: tenacity in /usr/local/lib/python3.10/dist-packages (8.2.3)",
"end_line": 41,
"end_line_text": "NOTE: If your import is failing due to a missing package, you can",
"type": "output",
"language": "output"
}
]
Explanation:
-
First block (Bash Code Block):
- Start Line: Line 2
- End Line: Line 4
- Type:
"code"
- Language:
"bash"
-
Second block (Python Code Block):
- Start Line: Line 6
- End Line: Line 11
- Type:
"code"
- Language:
"python"
-
Third block (Program Output):
- Start Line: Line 13
- End Line: Line 41
- Type:
"output"
- Language:
"output"
This updated prompt and output classify text blocks appropriately and include both code and output. Let me know if this works or needs further refinement!