janus-llm 3.4.0__tar.gz → 3.4.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. {janus_llm-3.4.0 → janus_llm-3.4.1}/PKG-INFO +1 -1
  2. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/__init__.py +1 -1
  3. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/cli.py +24 -0
  4. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/converter.py +27 -22
  5. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/refiner_parser.py +3 -1
  6. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/refiners/refiner.py +17 -7
  7. {janus_llm-3.4.0 → janus_llm-3.4.1}/pyproject.toml +1 -1
  8. {janus_llm-3.4.0 → janus_llm-3.4.1}/LICENSE +0 -0
  9. {janus_llm-3.4.0 → janus_llm-3.4.1}/README.md +0 -0
  10. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/__main__.py +0 -0
  11. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/_tests/__init__.py +0 -0
  12. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/_tests/conftest.py +0 -0
  13. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/_tests/test_cli.py +0 -0
  14. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/__init__.py +0 -0
  15. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/_tests/__init__.py +0 -0
  16. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/_tests/test_translate.py +0 -0
  17. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/diagram.py +0 -0
  18. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/document.py +0 -0
  19. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/evaluate.py +0 -0
  20. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/requirements.py +0 -0
  21. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/converter/translate.py +0 -0
  22. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/__init__.py +0 -0
  23. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/_tests/__init__.py +0 -0
  24. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/_tests/test_collections.py +0 -0
  25. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/_tests/test_database.py +0 -0
  26. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/_tests/test_vectorize.py +0 -0
  27. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/collections.py +0 -0
  28. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/database.py +0 -0
  29. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/embedding_models_info.py +0 -0
  30. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/embedding/vectorize.py +0 -0
  31. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/__init__.py +0 -0
  32. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/_tests/__init__.py +0 -0
  33. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/_tests/test_combine.py +0 -0
  34. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/_tests/test_splitter.py +0 -0
  35. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/alc/__init__.py +0 -0
  36. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/alc/_tests/__init__.py +0 -0
  37. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/alc/_tests/test_alc.py +0 -0
  38. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/alc/alc.py +0 -0
  39. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/binary/__init__.py +0 -0
  40. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/binary/_tests/__init__.py +0 -0
  41. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/binary/_tests/test_binary.py +0 -0
  42. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/binary/binary.py +0 -0
  43. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/binary/reveng/decompile_script.py +0 -0
  44. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/block.py +0 -0
  45. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/combine.py +0 -0
  46. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/file.py +0 -0
  47. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/mumps/__init__.py +0 -0
  48. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/mumps/_tests/__init__.py +0 -0
  49. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/mumps/_tests/test_mumps.py +0 -0
  50. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/mumps/mumps.py +0 -0
  51. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/mumps/patterns.py +0 -0
  52. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/naive/__init__.py +0 -0
  53. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/naive/basic_splitter.py +0 -0
  54. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/naive/chunk_splitter.py +0 -0
  55. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/naive/registry.py +0 -0
  56. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/naive/simple_ast.py +0 -0
  57. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/naive/tag_splitter.py +0 -0
  58. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/node.py +0 -0
  59. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/splitter.py +0 -0
  60. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/treesitter/__init__.py +0 -0
  61. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/treesitter/_tests/__init__.py +0 -0
  62. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/treesitter/_tests/test_treesitter.py +0 -0
  63. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/language/treesitter/treesitter.py +0 -0
  64. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/llm/__init__.py +0 -0
  65. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/llm/model_callbacks.py +0 -0
  66. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/llm/models_info.py +0 -0
  67. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/__init__.py +0 -0
  68. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/__init__.py +0 -0
  69. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/reference.py +0 -0
  70. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/target.py +0 -0
  71. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_bleu.py +0 -0
  72. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_chrf.py +0 -0
  73. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_file_pairing.py +0 -0
  74. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_llm.py +0 -0
  75. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_reading.py +0 -0
  76. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_rouge_score.py +0 -0
  77. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_similarity_score.py +0 -0
  78. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/_tests/test_treesitter_metrics.py +0 -0
  79. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/bleu.py +0 -0
  80. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/chrf.py +0 -0
  81. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/cli.py +0 -0
  82. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/complexity_metrics.py +0 -0
  83. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/file_pairing.py +0 -0
  84. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/llm_metrics.py +0 -0
  85. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/metric.py +0 -0
  86. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/reading.py +0 -0
  87. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/rouge_score.py +0 -0
  88. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/similarity.py +0 -0
  89. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/metrics/splitting.py +0 -0
  90. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/__init__.py +0 -0
  91. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/_tests/__init__.py +0 -0
  92. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/_tests/test_code_parser.py +0 -0
  93. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/code_parser.py +0 -0
  94. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/doc_parser.py +0 -0
  95. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/eval_parser.py +0 -0
  96. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/reqs_parser.py +0 -0
  97. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/parsers/uml.py +0 -0
  98. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/prompts/__init__.py +0 -0
  99. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/prompts/prompt.py +0 -0
  100. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/__init__.py +0 -0
  101. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/_tests/__init__.py +0 -0
  102. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/_tests/test_logger.py +0 -0
  103. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/_tests/test_progress.py +0 -0
  104. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/enums.py +0 -0
  105. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/logger.py +0 -0
  106. {janus_llm-3.4.0 → janus_llm-3.4.1}/janus/utils/progress.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: janus-llm
