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.
- janus/__init__.py +1 -1
- janus/__main__.py +1 -1
- janus/_tests/evaluator_tests/EvalReadMe.md +85 -0
- janus/_tests/evaluator_tests/incose_tests/incose_large_test.json +39 -0
- janus/_tests/evaluator_tests/incose_tests/incose_small_test.json +17 -0
- janus/_tests/evaluator_tests/inline_comment_tests/mumps_inline_comment_test.m +71 -0
- janus/_tests/test_cli.py +3 -2
- janus/cli/aggregate.py +135 -0
- janus/cli/cli.py +111 -0
- janus/cli/constants.py +43 -0
- janus/cli/database.py +289 -0
- janus/cli/diagram.py +178 -0
- janus/cli/document.py +174 -0
- janus/cli/embedding.py +122 -0
- janus/cli/llm.py +187 -0
- janus/cli/partition.py +125 -0
- janus/cli/self_eval.py +149 -0
- janus/cli/translate.py +183 -0
- janus/converter/__init__.py +1 -1
- janus/converter/_tests/test_translate.py +2 -0
- janus/converter/converter.py +129 -93
- janus/converter/document.py +21 -14
- janus/converter/evaluate.py +20 -13
- janus/converter/translate.py +3 -3
- janus/embedding/collections.py +1 -1
- janus/language/alc/_tests/alc.asm +3779 -0
- janus/language/binary/_tests/hello.bin +0 -0
- janus/language/block.py +47 -12
- janus/language/file.py +1 -1
- janus/language/mumps/_tests/mumps.m +235 -0
- janus/language/treesitter/_tests/languages/fortran.f90 +416 -0
- janus/language/treesitter/_tests/languages/ibmhlasm.asm +16 -0
- janus/language/treesitter/_tests/languages/matlab.m +225 -0
- janus/llm/models_info.py +9 -1
- janus/metrics/_tests/asm_test_file.asm +10 -0
- janus/metrics/_tests/mumps_test_file.m +6 -0
- janus/metrics/_tests/test_treesitter_metrics.py +1 -1
- janus/metrics/prompts/clarity.txt +8 -0
- janus/metrics/prompts/completeness.txt +16 -0
- janus/metrics/prompts/faithfulness.txt +10 -0
- janus/metrics/prompts/hallucination.txt +16 -0
- janus/metrics/prompts/quality.txt +8 -0
- janus/metrics/prompts/readability.txt +16 -0
- janus/metrics/prompts/usefulness.txt +16 -0
- janus/parsers/code_parser.py +4 -4
- janus/parsers/doc_parser.py +12 -9
- janus/parsers/parser.py +7 -0
- janus/parsers/partition_parser.py +6 -4
- janus/parsers/reqs_parser.py +8 -5
- janus/parsers/uml.py +5 -4
- janus/prompts/prompt.py +2 -2
- janus/prompts/templates/README.md +30 -0
- janus/prompts/templates/basic_aggregation/human.txt +6 -0
- janus/prompts/templates/basic_aggregation/system.txt +1 -0
- janus/prompts/templates/basic_refinement/human.txt +14 -0
- janus/prompts/templates/basic_refinement/system.txt +1 -0
- janus/prompts/templates/diagram/human.txt +9 -0
- janus/prompts/templates/diagram/system.txt +1 -0
- janus/prompts/templates/diagram_with_documentation/human.txt +15 -0
- janus/prompts/templates/diagram_with_documentation/system.txt +1 -0
- janus/prompts/templates/document/human.txt +10 -0
- janus/prompts/templates/document/system.txt +1 -0
- janus/prompts/templates/document_cloze/human.txt +11 -0
- janus/prompts/templates/document_cloze/system.txt +1 -0
- janus/prompts/templates/document_cloze/variables.json +4 -0
- janus/prompts/templates/document_cloze/variables_asm.json +4 -0
- janus/prompts/templates/document_inline/human.txt +13 -0
- janus/prompts/templates/eval_prompts/incose/human.txt +32 -0
- janus/prompts/templates/eval_prompts/incose/system.txt +1 -0
- janus/prompts/templates/eval_prompts/incose/variables.json +3 -0
- janus/prompts/templates/eval_prompts/inline_comments/human.txt +49 -0
- janus/prompts/templates/eval_prompts/inline_comments/system.txt +1 -0
- janus/prompts/templates/eval_prompts/inline_comments/variables.json +3 -0
- janus/prompts/templates/micromanaged_mumps_v1.0/human.txt +23 -0
- janus/prompts/templates/micromanaged_mumps_v1.0/system.txt +3 -0
- janus/prompts/templates/micromanaged_mumps_v2.0/human.txt +28 -0
- janus/prompts/templates/micromanaged_mumps_v2.0/system.txt +3 -0
- janus/prompts/templates/micromanaged_mumps_v2.1/human.txt +29 -0
- janus/prompts/templates/micromanaged_mumps_v2.1/system.txt +3 -0
- janus/prompts/templates/multidocument/human.txt +15 -0
- janus/prompts/templates/multidocument/system.txt +1 -0
- janus/prompts/templates/partition/human.txt +22 -0
- janus/prompts/templates/partition/system.txt +1 -0
- janus/prompts/templates/partition/variables.json +4 -0
- janus/prompts/templates/pseudocode/human.txt +7 -0
- janus/prompts/templates/pseudocode/system.txt +7 -0
- janus/prompts/templates/refinement/fix_exceptions/human.txt +19 -0
- janus/prompts/templates/refinement/fix_exceptions/system.txt +1 -0
- janus/prompts/templates/refinement/format/code_format/human.txt +12 -0
- janus/prompts/templates/refinement/format/code_format/system.txt +1 -0
- janus/prompts/templates/refinement/format/requirements_format/human.txt +14 -0
- janus/prompts/templates/refinement/format/requirements_format/system.txt +1 -0
- janus/prompts/templates/refinement/hallucination/human.txt +13 -0
- janus/prompts/templates/refinement/hallucination/system.txt +1 -0
- janus/prompts/templates/refinement/reflection/human.txt +15 -0
- janus/prompts/templates/refinement/reflection/incose/human.txt +26 -0
- janus/prompts/templates/refinement/reflection/incose/system.txt +1 -0
- janus/prompts/templates/refinement/reflection/incose_deduplicate/human.txt +16 -0
- janus/prompts/templates/refinement/reflection/incose_deduplicate/system.txt +1 -0
- janus/prompts/templates/refinement/reflection/system.txt +1 -0
- janus/prompts/templates/refinement/revision/human.txt +16 -0
- janus/prompts/templates/refinement/revision/incose/human.txt +16 -0
- janus/prompts/templates/refinement/revision/incose/system.txt +1 -0
- janus/prompts/templates/refinement/revision/incose_deduplicate/human.txt +17 -0
- janus/prompts/templates/refinement/revision/incose_deduplicate/system.txt +1 -0
- janus/prompts/templates/refinement/revision/system.txt +1 -0
- janus/prompts/templates/refinement/uml/alc_fix_variables/human.txt +15 -0
- janus/prompts/templates/refinement/uml/alc_fix_variables/system.txt +2 -0
- janus/prompts/templates/refinement/uml/fix_connections/human.txt +15 -0
- janus/prompts/templates/refinement/uml/fix_connections/system.txt +2 -0
- janus/prompts/templates/requirements/human.txt +13 -0
- janus/prompts/templates/requirements/system.txt +2 -0
- janus/prompts/templates/retrieval/language_docs/human.txt +10 -0
- janus/prompts/templates/retrieval/language_docs/system.txt +1 -0
- janus/prompts/templates/simple/human.txt +16 -0
- janus/prompts/templates/simple/system.txt +3 -0
- janus/refiners/format.py +49 -0
- janus/refiners/refiner.py +113 -4
- janus/utils/enums.py +127 -112
- janus/utils/logger.py +2 -0
- {janus_llm-4.3.1.dist-info → janus_llm-4.3.5.dist-info}/METADATA +7 -7
- janus_llm-4.3.5.dist-info/RECORD +210 -0
- {janus_llm-4.3.1.dist-info → janus_llm-4.3.5.dist-info}/WHEEL +1 -1
- janus_llm-4.3.5.dist-info/entry_points.txt +3 -0
- janus/cli.py +0 -1488
- janus_llm-4.3.1.dist-info/RECORD +0 -115
- janus_llm-4.3.1.dist-info/entry_points.txt +0 -3
- {janus_llm-4.3.1.dist-info → janus_llm-4.3.5.dist-info}/LICENSE +0 -0
janus/converter/evaluate.py
CHANGED
@@ -9,6 +9,7 @@ from janus.language.block import TranslatedCodeBlock
|
|
9
9
|
from janus.language.combine import JsonCombiner
|
10
10
|
from janus.parsers.eval_parsers.incose_parser import IncoseParser
|
11
11
|
from janus.parsers.eval_parsers.inline_comment_parser import InlineCommentParser
|
12
|
+
from janus.parsers.parser import JanusParserException
|
12
13
|
from janus.utils.logger import create_logger
|
13
14
|
|
14
15
|
log = create_logger(__name__)
|
@@ -30,8 +31,7 @@ class Evaluator(Converter):
|
|
30
31
|
|
31
32
|
Arguments:
|
32
33
|
model: The LLM to use for translation. If an OpenAI model, the
|
33
|
-
`OPENAI_API_KEY` environment variable must be set
|
34
|
-
`OPENAI_ORG_ID` environment variable should be set if needed.
|
34
|
+
`OPENAI_API_KEY` environment variable must be set.
|
35
35
|
model_arguments: Additional arguments to pass to the LLM constructor.
|
36
36
|
max_prompts: The maximum number of prompts to try before giving up.
|
37
37
|
"""
|
@@ -55,8 +55,7 @@ class RequirementEvaluator(Evaluator):
|
|
55
55
|
|
56
56
|
Arguments:
|
57
57
|
model: The LLM to use for translation. If an OpenAI model, the
|
58
|
-
`OPENAI_API_KEY` environment variable must be set
|
59
|
-
`OPENAI_ORG_ID` environment variable should be set if needed.
|
58
|
+
`OPENAI_API_KEY` environment variable must be set.
|
60
59
|
model_arguments: Additional arguments to pass to the LLM constructor.
|
61
60
|
max_prompts: The maximum number of prompts to try before giving up.
|
62
61
|
"""
|
@@ -110,7 +109,6 @@ class RequirementEvaluator(Evaluator):
|
|
110
109
|
|
111
110
|
block.processing_time = 0
|
112
111
|
block.cost = 0
|
113
|
-
block.retries = 0
|
114
112
|
obj = {}
|
115
113
|
for i in range(0, len(requirements), self.eval_items_per_request):
|
116
114
|
# Build a new TranslatedBlock using the new working text
|
@@ -122,15 +120,25 @@ class RequirementEvaluator(Evaluator):
|
|
122
120
|
working_block = TranslatedCodeBlock(working_copy, self._target_language)
|
123
121
|
|
124
122
|
# Run the LLM on the working text
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
123
|
+
try:
|
124
|
+
super()._add_translation(working_block)
|
125
|
+
except JanusParserException as e:
|
126
|
+
block.text += "\n==============\n" + working_block.text
|
127
|
+
block.tokens = self._llm.get_num_tokens(block.text)
|
128
|
+
raise e
|
129
|
+
finally:
|
130
|
+
# Update metadata to include for all runs
|
131
|
+
block.num_requests += working_block.num_requests
|
132
|
+
block.cost += working_block.cost
|
133
|
+
block.processing_time += working_block.processing_time
|
134
|
+
block.request_input_tokens += working_block.request_input_tokens
|
135
|
+
block.request_output_tokens += working_block.request_output_tokens
|
131
136
|
|
132
137
|
# Update the output text to merge this section's output in
|
133
138
|
obj.update(json.loads(working_block.text))
|
139
|
+
# intermediate result of block,
|
140
|
+
# will be overwritten if file completes successfully
|
141
|
+
block.text = json.dumps(obj)
|
134
142
|
|
135
143
|
block.text = json.dumps(obj)
|
136
144
|
block.tokens = self._llm.get_num_tokens(block.text)
|
@@ -153,8 +161,7 @@ class InlineCommentEvaluator(Evaluator):
|
|
153
161
|
|
154
162
|
Arguments:
|
155
163
|
model: The LLM to use for translation. If an OpenAI model, the
|
156
|
-
`OPENAI_API_KEY` environment variable must be set
|
157
|
-
`OPENAI_ORG_ID` environment variable should be set if needed.
|
164
|
+
`OPENAI_API_KEY` environment variable must be set.
|
158
165
|
model_arguments: Additional arguments to pass to the LLM constructor.
|
159
166
|
max_prompts: The maximum number of prompts to try before giving up.
|
160
167
|
"""
|
janus/converter/translate.py
CHANGED
@@ -21,8 +21,7 @@ class Translator(Converter):
|
|
21
21
|
|
22
22
|
Arguments:
|
23
23
|
model: The LLM to use for translation. If an OpenAI model, the
|
24
|
-
`OPENAI_API_KEY` environment variable must be set
|
25
|
-
`OPENAI_ORG_ID` environment variable should be set if needed.
|
24
|
+
`OPENAI_API_KEY` environment variable must be set.
|
26
25
|
model_arguments: Additional arguments to pass to the LLM constructor.
|
27
26
|
source_language: The source programming language.
|
28
27
|
target_language: The target programming language.
|
@@ -67,7 +66,8 @@ class Translator(Converter):
|
|
67
66
|
)
|
68
67
|
self._target_language = target_language
|
69
68
|
self._target_version = target_version
|
70
|
-
|
69
|
+
# Taking the first suffix as the default for output files
|
70
|
+
self._target_suffix = f".{LANGUAGES[target_language]['suffixes'][0]}"
|
71
71
|
|
72
72
|
@run_if_changed(
|
73
73
|
"_prompt_template_name",
|
janus/embedding/collections.py
CHANGED
@@ -87,7 +87,7 @@ class Collections:
|
|
87
87
|
"""Get the Chroma collections.
|
88
88
|
|
89
89
|
Returns:
|
90
|
-
The Chroma collections. Raises
|
90
|
+
The Chroma collections. Raises InvalidCollectionException if not found.
|
91
91
|
"""
|
92
92
|
if isinstance(name, str):
|
93
93
|
return [self._client.get_collection(name)]
|