janus-llm 3.0.1__py3-none-any.whl → 3.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- janus/__init__.py +1 -1
- janus/converter/diagram.py +3 -1
- janus/parsers/uml.py +51 -0
- {janus_llm-3.0.1.dist-info → janus_llm-3.1.1.dist-info}/METADATA +1 -1
- {janus_llm-3.0.1.dist-info → janus_llm-3.1.1.dist-info}/RECORD +8 -7
- {janus_llm-3.0.1.dist-info → janus_llm-3.1.1.dist-info}/LICENSE +0 -0
- {janus_llm-3.0.1.dist-info → janus_llm-3.1.1.dist-info}/WHEEL +0 -0
- {janus_llm-3.0.1.dist-info → janus_llm-3.1.1.dist-info}/entry_points.txt +0 -0
janus/__init__.py
CHANGED
@@ -5,7 +5,7 @@ from langchain_core._api.deprecation import LangChainDeprecationWarning
|
|
5
5
|
from .converter.translate import Translator
|
6
6
|
from .metrics import * # noqa: F403
|
7
7
|
|
8
|
-
__version__ = "3.
|
8
|
+
__version__ = "3.1.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)
|
janus/converter/diagram.py
CHANGED
@@ -5,6 +5,7 @@ from janus.converter.converter import run_if_changed
|
|
5
5
|
from janus.converter.document import Documenter
|
6
6
|
from janus.language.block import TranslatedCodeBlock
|
7
7
|
from janus.llm.models_info import MODEL_PROMPT_ENGINES
|
8
|
+
from janus.parsers.uml import UMLSyntaxParser
|
8
9
|
from janus.utils.logger import create_logger
|
9
10
|
|
10
11
|
log = create_logger(__name__)
|
@@ -39,6 +40,7 @@ class DiagramGenerator(Documenter):
|
|
39
40
|
self._diagram_type = diagram_type
|
40
41
|
self._add_documentation = add_documentation
|
41
42
|
self._documenter = None
|
43
|
+
self._diagram_parser = UMLSyntaxParser(language="plantuml")
|
42
44
|
if add_documentation:
|
43
45
|
self._diagram_prompt_template_name = "diagram_with_documentation"
|
44
46
|
else:
|
@@ -83,7 +85,7 @@ class DiagramGenerator(Documenter):
|
|
83
85
|
|
84
86
|
self._parser.set_reference(block.original)
|
85
87
|
|
86
|
-
query_and_parse = self.diagram_prompt | self._llm | self.
|
88
|
+
query_and_parse = self.diagram_prompt | self._llm | self._diagram_parser
|
87
89
|
|
88
90
|
if self._add_documentation:
|
89
91
|
block.text = query_and_parse.invoke(
|
janus/parsers/uml.py
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
import re
|
2
|
+
import subprocess # nosec
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import List, Tuple
|
5
|
+
|
6
|
+
from langchain_core.exceptions import OutputParserException
|
7
|
+
|
8
|
+
from janus.utils.logger import create_logger
|
9
|
+
|
10
|
+
from .code_parser import CodeParser
|
11
|
+
|
12
|
+
log = create_logger(__name__)
|
13
|
+
|
14
|
+
|
15
|
+
class UMLSyntaxParser(CodeParser):
|
16
|
+
def _get_uml_output(self, file: str) -> Tuple[str, str]:
|
17
|
+
# NOTE: running subprocess with shell=False, added nosec to label that we know
|
18
|
+
# risk exists
|
19
|
+
try:
|
20
|
+
plantuml_path = Path.home().expanduser() / ".janus/lib/plantuml.jar"
|
21
|
+
res = subprocess.run(
|
22
|
+
["java", "-jar", plantuml_path, file],
|
23
|
+
stdout=subprocess.PIPE,
|
24
|
+
stderr=subprocess.PIPE,
|
25
|
+
) # nosec
|
26
|
+
stdout = res.stdout.decode("utf-8")
|
27
|
+
stderr = res.stderr.decode("utf-8")
|
28
|
+
except FileNotFoundError:
|
29
|
+
log.warning("Plant UML executable not found, skipping syntax check")
|
30
|
+
stdout = ""
|
31
|
+
stderr = ""
|
32
|
+
return stdout, stderr
|
33
|
+
|
34
|
+
def _get_errs(self, s: str) -> List[str]:
|
35
|
+
return [x.group() for x in re.finditer(r"Error (.*)\n", s)]
|
36
|
+
|
37
|
+
def parse(self, text: str) -> str:
|
38
|
+
text = super().parse(text)
|
39
|
+
janus_path = Path.home().expanduser() / Path(".janus")
|
40
|
+
if not janus_path.exists():
|
41
|
+
janus_path.mkdir()
|
42
|
+
temp_file_path = janus_path / "tmp.txt"
|
43
|
+
with open(temp_file_path, "w") as f:
|
44
|
+
f.write(text)
|
45
|
+
uml_std_out, uml_std_err = self._get_uml_output(temp_file_path)
|
46
|
+
uml_errs = self._get_errs(uml_std_out) + self._get_errs(uml_std_err)
|
47
|
+
if len(uml_errs) > 0:
|
48
|
+
raise OutputParserException(
|
49
|
+
"Error: Received UML Errors:\n" + "\n".join(uml_errs)
|
50
|
+
)
|
51
|
+
return text
|
@@ -1,4 +1,4 @@
|
|
1
|
-
janus/__init__.py,sha256=
|
1
|
+
janus/__init__.py,sha256=jQAeQ79XxAr006t0p-cWwyFpS-zXKlBPpr_Ock6OrPw,351
|
2
2
|
janus/__main__.py,sha256=lEkpNtLVPtFo8ySDZeXJ_NXDHb0GVdZFPWB4gD4RPS8,64
|
3
3
|
janus/_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
janus/_tests/conftest.py,sha256=V7uW-oq3YbFiRPvrq15YoVVrA1n_83pjgiyTZ-IUGW8,963
|
@@ -8,7 +8,7 @@ janus/converter/__init__.py,sha256=kzVmWOPXRDayqqBZ8ZDaFQzA_q8PEdv407dc-DefPxY,2
|
|
8
8
|
janus/converter/_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
janus/converter/_tests/test_translate.py,sha256=eiLbmouokZrAeAYmdoJgnlx5-k4QiO6i0N6e6ZvZsvM,15885
|
10
10
|
janus/converter/converter.py,sha256=Bq07_9N_3Dv9NBqVACvb7LC2HxdQmfVZ1b0BlWrxjgo,23521
|
11
|
-
janus/converter/diagram.py,sha256=
|
11
|
+
janus/converter/diagram.py,sha256=JsJNDf-P8bPejpDxbCVEHvw-0kewiMrXh5qLhsL5JOA,4730
|
12
12
|
janus/converter/document.py,sha256=hsW512veNjFWbdl5WriuUdNmMEqZy8ktRvqn9rRmA6E,4566
|
13
13
|
janus/converter/evaluate.py,sha256=APWQUY3gjAXqkJkPzvj0UA4wPK3Cv9QSJLM-YK9t-ng,476
|
14
14
|
janus/converter/requirements.py,sha256=6YvrJRVH9BuPCOPxnXmaJQFYmoLYYvCu3zTntDLHeNg,1832
|
@@ -88,6 +88,7 @@ janus/parsers/code_parser.py,sha256=XwCoOYwnx2tpqluIdXWg-GWOOkooSDYmJHvqDrxgf48,
|
|
88
88
|
janus/parsers/doc_parser.py,sha256=X8eCb1QXbL6sVWLEFGjsPyxrpJ9XnOPg7G4KZSo9A9E,5658
|
89
89
|
janus/parsers/eval_parser.py,sha256=HB5-zY_Jpmkj6FDbuNCCVCRxwmzhViSAjPKbyyC0Ebc,2723
|
90
90
|
janus/parsers/reqs_parser.py,sha256=MFBvtR3otpyPZlkZxu0dVH1YeEJhvhNzhaGKGHaQVHA,2359
|
91
|
+
janus/parsers/uml.py,sha256=Zb_Yl5NZKYZo8WDNH5TFpaGtI35JR4vJQTVNBH2q6lo,1813
|
91
92
|
janus/prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
92
93
|
janus/prompts/prompt.py,sha256=vd7UbitF0VFCi21RsggDebD51xcuyls_lQLGKkphfI8,10578
|
93
94
|
janus/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -97,8 +98,8 @@ janus/utils/_tests/test_progress.py,sha256=Yh5NDNq-24n2nhHHbJm39pENAH70PYnh9ymwd
|
|
97
98
|
janus/utils/enums.py,sha256=AoilbdiYyMvY2Mp0AM4xlbLSELfut2XMwhIM1S_msP4,27610
|
98
99
|
janus/utils/logger.py,sha256=KZeuaMAnlSZCsj4yL0P6N-JzZwpxXygzACWfdZFeuek,2337
|
99
100
|
janus/utils/progress.py,sha256=pKcCzO9JOU9fSD7qTmLWcqY5smc8mujqQMXoPgqNysE,1458
|
100
|
-
janus_llm-3.
|
101
|
-
janus_llm-3.
|
102
|
-
janus_llm-3.
|
103
|
-
janus_llm-3.
|
104
|
-
janus_llm-3.
|
101
|
+
janus_llm-3.1.1.dist-info/LICENSE,sha256=_j0st0a-HB6MRbP3_BW3PUqpS16v54luyy-1zVyl8NU,10789
|
102
|
+
janus_llm-3.1.1.dist-info/METADATA,sha256=1ctKwnb7R2X0yHkH6lY54iYX3dcSU6cy4mVBtvO_6bE,4184
|
103
|
+
janus_llm-3.1.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
104
|
+
janus_llm-3.1.1.dist-info/entry_points.txt,sha256=OGhQwzj6pvXp79B0SaBD5apGekCu7Dwe9fZZT_TZ544,39
|
105
|
+
janus_llm-3.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|