3
- Version: 3.4.0
3
+ Version: 3.4.1
4
4
  Summary: A transcoding library using LLMs.
5
5
  Home-page: https://github.com/janus-llm/janus-llm
6
6
  License: Apache 2.0
@@ -5,7 +5,7 @@ from langchain_core._api.deprecation import LangChainDeprecationWarning
5
5
  from janus.converter.translate import Translator
6
6
  from janus.metrics import * # noqa: F403
7
7
 
8
- __version__ = "3.4.0"
8
+ __version__ = "3.4.1"
9
9
 
10
10
  # Ignoring a deprecation warning from langchain_core that I can't seem to hunt down
11
11
  warnings.filterwarnings("ignore", category=LangChainDeprecationWarning)
@@ -248,6 +248,13 @@ def translate(
248
248
  "If unspecificed, model's default max will be used.",
249
249
  ),
250
250
  ] = None,
251
+ skip_refiner: Annotated[
252
+ bool,
253
+ typer.Option(
254
+ "--skip-refiner",
255
+ help="Whether to skip the refiner for generating output",
256
+ ),
257
+ ] = True,
251
258
  ):
252
259
  try:
253
260
  target_language, target_version = target_lang.split("-")
@@ -274,6 +281,7 @@ def translate(
274
281
  db_config=collections_config,
275
282
  splitter_type=splitter_type,
276
283
  skip_context=skip_context,
284
+ skip_refiner=skip_refiner,
277
285
  )
278
286
  translator.translate(input_dir, output_dir, overwrite, collection)
279
287
 
@@ -395,6 +403,13 @@ def document(
395
403
  "If unspecificed, model's default max will be used.",
396
404
  ),
397
405
  ] = None,
406
+ skip_refiner: Annotated[
407
+ bool,
408
+ typer.Option(
409
+ "--skip-refiner",
410
+ help="Whether to skip the refiner for generating output",
411
+ ),
412
+ ] = True,
398
413
  ):
399
414
  model_arguments = dict(temperature=temperature)
400
415
  collections_config = get_collections_config()
@@ -407,6 +422,7 @@ def document(
407
422
  db_path=db_loc,
408
423
  db_config=collections_config,
409
424
  splitter_type=splitter_type,
425
+ skip_refiner=skip_refiner,
410
426
  skip_context=skip_context,
411
427
  )
412
428
  if doc_mode == "madlibs":
@@ -520,6 +536,13 @@ def diagram(
520
536
  click_type=click.Choice(list(CUSTOM_SPLITTERS.keys())),
521
537
  ),
522
538
  ] = "file",
539
+ skip_refiner: Annotated[
540
+ bool,
541
+ typer.Option(
542
+ "--skip-refiner",
543
+ help="Whether to skip the refiner for generating output",
544
+ ),
545
+ ] = True,
523
546
  ):
524
547
  model_arguments = dict(temperature=temperature)
525
548
  collections_config = get_collections_config()
