-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Handling Of Long Outputs (#328)
# Problem Cell outputs can be very long. For example, if we run a query (gcloud, SQL, etc...) the output could be very verbose. This output could eat up the entire context allocated for the input document. As a result, we might not have sufficiently meaningful context to prompt the model. There was another bug in our doc tailer. We were applying character limits to the rendered markdown. We were imposing this by tailing the lines. This could produce invalid markdown. For example, we might end up truncating the document in the middle of a code block so we wouldn't have the opening triple quotes for the code block. We might also include the output of the code block without including the code that it is output for. # Solution First, we impose character limits in a way that is aware of cell boundaries. We move truncation into the Block to Markdown conversion. The conversion now takes the maximum length for the output string. The conversion routine then figures out how much to allocate to the contents of the cell and its outputs. This allows truncation to happen in a way that can respect cell boundaries. Second, if we truncate the code block or output we output a string indicating that the output was truncated. We want the model to know that output was truncated. We update our prompt to tell the LLM to look for truncated output and to potentially deal with this by running commands that will provide less verbose output. Fix #299
- Loading branch information
Showing
8 changed files
with
151 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ Google Cloud service account [email protected]. | |
</reasoning> | ||
</example> | ||
|
||
* If the output of a command is really long it will be truncated as indicated by the string "<...stdout was truncated...>" | ||
* If the truncated output contains critical information to figure out what to do next, you should respond with a | ||
suggestion on how to run the command so as to produce just the information you need with less verbosity | ||
|
||
* If logging or SQL queries leads to truncated output, suggest alternative queries with | ||
clauses to restrict the output to the rows and fields you need | ||
* If dumping large JSON/YAML blobs leads to truncated output, provide a command to 1) save the data to a file and 2) then use tools like jq or yq to read the | ||
fields you need | ||
|
||
{{if .Examples}} | ||
Here are a bunch of examples of input documents along with the expected output. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ Google Cloud service account [email protected]. | |
</reasoning> | ||
</example> | ||
|
||
* If the output of a command is really long it will be truncated as indicated by the string "<...stdout was truncated...>" | ||
* If the truncated output contains critical information to figure out what to do next, you should respond with a | ||
suggestion on how to run the command so as to produce just the information you need with less verbosity | ||
|
||
* If logging or SQL queries leads to truncated output, suggest alternative queries with | ||
clauses to restrict the output to the rows and fields you need | ||
* If dumping large JSON/YAML blobs leads to truncated output, provide a command to 1) save the data to a file and 2) then use tools like jq or yq to read the | ||
fields you need | ||
|
||
|
||
Here are a bunch of examples of input documents along with the expected output. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ Google Cloud service account [email protected]. | |
</reasoning> | ||
</example> | ||
|
||
* If the output of a command is really long it will be truncated as indicated by the string "<...stdout was truncated...>" | ||
* If the truncated output contains critical information to figure out what to do next, you should respond with a | ||
suggestion on how to run the command so as to produce just the information you need with less verbosity | ||
|
||
* If logging or SQL queries leads to truncated output, suggest alternative queries with | ||
clauses to restrict the output to the rows and fields you need | ||
* If dumping large JSON/YAML blobs leads to truncated output, provide a command to 1) save the data to a file and 2) then use tools like jq or yq to read the | ||
fields you need | ||
|
||
|
||
Here's the actual document containing the problem or task to be solved: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters