janus-llm 4.3.1__py3-none-any.whl → 4.3.5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. janus/__init__.py +1 -1
  2. janus/__main__.py +1 -1
  3. janus/_tests/evaluator_tests/EvalReadMe.md +85 -0
  4. janus/_tests/evaluator_tests/incose_tests/incose_large_test.json +39 -0
  5. janus/_tests/evaluator_tests/incose_tests/incose_small_test.json +17 -0
  6. janus/_tests/evaluator_tests/inline_comment_tests/mumps_inline_comment_test.m +71 -0
  7. janus/_tests/test_cli.py +3 -2
  8. janus/cli/aggregate.py +135 -0
  9. janus/cli/cli.py +111 -0
  10. janus/cli/constants.py +43 -0
  11. janus/cli/database.py +289 -0
  12. janus/cli/diagram.py +178 -0
  13. janus/cli/document.py +174 -0
  14. janus/cli/embedding.py +122 -0
  15. janus/cli/llm.py +187 -0
  16. janus/cli/partition.py +125 -0
  17. janus/cli/self_eval.py +149 -0
  18. janus/cli/translate.py +183 -0
  19. janus/converter/__init__.py +1 -1
  20. janus/converter/_tests/test_translate.py +2 -0
  21. janus/converter/converter.py +129 -93
  22. janus/converter/document.py +21 -14
  23. janus/converter/evaluate.py +20 -13
  24. janus/converter/translate.py +3 -3
  25. janus/embedding/collections.py +1 -1
  26. janus/language/alc/_tests/alc.asm +3779 -0
  27. janus/language/binary/_tests/hello.bin +0 -0
  28. janus/language/block.py +47 -12
  29. janus/language/file.py +1 -1
  30. janus/language/mumps/_tests/mumps.m +235 -0
  31. janus/language/treesitter/_tests/languages/fortran.f90 +416 -0
  32. janus/language/treesitter/_tests/languages/ibmhlasm.asm +16 -0
  33. janus/language/treesitter/_tests/languages/matlab.m +225 -0
  34. janus/llm/models_info.py +9 -1
  35. janus/metrics/_tests/asm_test_file.asm +10 -0
  36. janus/metrics/_tests/mumps_test_file.m +6 -0
  37. janus/metrics/_tests/test_treesitter_metrics.py +1 -1
  38. janus/metrics/prompts/clarity.txt +8 -0
  39. janus/metrics/prompts/completeness.txt +16 -0
  40. janus/metrics/prompts/faithfulness.txt +10 -0
  41. janus/metrics/prompts/hallucination.txt +16 -0
  42. janus/metrics/prompts/quality.txt +8 -0
  43. janus/metrics/prompts/readability.txt +16 -0
  44. janus/metrics/prompts/usefulness.txt +16 -0
  45. janus/parsers/code_parser.py +4 -4
  46. janus/parsers/doc_parser.py +12 -9
  47. janus/parsers/parser.py +7 -0
  48. janus/parsers/partition_parser.py +6 -4
  49. janus/parsers/reqs_parser.py +8 -5
  50. janus/parsers/uml.py +5 -4
  51. janus/prompts/prompt.py +2 -2
  52. janus/prompts/templates/README.md +30 -0
  53. janus/prompts/templates/basic_aggregation/human.txt +6 -0
  54. janus/prompts/templates/basic_aggregation/system.txt +1 -0
  55. janus/prompts/templates/basic_refinement/human.txt +14 -0
  56. janus/prompts/templates/basic_refinement/system.txt +1 -0
  57. janus/prompts/templates/diagram/human.txt +9 -0
  58. janus/prompts/templates/diagram/system.txt +1 -0
  59. janus/prompts/templates/diagram_with_documentation/human.txt +15 -0
  60. janus/prompts/templates/diagram_with_documentation/system.txt +1 -0
  61. janus/prompts/templates/document/human.txt +10 -0
  62. janus/prompts/templates/document/system.txt +1 -0
  63. janus/prompts/templates/document_cloze/human.txt +11 -0
  64. janus/prompts/templates/document_cloze/system.txt +1 -0
  65. janus/prompts/templates/document_cloze/variables.json +4 -0
  66. janus/prompts/templates/document_cloze/variables_asm.json +4 -0
  67. janus/prompts/templates/document_inline/human.txt +13 -0
  68. janus/prompts/templates/eval_prompts/incose/human.txt +32 -0
  69. janus/prompts/templates/eval_prompts/incose/system.txt +1 -0
  70. janus/prompts/templates/eval_prompts/incose/variables.json +3 -0
  71. janus/prompts/templates/eval_prompts/inline_comments/human.txt +49 -0
  72. janus/prompts/templates/eval_prompts/inline_comments/system.txt +1 -0
  73. janus/prompts/templates/eval_prompts/inline_comments/variables.json +3 -0
  74. janus/prompts/templates/micromanaged_mumps_v1.0/human.txt +23 -0
  75. janus/prompts/templates/micromanaged_mumps_v1.0/system.txt +3 -0
  76. janus/prompts/templates/micromanaged_mumps_v2.0/human.txt +28 -0
  77. janus/prompts/templates/micromanaged_mumps_v2.0/system.txt +3 -0
  78. janus/prompts/templates/micromanaged_mumps_v2.1/human.txt +29 -0
  79. janus/prompts/templates/micromanaged_mumps_v2.1/system.txt +3 -0
  80. janus/prompts/templates/multidocument/human.txt +15 -0
  81. janus/prompts/templates/multidocument/system.txt +1 -0
  82. janus/prompts/templates/partition/human.txt +22 -0
  83. janus/prompts/templates/partition/system.txt +1 -0
  84. janus/prompts/templates/partition/variables.json +4 -0
  85. janus/prompts/templates/pseudocode/human.txt +7 -0
  86. janus/prompts/templates/pseudocode/system.txt +7 -0
  87. janus/prompts/templates/refinement/fix_exceptions/human.txt +19 -0
  88. janus/prompts/templates/refinement/fix_exceptions/system.txt +1 -0
  89. janus/prompts/templates/refinement/format/code_format/human.txt +12 -0
  90. janus/prompts/templates/refinement/format/code_format/system.txt +1 -0
  91. janus/prompts/templates/refinement/format/requirements_format/human.txt +14 -0
  92. janus/prompts/templates/refinement/format/requirements_format/system.txt +1 -0
  93. janus/prompts/templates/refinement/hallucination/human.txt +13 -0
  94. janus/prompts/templates/refinement/hallucination/system.txt +1 -0
  95. janus/prompts/templates/refinement/reflection/human.txt +15 -0
  96. janus/prompts/templates/refinement/reflection/incose/human.txt +26 -0
  97. janus/prompts/templates/refinement/reflection/incose/system.txt +1 -0
  98. janus/prompts/templates/refinement/reflection/incose_deduplicate/human.txt +16 -0
  99. janus/prompts/templates/refinement/reflection/incose_deduplicate/system.txt +1 -0
  100. janus/prompts/templates/refinement/reflection/system.txt +1 -0
  101. janus/prompts/templates/refinement/revision/human.txt +16 -0
  102. janus/prompts/templates/refinement/revision/incose/human.txt +16 -0
  103. janus/prompts/templates/refinement/revision/incose/system.txt +1 -0
  104. janus/prompts/templates/refinement/revision/incose_deduplicate/human.txt +17 -0
  105. janus/prompts/templates/refinement/revision/incose_deduplicate/system.txt +1 -0
  106. janus/prompts/templates/refinement/revision/system.txt +1 -0
  107. janus/prompts/templates/refinement/uml/alc_fix_variables/human.txt +15 -0
  108. janus/prompts/templates/refinement/uml/alc_fix_variables/system.txt +2 -0
  109. janus/prompts/templates/refinement/uml/fix_connections/human.txt +15 -0
  110. janus/prompts/templates/refinement/uml/fix_connections/system.txt +2 -0
  111. janus/prompts/templates/requirements/human.txt +13 -0
  112. janus/prompts/templates/requirements/system.txt +2 -0
  113. janus/prompts/templates/retrieval/language_docs/human.txt +10 -0
  114. janus/prompts/templates/retrieval/language_docs/system.txt +1 -0
  115. janus/prompts/templates/simple/human.txt +16 -0
  116. janus/prompts/templates/simple/system.txt +3 -0
  117. janus/refiners/format.py +49 -0
  118. janus/refiners/refiner.py +113 -4
  119. janus/utils/enums.py +127 -112
  120. janus/utils/logger.py +2 -0
  121. {janus_llm-4.3.1.dist-info → janus_llm-4.3.5.dist-info}/METADATA +7 -7
  122. janus_llm-4.3.5.dist-info/RECORD +210 -0
  123. {janus_llm-4.3.1.dist-info → janus_llm-4.3.5.dist-info}/WHEEL +1 -1
  124. janus_llm-4.3.5.dist-info/entry_points.txt +3 -0
  125. janus/cli.py +0 -1488
  126. janus_llm-4.3.1.dist-info/RECORD +0 -115
  127. janus_llm-4.3.1.dist-info/entry_points.txt +0 -3
  128. {janus_llm-4.3.1.dist-info → janus_llm-4.3.5.dist-info}/LICENSE +0 -0