@@ -533,6 +556,7 @@ def diagram(
533
556
  diagram_type=diagram_type,
534
557
  add_documentation=add_documentation,
535
558
  splitter_type=splitter_type,
559
+ skip_refiner=skip_refiner,
536
560
  skip_context=skip_context,
537
561
  )
538
562
  diagram_generator.translate(input_dir, output_dir, overwrite, collection)
@@ -1,6 +1,5 @@
1
1
  import functools
2
2
  import json
3
- import math
4
3
  import time
5
4
  from pathlib import Path
6
5
  from typing import Any, List, Optional, Tuple
@@ -77,6 +76,7 @@ class Converter:
77
76
  prune_node_types: tuple[str, ...] = (),
78
77
  splitter_type: str = "file",
79
78
  refiner_type: str = "basic",
79
+ skip_refiner: bool = True,
80
80
  skip_context: bool = False,
81
81
  ) -> None:
82
82
  """Initialize a Converter instance.
@@ -98,6 +98,8 @@ class Converter:
98
98
  splitter_type: The type of splitter to use. Valid values are `"file"`,
99
99
  `"tag"`, `"chunk"`, `"ast-strict"`, and `"ast-flex"`.
100
100
  refiner_type: The type of refiner to use. Valid values are `"basic"`.
101
+ skip_refiner: Whether to skip the refiner.
102
+ skip_context: Whether to skip adding context to the prompt.
101
103
  """
102
104
  self._changed_attrs: set = set()
103
105
 
@@ -133,6 +135,8 @@ class Converter:
133
135
  self._refiner_type: str
134
136
  self._refiner: Refiner
135
137
 
138
+ self.skip_refiner = skip_refiner
139
+
136
140
  self.set_splitter(splitter_type=splitter_type)
137
141
  self.set_refiner(refiner_type=refiner_type)
138
142
  self.set_model(model_name=model, **model_arguments)
@@ -293,7 +297,7 @@ class Converter:
293
297
  """
294
298
  if self._refiner_type == "basic":
295
299
  self._refiner = BasicRefiner(
296
- "basic_refinement", self._model_name, self._source_language
300
+ "basic_refinement", self._model_id, self._source_language
297
301
  )
298
302
  else:
299
303
  raise ValueError(f"Error: unknown refiner type {self._refiner_type}")
@@ -598,40 +602,41 @@ class Converter:
598
602
  self._parser.set_reference(block.original)
599
603
 
600
604
  # Retries with just the output and the error
601
- n1 = round(self.max_prompts ** (1 / 3))
605
+ n1 = round(self.max_prompts ** (1 / 2))
602
606
 
603
607
  # Retries with the input, output, and error
604
- n2 = round((self.max_prompts // n1) ** (1 / 2))
608
+ n2 = round(self.max_prompts // n1)
605
609
 
606
610
  # Retries with just the input
607
- n3 = math.ceil(self.max_prompts / (n1 * n2))
608
- # Make replacements in the prompt
609
611
  if not self.skip_context:
610
612
  self._make_prompt_additions(block)
611
-
612
- refine_output = RefinerParser(
613
- parser=self._parser,
614
- initial_prompt=self._prompt.format(**{"SOURCE_CODE": block.original.text}),
615
- refiner=self._refiner,
616
- max_retries=n1,
617
- llm=self._llm,
618
- )
619
- retry = RetryWithErrorOutputParser.from_llm(
620
- llm=self._llm,
621
- parser=refine_output,
622
- max_retries=n2,
623
- )
613
+ if not self.skip_refiner: # Make replacements in the prompt
614
+ refine_output = RefinerParser(
615
+ parser=self._parser,
616
+ initial_prompt=self._prompt.format(
617
+ **{"SOURCE_CODE": block.original.text}
618
+ ),
619
+ refiner=self._refiner,
620
+ max_retries=n1,
621
+ llm=self._llm,
622
+ )
623
+ else:
624
+ refine_output = RetryWithErrorOutputParser.from_llm(
625
+ llm=self._llm,
626
+ parser=self._parser,
627
+ max_retries=n1,
628
+ )
624
629
  completion_chain = self._prompt | self._llm
625
630
  chain = RunnableParallel(
626
631
  completion=completion_chain, prompt_value=self._prompt
627
- ) | RunnableLambda(lambda x: retry.parse_with_prompt(**x))
628
- for _ in range(n3):
632
+ ) | RunnableLambda(lambda x: refine_output.parse_with_prompt(**x))
633
+ for _ in range(n2):
629
634
  try:
630
635
  return chain.invoke({"SOURCE_CODE": block.original.text})
631
636
  except OutputParserException:
632
637
  pass
633
638
 
634
- raise OutputParserException(f"Failed to parse after {n1*n2*n3} retries")
639
+ raise OutputParserException(f"Failed to parse after {n1*n2} retries")
635
640
 
636
641
  def _get_output_obj(
637
642
  self, block: TranslatedCodeBlock
@@ -40,7 +40,9 @@ class RefinerParser(BaseOutputParser):
40
40
  return self.parser.parse(text)
41
41
  except OutputParserException as oe:
42
42
  err = str(oe)
43
- new_prompt, prompt_arguments = self.refiner.refine(last_prompt, text, err)
43
+ new_prompt, prompt_arguments = self.refiner.refine(
44
+ self.initial_prompt, last_prompt, text, err
45
+ )
44
46
  new_chain = new_prompt | self.llm
45
47
  text = new_chain.invoke(prompt_arguments)
46
48
  last_prompt = new_prompt.format(**prompt_arguments)
@@ -5,7 +5,12 @@ from janus.llm.models_info import MODEL_PROMPT_ENGINES
5
5
 
6
6
  class Refiner:
7
7
  def refine(
8
- self, original_prompt: str, original_output: str, errors: str, **kwargs
8
+ self,
9
+ original_prompt: str,
10
+ previous_prompt: str,
11
+ previous_output: str,
12
+ errors: str,
13
+ **kwargs,
9
14
  ) -> tuple[ChatPromptTemplate, dict[str, str]]:
10
15
  """Creates a new prompt based on feedback from original results
