File size: 1,073 Bytes
672bc8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from fastapi import FastAPI
from llmguardian import SecurityScanner  # Import the SecurityScanner class from the LLMGuardian package
import uvicorn

# Create the web application
app = FastAPI()

# Create the security scanner
scanner = SecurityScanner()

# Create a simple interface
def check_security(model_name, input_text):
    """
    This function creates the web interface where users can test their models
    """
    results = scanner.scan_model(model_name, input_text)
    return results.format_report()

# Create the web interface
interface = gr.Interface(
    fn=check_security,
    inputs=[
        gr.Textbox(label="Model Name"),
        gr.Textbox(label="Test Input")
    ],
    outputs=gr.JSON(label="Security Report"),
    title="LLMGuardian Security Scanner",
    description="Test your LLM model for security vulnerabilities"
)

# Mount the interface
app = gr.mount_gradio_app(app, interface, path="/")

# Ensure the FastAPI app runs when the script is executed
if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)