@@ -0,0 +1,49 @@
1
+ Please evaluate each comment in the provided {SOURCE_LANGUAGE} code based on the following criteria:
2
+
3
+ Completeness - Does the comment address all capabilities of the relevant source code?
4
+
5
+ 4 - All essential functionality is documented.
6
+ 3 - Most essential functionality is documented.
7
+ 2 - Little essential functionality is documented.
8
+ 1 - No essential functionality is documented.
9
+
10
+
11
+ Hallucination - Does the comment provide true information?
12
+
13
+ 4 - The comment provides only true information.
14
+ 3 - The comment provides mostly true information.
15
+ 2 - The comment provides mostly untrue information.
16
+ 1 - The comment is completely untrue.
17
+
18
+
19
+ Readability - Is the comment clear to read?
20
+
21
+ 4 - The comment is well-written.
22
+ 3 - The comment has few problems.
23
+ 2 - The comment has many problems.
24
+ 1 - The comment is unreadable.
25
+
26
+ Usefulness - Is the comment useful?
27
+
28
+ 4 - The comment helps an expert programmer understand the code better.
29
+ 3 - The comment helps an average programmer understand the code better.
30
+ 2 - The comment documents only trivial functionality.
31
+ 1 - The comment is not useful at any level.
32
+
33
+
34
+ Look through the code and find each individual comment, they will be deliniated by <BLOCK_COMMENT id> or <INLINE_COMMENT id> where "id" is an 8-character UUID for the comment that follows.
35
+
36
+ Each comment should be evaluated independently based on the above criteria. Your response should be formatted as a list of JSON objects, with each object corresponding to one comment. Each object should include five keys: `comment_id`, `completeness`, `hallucination`, `readability`, and `usefulness`. `comment_id` should have a string value that holds the 8-character UUID associated with the comment. The other four values should each be a JSON object with two keys: `reasoning` (a clear explanation of why the criteria is rated the way it is) and `score` (an integer rating from 1 to 4).
37
+
38
+ Be discerning in your evaluation; only very high-quality comments should get top marks. Be a hard grader. If a comment is rated low, be thorough and detailed in your explanation of your score.
39
+
40
+ Below is an example output for a snippet of code with three labeled comments:
41
+ ```{EXAMPLE_OUTPUT}```
42
+
43
+
44
+ Evaluate the following code:
45
+ ```
46
+ {SOURCE_CODE}
47
+ ```
48
+
49
+ Don't forget to include your final scores in JSON format!
@@ -0,0 +1 @@
1
+ You are a software quality engineer, your job is to evaluate comments in code according to a rubric.
@@ -0,0 +1,3 @@
1
+ {
2
+ "EXAMPLE_OUTPUT": "[\n {\n \"comment_id\": \"abcd1234\",\n \"completeness\": {\n \"reasoning\": \"The comment completely describes the functionality of the block\",\n \"score\": 4\n },\n \"hallucination\": {\n \"reasoning\": \"The comment misrepresents the behavior of for-loops in this language, and as a result is entirely wrong about what this code does\",\n \"score\": 1\n },\n \"readability\": {\n \"reasoning\": \"The comment is easy to read and understand\",\n \"score\": 4\n },\n \"usefulness\": {\n \"reasoning\": \"The comment would be necessary to understand this block (if the comment were correct)\",\n \"score\": 3\n }\n },\n {\n \"comment_id\": \"5678efgh\",\n \"completeness\": {\n \"reasoning\": \"There is no explanation of the GR_lby variable\",\n \"score\": 2\n },\n \"hallucination\": {\n \"reasoning\": \"The comment is accurate\",\n \"score\": 4\n },\n \"readability\": {\n \"reasoning\": \"The comment is wordy but generally understandable\",\n \"score\": 3\n },\n \"usefulness\": {\n \"reasoning\": \"The comment didn't explain anything that isn't already obvious from the code\",\n \"score\": 1\n }\n },\n {\n \"comment_id\": \"00aa22bb\",\n \"completeness\": {\n \"reasoning\": \"The comment describes the functionality of the line, but not an explanation/origin of the hard-coded integer\",\n \"score\": 3\n },\n \"hallucination\": {\n \"reasoning\": \"The comment mentions a function that does not appear to exist in the file\",\n \"score\": 2\n },\n \"readability\": {\n \"reasoning\": \"The comment was difficult to follow, and formatted poorly\",\n \"score\": 1\n },\n \"usefulness\": {\n \"reasoning\": \"This line would be completely incomprehensible without this comment\",\n \"score\": 4\n }\n }\n]"
3
+ }
@@ -0,0 +1,23 @@
1
+ Adhere to the following rules for translating MUMPS to Python:
2
+
3
+ 1. Routines from other files
4
+ When a function from another file is invoked, treat the file like a module. Keep all imports at the beginning of the returned code.
5
+
6
+ 2. Naming Conventions
7
+ Adhere to PEP8 for variable and function names. Improve readability when possible, making use of context and documentation. For example, a MUMPS variable like `RXQTY` might be translated to `prescription_quantity`.
8
+
9
+ 3. Ignore K(ill) Commands
10
+ Memory allocation and garbage collection is generally handled automatically in Python, so any MUMPS K(ill) commands should be ignored.
11
+
12
+ 4. Arrays
13
+ MUMPS arrays should generally be treated as nested dictionaries.
14
+
15
+ 5. Global Variables
16
+ When globals (prepended by a circumflex) are used in a routine, treat them as coming from a mysql database. Assume that database credentials are stored in environment variables ('SQL_HOST`, `SQL_USER`, `SQL_PWD`, `SQL_DB`).
17
+
18
+
19
+ Please convert the following MUMPS .m code found in between triple backticks into {TARGET_LANGUAGE} code. The returned code should also be delimited with triple backticks.
20
+
21
+ ```
22
+ {SOURCE_CODE}
23
+ ```
@@ -0,0 +1,3 @@
1
+ Your purpose is to convert MUMPS .m code
2
+ into runnable {TARGET_LANGUAGE} code ({TARGET_LANGUAGE} version
3
+ {TARGET_LANGUAGE_VERSION}).
@@ -0,0 +1,28 @@
1
+ Adhere to the following rules for translating MUMPS to Python:
2
+
3
+ 1. Routines from other files
4
+ When a function from another file is invoked (e.g. `D FUNC^ABC`), treat the file like a module (e.g. `from abc import func`, `func()` ). Keep all imports at the beginning of the returned code.
5
+
6
+ 2. Naming Conventions
7
+ Adhere to PEP8 for variable and function names. Improve readability when possible, making use of context and documentation. For example, a MUMPS variable like `RXQTY` might be translated to `prescription_quantity`.
8
+
9
+ 3. Ignore K(ill) Commands
10
+ Memory allocation and garbage collection is generally handled automatically in Python, so any MUMPS K(ill) commands should be ignored.
11
+
12
+ 4. Arrays
13
+ MUMPS arrays should generally be treated as nested dictionaries.
14
+
15
+ 5. Global Variables
16
+ When globals (prepended by a circumflex) are used in a routine, treat them as coming from a mysql database. Assume that database credentials are stored in environment variables ('SQL_HOST`, `SQL_USER`, `SQL_PWD`, `SQL_DB`).
17
+
18
+ 6. Local Variables
19
+ In MUMPS, even "local" variables are accessible from any subroutine. If a variable would not be defined, declare it as global.
20
+
21
+ 7. Translate Everything
22
+ Translate ALL the given code to the best of your ability.
23
+
24
+ Please convert the following MUMPS .m code found in between triple backticks into {TARGET_LANGUAGE} code. The returned code should also be delimited with triple backticks.
25
+
26
+ ```
27
+ {SOURCE_CODE}
28
+ ```
@@ -0,0 +1,3 @@
1
+ Your purpose is to convert MUMPS .m code
2
+ into runnable {TARGET_LANGUAGE} code ({TARGET_LANGUAGE} version
3
+ {TARGET_LANGUAGE_VERSION}).
@@ -0,0 +1,29 @@
1
+ Adhere to the following rules for translating MUMPS to Python:
2
+
3
+ 1. Routines from other files
4
+ When a function from another file is invoked (e.g. `D FUNC^ABC`), treat the file like a module (e.g. `from abc import func`, `func()` ). Keep all imports at the beginning of the returned code.
5
+
6
+ 2. Naming Conventions
7
+ Adhere to PEP8 for variable and function names. Improve readability when possible, making use of context and documentation. For example, a MUMPS variable like `RXQTY` might be translated to `prescription_quantity`.
8
+
9
+ 3. Ignore K(ill) Commands
10
+ Memory allocation and garbage collection is generally handled automatically in Python, so any MUMPS K(ill) commands should be ignored.
11
+
12
+ 4. Arrays
13
+ MUMPS arrays should be treated as nested dictionaries.
14
+
15
+ 5. Global Variables
16
+ When globals (prepended by a circumflex) are used in a routine, treat them as coming from a mysql database. Assume that database credentials are stored in environment variables ('SQL_HOST`, `SQL_USER`, `SQL_PWD`, `SQL_DB`).
17
+
18
+ 6. Local Variables
19
+ In MUMPS, even "local" variables are accessible from any subroutine. Declare all variables used in any function as global at the beginning of the function.
20
+
21
+ 7. Translate Everything
22
+ Translate ALL the given code to the best of your ability. DO NOT use pseudocode. DO NOT leave functions empty. DO NOT give up on translation.
23
+
24
+
25
+ Please convert the following MUMPS .m code found in between triple backticks into {TARGET_LANGUAGE} code. The returned code should also be delimited with triple backticks.
26
+
27
+ ```
28
+ {SOURCE_CODE}
29
+ ```
@@ -0,0 +1,3 @@
1
+ Your purpose is to convert MUMPS .m code
2
+ into runnable {TARGET_LANGUAGE} code ({TARGET_LANGUAGE} version
3
+ {TARGET_LANGUAGE_VERSION}).
@@ -0,0 +1,15 @@
1
+ Please document the {SOURCE_LANGUAGE} function or module below. Your response should be in JSON format, and include three string fields:
2
+
3
+ docstring: A Sphinx-style docstring for the code, including a summary of its functionality; the name, type, and description of any parameters or returns; and any potential exceptions that might arise in its execution. This should be a string value, NOT a nested JSON object.
4
+ example_usage: A well-commented minimal example in {SOURCE_LANGUAGE} utilizing the given code's functionality.
5
+ pseudocode: A Python-stype pseudocode implementation of the module or function's behavior.
6
+
7
+ If no executable code is provided (for example, if the input is a simple label with no logic attached), return an empty string for each of the above fields.
8
+
9
+ It is vital that you do not include any other context, questions, or text of any kind, other than the documentation for this piece of code. You should include all of the fields described above, and those fields only.
10
+
11
+ Here is the code:
12
+
13
+ ```
14
+ {SOURCE_CODE}
15
+ ```
@@ -0,0 +1 @@
1
+ You are a senior software engineer tasked with documenting {SOURCE_LANGUAGE} code.
@@ -0,0 +1,22 @@
1
+ Partition the {SOURCE_LANGUAGE} code into logical blocks. Each block should be relatively self-contained and ideally constitute a complete "subroutine", including any associated comments. These breakpoints should usually be inserted between labeled blocks, but perhaps not between *every* labeled block (depending on things like fallthrough).
2
+
3
+ INPUT FORMAT:
4
+ Each line of code has been prepended with an 8-character unique ID. a Python example would look like this:
5
+ ```
6
+ {EXAMPLE_INPUT}
7
+ ```
8
+
9
+ And your output might look like this:
10
+ ```
11
+ {EXAMPLE_OUTPUT}
12
+ ```
13
+
14
+ You are to output a JSON object containing a subset of these IDs, corresponding to the lines that should start a new block. Each partition should be paired with an explanation (please output the explanation first, before giving the line ID). DO NOT include any additional commentary before or after the JSON object, your response should be the JSON object ONLY.
15
+
16
+ Format instructions:
17
+ {format_instructions}
18
+
19
+ Input:
20
+ ```
21
+ {SOURCE_CODE}
22
+ ```
@@ -0,0 +1 @@
1
+ Your purpose is to partition {SOURCE_LANGUAGE} code into self-contained logical blocks.
@@ -0,0 +1,4 @@
1
+ {
2
+ "EXAMPLE_INPUT": "0d2f4f8d\tdef f(n):\ndef2a953\t return n * f_memo(n - 1)\n75315253\ne7f928da\tmemo = {0: 1, 1: 1}\n1781b2a9\tdef f_memo(n):\n2fe21e27\t if n in memo:\n9aef6179\t return memo[n]\n6061bd82\t memo[n] = f(n)\n22bd0c30\t return memo[n]\n5d85e19e\n06027969\tdef combinations(n, k):\n91b722fb\t return f_memo(n) // (f_memo(k) * f_memo(n - k))\n4b3f79be\nk57w964a\tdef prob_n_heads(n, k):\n51638s96\t return combinations(n, k) / (2 ** n)\n065o6q32\nj5q6p852\tprint(f\"Probability of 5/10 coin flips being heads: {prob_n_heads(10, 5)}.\")",
3
+ "EXAMPLE_OUTPUT": "[\n {\n \"reasoning\": \"The `combinations` function can be understood without the above implementation of factorials. However, the definitions of `f` and `f_memo` cannot be understood without one another, so there should be no partitions between 0d2f4f8d and 06027969.\",\n \"location\": \"06027969\"\n },\n {\n \"reasoning\": \"The specific implementation of `combinations` is not necessary to understand the functionality of `prob_n_heads` or the print statement\",\n \"location\": \"k57w964a\"\n }\n]"
4
+ }
@@ -0,0 +1,7 @@
1
+ Please convert all of the following code into pseudocode that can replicate its functionality.
2
+
3
+ Here is the code
4
+
5
+ ```
6
+ {SOURCE_CODE}
7
+ ```
@@ -0,0 +1,7 @@
1
+ Your purpose is to understand a source code file (or section of code) and generate easy-to-understand pseudocode for it.
2
+
3
+ This pseudocode should be written such that it is not tied to the programming language of the source code. For example, if the source code is written in Java, the pseudocode should not be written in Java. It should be written more abstract and should not focus on the syntax of the source code.
4
+
5
+ Do not leave sections of the source code unexplained.
6
+
7
+ Ensure the pseudocode that you produce lies within triple backticks (```).
@@ -0,0 +1,19 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ ERROR:
12
+ ```
13
+ {error}
14
+ ```
15
+ --------------------
16
+ Above, the COMPLETION did not satisfy the constraints given in the TASK, resulting in the ERROR.
17
+ Please update the COMPLETION such that it satisfies the constraints laid out in the TASK.
18
+ Do NOT make any changes to the COMPLETION other than are required to fix the ERROR.
19
+ Your response should contain a complete output. Do not provide any other commentary or followup questions.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with correcting invalid outputs from Large Language Models (LLMs). Given a task, an invalid output, and the parsing error, it is your job to write a new version of the output that resolves the error and meets the task requirements.
@@ -0,0 +1,12 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ Above, the COMPLETION should be formatted to have its relevant output between tripple backticks.
12
+ Please extract the relevant output (e.g. any generated code) from the COMPLETION and output it between tripple backticks.
@@ -0,0 +1 @@
1
+ You are a helpful software engineer named John tasked with taking unformated code and putting it into a specific output format.
@@ -0,0 +1,14 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ Above, the COMPLETION should be formatted to have its relevant output in json.
12
+ Extract all the generated requirements from the COMPLETION, and output a JSON-formatted string with the requirements text only a single key: "requirements".
13
+ The value of the requirements key should be a list of strings, with each requirement in a single string, and no further nesting in items in the list.
14
+ Ensure that the output string is properly formatted JSON.
@@ -0,0 +1 @@
1
+ You are a helpful software engineer named John tasked with taking unformated code and putting it into a specific output format.
@@ -0,0 +1,13 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ Identify any hallucinations or factual errors in the provided COMPLETION of the above TASK. Return a numbered list of hallucinations, each with an explanation of the problem.
12
+
13
+ If no hallucinations are present, respond with LGTM. "LGTM" must be returned on its own without any further commentary.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with identifying hallucinations and factual errors in Large Language Models (LLMs). Given a task and an output, it is your job to identify any hallucinations in the output. If the output is hallucination-free, you may approve it with a simple "LGTM".
@@ -0,0 +1,15 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ Generate critique and suggestions for the provided COMPLETION of the above TASK. Your suggestions can including requests for added detail, corrections of factual errors, improved style, etc.
12
+
13
+ Do not rewrite the output yourself, only provide critique that can be acted on. Provide no further commentary or questions other than your feedback.
14
+
15
+ If the output fully meets the requirements of the task and is of high quality, respond with LGTM. "LGTM" must be returned on its own without further commentary.
@@ -0,0 +1,26 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ REQUIREMENTS:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+
12
+ Generate critique and suggestions for the provided REQUIREMENTS based on the above TASK. Your suggestions can include requests for added detail, corrections of factual errors, improved style, etc. to ensure that each of the requirements meet INCOSE standards, described below.
13
+
14
+ Do not rewrite the output yourself, only provide critique that can be acted on. Provide no further commentary or questions other than your feedback.
15
+
16
+ If every single one of the requirements meets the following INCOSE standards, return LGTM. "LGTM" must be returned on its own without further commentary. Be especially strict in your grading!
17
+
18
+ C1 - Necessary: The need or requirement statement defines an essential capability, characteristic, constraint, or quality factor needed to satisfy a lifecycle concept, need, source, or parent requirement.
19
+ C2 - Appropriate: The specific intent and amount of detail of the need or requirement statement is appropriate to the level (the level of abstraction, organization, or system architecture) of the entity to which it refers.
20
+ C3 - Unambiguous: Need statements must be written such that the stakeholder intent is clear. Requirement statements must be stated such that the requirement can be interpreted in only one way by all the intended stakeholders.
21
+ C4 - Complete: The requirement statement sufficiently describes the necessary capability, characteristic, constraint, or quality factor to meet the need, source, or parent requirement from which it was transformed without needing other information to understand the requirement.
22
+ C5 - Singular: The stakeholder need or requirement statement should state a single capability, characteristic, constraint, or quality factor.
23
+ C6 - Feasible: The need or requirement can be realized within entity constraints (for example: cost, schedule, technical, legal, ethical, safety) with acceptable risk.
24
+ C7 - Verifiable: The requirement statement is structured and worded such that its realization can be verified to the approving authority’s satisfaction.
25
+ C8 - Correct: The need statement must be an accurate representation of the lifecycle concept or source from which it was transformed. The requirement statement must be an accurate representation of the need, source, or parent requirement from which it was transformed.
26
+ C9 - Conforming: Individual needs and requirements should conform to an approved standard pattern and style guide or standard for writing and managing needs and requirements.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with reviewing and critiquing outputs from Large Language Models (LLMs). Given a task and an output, it is your job to generate critique and suggestions to improve the output. If the output fully meets the requirements of the task and is of high quality, you may approve it with a simple "LGTM".
@@ -0,0 +1,16 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ REQUIREMENTS:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+
12
+ In order for software requirements to be useful for software modernization, they must be reasonably consise and not overly specific to the syntax of the legacy language of the code which they describe. With this in mind, for the provided TASK, suggest ways that the REQUIREMENTS could be less redundant. If the REQUIREMENTS include duplicated or unnecessary requirements, explain how some of them could be combined to reduce this number. If the REQUIREMENTS refer to specific aspects of the original coding language which would not be useful to a software developer porting the code to a new language, point it out.
13
+
14
+ Do not rewrite the output yourself, only provide critique that can be acted on. Provide no further commentary or questions other than your feedback.
15
+
16
+ If the requirements in the completion above are adequately consise, return LGTM. "LGTM" must be returned on its own without further commentary.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with reviewing and critiquing outputs from Large Language Models (LLMs). Given a task and an output, it is your job to generate critique and suggestions to improve the output. If the output fully meets the requirements of the task and is of high quality, you may approve it with a simple "LGTM".
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with reviewing and critiquing outputs from Large Language Models (LLMs). Given a task and an output, it is your job to generate critique and suggestions to improve the output. If the output fully meets the requirements of the task and is of high quality, you may approve it with a simple "LGTM".
@@ -0,0 +1,16 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ FEEDBACK:
12
+ ```
13
+ {reflection}
14
+ ```
15
+ --------------------
16
+ Improve the above COMPLETION of the given TASK by incorporating the provided FEEDBACK. Respond only with the revised output, following the format indicated in the original TASK description. Do not provide any additional commentary or questions about the critique.
@@ -0,0 +1,16 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ REQUIREMENTS:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ FEEDBACK:
12
+ ```
13
+ {reflection}
14
+ ```
15
+ --------------------
16
+ Improve the above REQUIREMENTS for the given TASK by incorporating the provided FEEDBACK. Respond only with the revised output, following the format indicated in the original TASK description. Do not provide any additional commentary or questions about the critique.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with improving outputs of Large Language Models according to human feedback. Given a task, a draft output, and some critique of that draft, it is your job to write a new version of the output that incorporates the provided suggestions and addresses any criticism.
@@ -0,0 +1,17 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ FEEDBACK:
12
+ ```
13
+ {reflection}
14
+ ```
15
+ --------------------
16
+ Improve the above COMPLETION of the given TASK by incorporating the provided FEEDBACK. Respond only with the revised output, following the format indicated in the original TASK description. Do not provide any additional commentary or questions about the critique.
17
+ g: Individual needs and requirements should conform to an approved standard pattern and style guide or standard for writing and managing needs and requirements.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with improving outputs of Large Language Models according to human feedback. Given a task, a draft output, and some critique of that draft, it is your job to write a new version of the output that incorporates the provided suggestions and addresses any criticism.
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with improving outputs of Large Language Models according to human feedback. Given a task, a draft output, and some critique of that draft, it is your job to write a new version of the output that incorporates the provided suggestions and addresses any criticism.
@@ -0,0 +1,15 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ Find any instances of variables in the provided COMPLETION of the above TASK being referenced without their proper namespace. Variables should always be referenced as data_structure.variable. Data structures can include classes, DSECTS, files or other similar language features.
12
+
13
+ Do not rewrite the output yourself, only provide critique that can be acted on. Provide no further commentary or questions other than your feedback.
14
+
15
+ If the output fully meets the requirements of the task and no variables are referenced outside their appropriate class or DSECT, respond with LGTM. "LGTM" must be returned on its own without further commentary.
@@ -0,0 +1,2 @@
1
+ You are a software engineer and quality control professional tasked with reviewing and critiquing outputs from Large Language Models (LLMs). Given a task and an output, it is your job to generate critique and suggestions to improve the output.
2
+ You must detect any instances of variables being referenced in the UML without referencing their appropriate namespace (i.e. struct.var). If the output fully meets the requirements of the task and all variables are appropriately referenced, you may approve it with a simple "LGTM".
@@ -0,0 +1,15 @@
1
+ TASK:
2
+ ```
3
+ {prompt}
4
+ ```
5
+ --------------------
6
+ COMPLETION:
7
+ ```
8
+ {completion}
9
+ ```
10
+ --------------------
11
+ Find any instances of connections in the provided COMPLETION of the above TASK that do not accurately represent the control flow of the program. The COMPLETION should accurately capture the entire control flow of the original program in the TASK.
12
+
13
+ Do not rewrite the output yourself, only provide critique that can be acted on. Provide no further commentary or questions other than your feedback.
14
+
15
+ If the output fully meets the requirements of the task and the control flow of the program in the TASK is accurately reflected, respond with LGTM. "LGTM" must be returned on its own without further commentary.
@@ -0,0 +1,2 @@
1
+ You are a software engineer and quality control professional tasked with reviewing and critiquing outputs from Large Language Models (LLMs). Given a task and an output, it is your job to generate critique and suggestions to improve the output.
2
+ You must detect any connections in the UML that do not accurately represent the control flow. If the output fully meets the requirements of the task and the control flow is correctly represented, you may approve it with a simple "LGTM".
@@ -0,0 +1,13 @@
1
+ We are modernizing the following code so we need to extract software requirements to document its functionality.
2
+
3
+ These requirements are intended for developers to refactor and port this code to a modern programming language, so they should focus on functionality rather than specifics of its current legacy language.
4
+
5
+ Write the requirements in the style of an INCOSE software requirements specification document.
6
+
7
+ Here is the code:
8
+
9
+ ```
10
+ {SOURCE_CODE}
11
+ ```
12
+
13
+ {context}
@@ -0,0 +1,2 @@
1
+ Your purpose is to understand a source code file
2
+ and generate a software requirements specification document for it.
@@ -0,0 +1,10 @@
1
+ Are there any references in the following {SOURCE_LANGUAGE} source code to uncommon or obscure built-in language functionality e.g. stand library calls, opcode, etc. that you do not understand and may be present in a language reference manual?
2
+
3
+ If so, return a short, comma-separated list of functions or opcodes to reference the manual for. Do not return any basic language functionality.
4
+
5
+ If not, return 'NODOCS'. 'NODOCS' must be returned on its own without further commentary.
6
+
7
+ Here is the code:
8
+ ```
9
+ {SOURCE_CODE}
10
+ ```
@@ -0,0 +1 @@
1
+ You are a software engineer and quality control professional tasked with providing context to source code by suggesting aspects of the code which could be made more clear by referencing a language manual. Given some source code, it is your job to pick out standard library calls or instructions which could be clarified with a reference. If there are no such code features, you may skip with process with the response "NODOCS".
@@ -0,0 +1,16 @@
1
+ Please convert the following {SOURCE_LANGUAGE} .{FILE_SUFFIX} code found in between triple backticks
2
+ into {TARGET_LANGUAGE} code.
3
+
4
+ If the given code is incomplete, assume it is translated elsewhere.
5
+ If the given code is missing variable definitions, assume they are assigned elsewhere.
6
+ If there are incomplete statements that haven't been closed out, assume they are closed out in other translations.
7
+ If the code has comments, keep ALL of them.
8
+ If it only consists of ONLY comments, assume the code that is represented by those comments is translated elsewhere.
9
+
10
+ Some more things to remember:
11
+ (1) follow standard styling practice for the target language
12
+ (2) make sure the language is typed correctly
13
+
14
+ ```
15
+ {SOURCE_CODE}
16
+ ```
@@ -0,0 +1,3 @@
1
+ Your purpose is to convert {SOURCE_LANGUAGE} {FILE_SUFFIX} code
2
+ into runnable {TARGET_LANGUAGE} code ({TARGET_LANGUAGE} version
3
+ {TARGET_LANGUAGE_VERSION}).
@@ -0,0 +1,49 @@
1
+ from typing import Any
2
+
3
+ from langchain_core.output_parsers import StrOutputParser
4
+ from langchain_core.prompt_values import PromptValue
5
+ from langchain_core.runnables import RunnableSerializable
6
+
7
+ from janus.llm.models_info import MODEL_PROMPT_ENGINES, JanusModel
8
+ from janus.parsers.parser import JanusParser
9
+ from janus.refiners.refiner import JanusRefiner
10
+
11
+
12
+ class FormatRefiner(JanusRefiner):
13
+ format_chain: RunnableSerializable
14
+
15
+ def __init__(
16
+ self,
17
+ llm: JanusModel,
18
+ parser: JanusParser,
19
+ max_retries: int,
20
+ prompt_template_name: str,
21
+ ):
22
+ format_prompt = MODEL_PROMPT_ENGINES[llm.short_model_id](
23
+ source_language="text",
24
+ prompt_template=prompt_template_name,
25
+ ).prompt
26
+ format_chain = format_prompt | llm | StrOutputParser()
27
+ super().__init__(
28
+ format_chain=format_chain, parser=parser, max_retries=max_retries
29
+ )
30
+
31
+ def parse_completion(
32
+ self, completion: str, prompt_value: PromptValue, **kwargs
33
+ ) -> Any:
34
+ completion = self.format_chain.invoke(
35
+ dict(completion=completion, prompt=prompt_value.to_string())
36
+ )
37
+ return self.parser.parse(completion)
38
+
39
+
40
+ class CodeFormatRefiner(FormatRefiner):
41
+ def __init__(self, llm: JanusModel, parser: JanusParser, max_retries: int):
42
+ super().__init__(llm, parser, max_retries, "refinement/format/code_format")
43
+
44
+
45
+ class RequirementsFormatRefiner(FormatRefiner):
46
+ def __init__(self, llm: JanusModel, parser: JanusParser, max_retries: int):
47
+ super().__init__(
48
+ llm, parser, max_retries, "refinement/format/requirements_format"
49
+ )