11
16
 
@@ -24,22 +29,27 @@ class BasicRefiner(Refiner):
24
29
  def __init__(
25
30
  self,
26
31
  prompt_name: str,
27
- model_name: str,
32
+ model_id: str,
28
33
  source_language: str,
29
34
  ) -> None:
30
35
  """Basic refiner, asks llm to fix output of previous prompt given errors
31
36
 
32
37
  Arguments:
33
38
  prompt_name: refinement prompt name to use
34
- model_name: name of llm to use
39
+ model_id: ID of the llm to use. Found in models_info.py
35
40
  source_language: source_langauge to use
36
41
  """
37
42
  self._prompt_name = prompt_name
38
- self._model_name = model_name
43
+ self._model_id = model_id
39
44
  self._source_language = source_language
40
45
 
41
46
  def refine(
42
- self, original_prompt: str, original_output: str, errors: str, **kwargs
47
+ self,
48
+ original_prompt: str,
49
+ previous_prompt: str,
50
+ previous_output: str,
51
+ errors: str,
52
+ **kwargs,
43
53
  ) -> tuple[ChatPromptTemplate, dict[str, str]]:
44
54
  """Creates a new prompt based on feedback from original results
45
55
 
@@ -51,13 +61,13 @@ class BasicRefiner(Refiner):
51
61
  Returns:
52
62
  Tuple of new prompt and prompt arguments
53
63
  """
54
- prompt_engine = MODEL_PROMPT_ENGINES[self._model_name](
64
+ prompt_engine = MODEL_PROMPT_ENGINES[self._model_id](
55
65
  prompt_template=self._prompt_name,
56
66
  source_language=self._source_language,
57
67
  )
58
68
  prompt_arguments = {
59
69
  "ORIGINAL_PROMPT": original_prompt,
60
- "OUTPUT": original_output,
70
+ "OUTPUT": previous_output,
61
71
  "ERRORS": errors,
62
72
  }
63
73
  return prompt_engine.prompt, prompt_arguments
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "janus-llm"
3
- version = "3.4.0"
3
+ version = "3.4.1"
4
4
  description = "A transcoding library using LLMs."
5
5
  authors = ["Michael Doyle <mdoyle@mitre.org>", "Chris Glasz <cglasz@mitre.org>",
6
6
  "Chris Tohline <ctohline@mitre.org>", "William Macke <wmacke@mitre.org>",
File without changes
File without changes
File without changes