Spaces:
Running
Running
Commit ·
320c295
1
Parent(s): f904840
commit
Browse files
app.py
CHANGED
|
@@ -17,32 +17,7 @@ from typing import Any, cast # to resolve PyLance freaking out over llama-cpp-py
|
|
| 17 |
from textwrap import dedent
|
| 18 |
import re # remove thinking tag from response
|
| 19 |
|
| 20 |
-
# ----- Get Model ----- #
|
| 21 |
-
# Download Q4_K_M GGUF file from the repo
|
| 22 |
-
model_path = hf_hub_download(
|
| 23 |
-
repo_id="unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF",
|
| 24 |
-
filename="Qwen3-Coder-30B-A3B-Instruct-UD-Q3_K_XL.gguf" # fallback: Q2_K_XL
|
| 25 |
-
)
|
| 26 |
|
| 27 |
-
# Initialize llama.cpp with the local cached path
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
# ----- Init App ----- #
|
| 31 |
-
app = gr.Server(title="Code-to-Flowchart Generator")
|
| 32 |
-
|
| 33 |
-
# ----- Functions ----- #
|
| 34 |
-
|
| 35 |
-
# This is a cleaning function to resolve common syntax errors.
|
| 36 |
-
def quote_labels(text: str) -> str:
|
| 37 |
-
# Mermaid node labels can't hold raw code characters, so quote-wrap each label body
|
| 38 |
-
# A label's real closing bracket is followed by a Mermaid connector, edge-label, pipe, statement end, or EOL
|
| 39 |
-
# operators after a subscript (== < <= > >= != %) are never mistaken for a close.
|
| 40 |
-
END = r'(?=\s*(?:[-<][-.>xo]|==[>=xo]|\||;|$))'
|
| 41 |
-
|
| 42 |
-
def esc(body: str) -> str:
|
| 43 |
-
return (body.replace('"', "'")
|
| 44 |
-
.replace('[', '[').replace(']', ']')
|
| 45 |
-
.replace('{', '{').replace('}', '}'))
|
| 46 |
|
| 47 |
out = []
|
| 48 |
for line in text.split('\n'):
|
|
|
|
| 17 |
from textwrap import dedent
|
| 18 |
import re # remove thinking tag from response
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
out = []
|
| 23 |
for line in text.split('\n'):
|