Added a diagram generator (based on my drawittome tool)
Browse files- tools/diagrams.py +8 -4
tools/diagrams.py
CHANGED
@@ -75,19 +75,23 @@ def kroki_img_from_mermaid(mermaid_code: str, output_format: str = "svg") -> str
|
|
75 |
|
76 |
|
77 |
def generateDiagram(input_text="I broke my car yesterday, and the mechanics will give it back to me after insurance payment.", input_precisions="Choose the best diagram paradigm"):
|
78 |
-
"""Generates a
|
79 |
|
80 |
Args:
|
81 |
input_text: the text to explain with a diagram.
|
82 |
input_precisions: diagram settings, by default the tool has the ability to choose the best type of diagram.
|
83 |
|
84 |
Returns:
|
85 |
-
kroki_html_result:
|
86 |
-
mermaid_diag_type: type of diagram selected by the tool
|
87 |
mermaid_code: mermaid code
|
88 |
"""
|
89 |
full_content_prompt = f"{PROMPT}. ###INPUT : {input_text}. ###PRECISIONS {input_precisions}"
|
90 |
mermaid_code, mermaid_diag_type = getModelResponseFromContent(content=full_content_prompt )
|
91 |
kroki_html_link = kroki_img_from_mermaid(mermaid_code)
|
92 |
#kroki_html_img = kroki_html_link[kroki_html_link.find('<img '):kroki_html_link.find('>', kroki_html_link.find('<img ')) + 1]
|
93 |
-
return kroki_html_link, mermaid_diag_type, mermaid_code
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
|
77 |
def generateDiagram(input_text="I broke my car yesterday, and the mechanics will give it back to me after insurance payment.", input_precisions="Choose the best diagram paradigm"):
|
78 |
+
"""Generates a diagram to explain a submitted text. The diagram is returned in different formats (HTML and raw code). It handles various types like Graph TB (default, block grouping with colors), flowchart TD (decision processes), sequenceDiagram (actor/system interactions), classDiagram (technical models like SQL schemas), stateDiagram-v2 (state logic or user stories), erDiagram (data entity relationships), gantt (projects and task timelines along dates), and timeline (historical/biographical sequences grouped by decade or century).
|
79 |
|
80 |
Args:
|
81 |
input_text: the text to explain with a diagram.
|
82 |
input_precisions: diagram settings, by default the tool has the ability to choose the best type of diagram.
|
83 |
|
84 |
Returns:
|
85 |
+
kroki_html_result: **Ready to display for chatbots** html diagram.
|
86 |
+
mermaid_diag_type: type of the diagram selected by the tool
|
87 |
mermaid_code: mermaid code
|
88 |
"""
|
89 |
full_content_prompt = f"{PROMPT}. ###INPUT : {input_text}. ###PRECISIONS {input_precisions}"
|
90 |
mermaid_code, mermaid_diag_type = getModelResponseFromContent(content=full_content_prompt )
|
91 |
kroki_html_link = kroki_img_from_mermaid(mermaid_code)
|
92 |
#kroki_html_img = kroki_html_link[kroki_html_link.find('<img '):kroki_html_link.find('>', kroki_html_link.find('<img ')) + 1]
|
93 |
+
return kroki_html_link, mermaid_diag_type, mermaid_code
|
94 |
+
|
95 |
+
|
96 |
+
#La solution tire a son avantage la rapidité du serveur d'inférence SAmbanova couplée à l'ingéniosité de Scout.
|
97 |
+
|