Skip to content

Instantly share code, notes, and snippets.

@psykhi
Last active April 19, 2024 18:28
Show Gist options
  • Save psykhi/f9a7acd9065acc8467d74e87585eeeb8 to your computer and use it in GitHub Desktop.
Save psykhi/f9a7acd9065acc8467d74e87585eeeb8 to your computer and use it in GitHub Desktop.

Prompt:

JSON mode ON
You produce valid JSON. ALL your messages immediately start with {
You always the follow the provided output JSON schema.

Output JSON Schema: {'$defs': {}, 'type': 'object', 'properties': {'response': {'description': 'Evaluation of the action an agent is going to take given its trajectory.', 'properties': {'observations': {'description': 'Detailed observations of where we are and if the action makes sense.', 'title': 'Observations', 'type': 'string'}, 'right_track': {'description': 'Whether the action is on the right track.', 'title': 'Right Track', 'type': 'boolean'}, 'feedback': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'default': None, 'description': 'Feedback for the agent if not on the right track. Could be used to course correct.', 'title': 'Feedback'}}, 'required': ['observations', 'right_track'], 'title': 'Evaluation', 'type': 'object'}}, 'required': ['response']}

Instructions:
 Operation: evaluate_action

Operation description: 
    Evaluate the action an agent is going to take given its trajectory and the actions it can take.
    You are given the problem it is trying to solve.
    Be very diligent in evaluating the action, especially if it is an edit.
    

