Spaces:
Sleeping
Sleeping
File size: 5,066 Bytes
1e8f979 25824c1 1e8f979 25824c1 1e8f979 25824c1 1e8f979 25824c1 1e8f979 25824c1 1e8f979 25824c1 1e8f979 d911fbd 1e8f979 f9ac799 1e8f979 f9ac799 1e8f979 f9ac799 1e8f979 f9ac799 1e8f979 de07302 d911fbd 1e8f979 de07302 1e8f979 f9ac799 1e8f979 f9ac799 1e8f979 f9ac799 1e8f979 f9ac799 1e8f979 7b8b051 1e8f979 25824c1 f230245 25824c1 1e8f979 25824c1 1e8f979 25824c1 1e8f979 25824c1 1e8f979 |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
import os
os.system('pip install transformers')
os.system('pip install gradio')
os.system('pip install requests')
import requests
import gradio as gr
from huggingface_hub import InferenceClient
from transformers import pipeline
# Inference client for chat completion
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
# Different pipelines for different tasks
qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
def respond(message, system_message, max_tokens, temperature, top_p):
messages = [{"role": "system", "content": system_message}]
messages.append({"role": "user", "content": message})
response = ""
for message in client.chat_completion(
messages,
max_tokens=max_tokens,
stream=True,
temperature=temperature,
top_p=top_p,
):
token = message.choices[0].delta.content
if token is not None:
response += token
return response
# GDPR Compliance Expert
def evaluate_gdpr_compliance(audit_data):
system_message = (
"You are an expert GDPR compliance officer. Assess the audit data for compliance with GDPR regulations. "
"Provide an analysis that identifies any compliance issues and suggestions for remediation. "
"Ensure a thorough evaluation of data processing, storage, and protection practices in line with GDPR requirements."
)
compliance_analysis = respond(audit_data, system_message, max_tokens=1024, temperature=0.7, top_p=0.95)
return compliance_analysis
# PCI Compliance Expert
def evaluate_pci_compliance(audit_data):
system_message = (
"You are an expert PCI compliance officer. Assess the audit data for compliance with PCI DSS regulations. "
"Provide an analysis that identifies any compliance issues and suggestions for remediation. "
"Ensure a thorough evaluation of payment card data security, storage, and processing practices in line with PCI requirements."
)
compliance_analysis = respond(audit_data, system_message, max_tokens=1024, temperature=0.7, top_p=0.95)
return compliance_analysis
# Custom CSS for the specified theme
custom_css = """
body {
background-color: #000000;
color: #ffffff;
font-family: Arial, sans-serif;
}
.gradio-container {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
background-color: #000000;
border: 1px solid #e0e0e0;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.gr-button {
background-color: #000000 !important;
border-color: #ff0000 !important;
color: #ff0000 !important;
margin: 5px;
}
.gr-button:hover {
background-color: #ff0000 !important;
border-color: #ff0000 !important;
color: #000000 !important;
}
textarea.gr-textbox {
border-radius: 4px !important;
border: 2px solid #ff0000 !important;
background-color: #ffffff !important;
color: #000000 !important;
}
textarea.gr-textbox:focus {
border-color: #ff0000 !important;
outline: 0 !important;
box-shadow: 0 0 0 0.2rem rgba(255, 0, 0, 0.5) !important;
}
#flagging-button {
display: none;
}
footer {
display: none;
}
.chatbox .chat-container .chat-message {
background-color: #000000 !important;
color: #ffffff !important;
}
.chatbox .chat-container .chat-message-input {
background-color: #000000 !important;
color: #ffffff !important;
}
.gr-markdown {
background-color: #000000 !important;
color: #ffffff !important;
}
.gr-markdown h1, .gr-markdown h2, .gr-markdown h3, .gr-markdown h4, .gr-markdown h5, .gr-markdown h6, .gr-markdown p, .gr-markdown ul, .gr-markdown ol, .gr-markdown li {
color: #ffffff !important;
}
.score-box {
width: 60px;
height: 60px;
display: flex;
align-items: center
}
.label-hidden .gr-label {
display: none;
}
"""
# Gradio Interface
with gr.Blocks(css=custom_css) as demo:
with gr.Column():
gr.Markdown("# GDPR and PCI Compliance Evaluation\n### Provide Audit Data for Compliance Check")
audit_data = gr.Textbox(lines=5, placeholder="Enter audit data here...", label="Audit Data", elem_classes="label-hidden")
gdpr_compliance = gr.Textbox(lines=10, placeholder="GDPR Compliance Analysis...", label="GDPR Compliance Analysis", elem_classes="label-hidden")
pci_compliance = gr.Textbox(lines=10, placeholder="PCI Compliance Analysis...", label="PCI Compliance Analysis", elem_classes="label-hidden")
def run_compliance_checks(audit_data):
gdpr_analysis = evaluate_gdpr_compliance(audit_data)
pci_analysis = evaluate_pci_compliance(audit_data)
return gdpr_analysis, pci_analysis
check_compliance_btn = gr.Button("Run Compliance Checks")
check_compliance_btn.click(run_compliance_checks, inputs=[audit_data], outputs=[gdpr_compliance, pci_compliance])
clear_btn = gr.Button("Clear")
clear_btn.click(lambda: ("", "", ""), None, [audit_data, gdpr_compliance, pci_compliance])
demo.launch()
|