Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdded ensure_tool definition
app.py
CHANGED
@@ -31,7 +31,15 @@ wandb.init(
|
|
31 |
HF_TOKEN = os.getenv("HF_API_TOKEN")
|
32 |
client = InferenceClient(model="declare-lab/flan-alpaca-gpt4", token=HF_TOKEN)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
34 |
def run_cppcheck(source_code: str):
|
|
|
|
|
|
|
35 |
# Write uploaded code to temp file
|
36 |
tf = NamedTemporaryFile(suffix=".cpp", delete=False)
|
37 |
tf.write(source_code.encode())
|
|
|
31 |
HF_TOKEN = os.getenv("HF_API_TOKEN")
|
32 |
client = InferenceClient(model="declare-lab/flan-alpaca-gpt4", token=HF_TOKEN)
|
33 |
|
34 |
+
def ensure_tool(name: str):
|
35 |
+
if shutil.which(name) is None:
|
36 |
+
print(f"Error: `{name}` not found. Please install it and retry.", file=sys.stderr)
|
37 |
+
sys.exit(1)
|
38 |
+
|
39 |
def run_cppcheck(source_code: str):
|
40 |
+
# Check for the code checker tool
|
41 |
+
ensure_tool("cppcheck")
|
42 |
+
|
43 |
# Write uploaded code to temp file
|
44 |
tf = NamedTemporaryFile(suffix=".cpp", delete=False)
|
45 |
tf.write(source_code.encode())
|