Input: {"trajectory": {"actions": [], "gained_knowledge": ["Understanding the context of a problem in the code and validating the existence and correct implementation of any new functions or variables introduced before making an edit."]}, "action": {"thoughts": "Before making any edit, I need to make sure I have seen all the necessary code. I will start by checking the `jsonrep.py` file where the problem was identified. I will view the entire file and make sure I understand the context of line 227 where the issue is located. I will check if there are any functions or variables introduced that need to be validated before making the edit. I will also check if there are any other files or methods in the same file that I need to take a look at before making the edit.", "learning": "Understanding the context of a problem in the code and validating the existence and correct implementation of any new functions or variables introduced before making an edit.", "action_name": "search", "action_input": {"regex": "jsonrep\\.py"}}, "possible_actions": {"$defs": {"Edit": {"description": "Edit a file in the repository by replacing a code block.\nBefore applying edits, validate the existence and correct implementation of any new functions or variables introduced.\nMake sure you have seen all the code necessary to make the edit. View entire function bodies first.\nThe edited code CANNOT refer to unknown variables or functions.\nEdits can only be done in files and lines that have already been viewed.", "properties": {"file_path": {"description": "Path of the file to edit.", "title": "File Path", "type": "string"}, "seen_all_needed_code": {"description": "Have you seen all the code needed to make the edit? Did you view the entire body of the function you are about to modify? You must be SURE.", "title": "Seen All Needed Code", "type": "boolean"}, "no_other_file_viewing_needed": {"description": "Did you take a good look at other methods/classes in the file that were provided in the file outline? Are you sure you don't need anything else? You must be SURE.", "title": "No Other File Viewing Needed", "type": "boolean"}, "edit_contains_all_needed_code": {"description": "Will you write all the code you need to replace the old code? You must guarantee that you will not take shortcuts and be thorough.", "title": "Edit Contains All Needed Code", "type": "boolean"}, "short_description": {"description": "A short description of the edit where you identify the lines to edit and what to do.", "title": "Short Description", "type": "string"}, "code_to_replace": {"description": "The code that will be replaced. Keep line numbers intact.", "title": "Code To Replace", "type": "string"}, "start_line": {"description": "The index of the first line that will be replaced.", "title": "Start Line", "type": "integer"}, "end_line": {"description": "Line number to end editing at. All lines betwee start_line and end_line are replaced.", "title": "End Line", "type": "integer"}, "new_code": {"description": "The new code to replace the old code with, WITHOUT line numbers. Indentation MUST be correct. Keep all leading whitespaces and newlines intact. Example:'    def new_action(self):\n        pass\n'", "title": "New Code", "type": "string"}, "no_unknowns": {"default": false, "description": "If true, the edited code does not refer to unknown variables or functions. The edited code does not contain placeholders for future implementation.", "title": "No Unknowns", "type": "boolean"}}, "required": ["file_path", "seen_all_needed_code", "no_other_file_viewing_needed", "edit_contains_all_needed_code", "short_description", "code_to_replace", "start_line", "end_line", "new_code"], "title": "Edit", "type": "object"}, "Edits": {"description": "Specify a list of edits to make", "properties": {"edits": {"description": "List of edits to make.", "items": {"$ref": "#/$defs/Edit"}, "title": "Edits", "type": "array"}}, "required": ["edits"], "title": "Edits", "type": "object"}, "Search": {"description": "Search for a regex in the repository. Will search through file names and their contents.", "properties": {"regex": {"description": "Regex to search for. Matches will be returned", "title": "Regex", "type": "string"}}, "required": ["regex"], "title": "Search", "type": "object"}, "Submit": {"description": "We have fixed the problem and written tests for it. Submit the solution.", "properties": {"done": {"title": "Done", "type": "boolean"}}, "required": ["done"], "title": "Submit", "type": "object"}, "ViewFile": {"description": "View a file in the repository. Don't hesitate to call this action multiple times to move around the file and to get more context.", "properties": {"file_path": {"title": "File Path", "type": "string"}, "cursor_line": {"description": "The line number to start from.", "title": "Cursor Line", "type": "integer"}, "before": {"description": "Number of lines to display before the cursor line.", "minimum": 50, "title": "Before", "type": "integer"}, "after": {"description": "Number of lines to display after the cursor line.", "minimum": 50, "title": "After", "type": "integer"}}, "required": ["file_path", "cursor_line", "before", "after"], "title": "ViewFile", "type": "object"}}, "properties": {"thoughts": {"description": "Step by step reasoning about the action to take. Make sure you have viewed all the necessary code before making an edit. It's always okay to look at more code.", "title": "Thoughts", "type": "string"}, "learning": {"anyOf": [{"type": "string"}, {"type": "null"}], "description": "A useful learning that will help in the future.", "title": "Learning"}, "action_name": {"enum": ["search", "edits", "submit", "view_file"], "title": "Action Name", "type": "string"}, "action_input": {"anyOf": [{"$ref": "#/$defs/Search"}, {"$ref": "#/$defs/Edits"}, {"$ref": "#/$defs/Submit"}, {"$ref": "#/$defs/ViewFile"}], "title": "Action Input"}}, "required": ["thoughts", "learning", "action_name", "action_input"], "title": "Action", "type": "object"}, "problem": "from_json does not correctly convert BulkDataURI's in SQ data elements\n**Describe the bug**\r\nWhen a DICOM object contains large data elements in SQ elements and is converted to JSON, those elements are correctly turned into BulkDataURI's. However, when the JSON is converted back to DICOM using from_json, the BulkDataURI's in SQ data elements are not converted back and warnings are thrown.\r\n\r\n**Expected behavior**\r\nThe BulkDataURI's in SQ data elements get converted back correctly.\r\n\r\n**Steps To Reproduce**\r\nTake the `waveform_ecg.dcm` in the test data, convert it to JSON, and then convert the JSON to DICOM\r\n\r\n**Your environment**\r\nmodule       | version\r\n------       | -------\r\nplatform     | macOS-10.15.7-x86_64-i386-64bit\r\nPython       | 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)  [Clang 6.0 (clang-600.0.57)]\r\npydicom      | 2.1.0\r\ngdcm         | _module not found_\r\njpeg_ls      | _module not found_\r\nnumpy        | _module not found_\r\nPIL          | _module not found_\r\n\r\nThe problem is in `jsonrep.py` at line 227. I plan on submitting a pull-request today for this.\n"}

Output JSON:

Raw reponse:

"{\n\"response\": {\n\"observations\": \"The problem is identified in `jsonrep.py` at line 227. The issue is related to the conversion of BulkDataURI's in SQ data elements when converting from JSON to DICOM. The expected behavior is for the BulkDataURI's to be converted back correctly. The steps to reproduce the issue involve converting a specific DICOM file to JSON and then back to DICOM. The environment includes macOS-10.15.7, Python 3.8.2, and missing dependencies for pydicom, gdcm, jpeg\\_ls, numpy, and PIL.\",\n\"right_track\": true,\n\"feedback\": null\n}\n}"

Error:

Invalid escape: line 3 column 472 (char 487)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment