Sg-at-srijan-us-kg commited on
Commit
ffd2ed9
·
verified ·
1 Parent(s): e05c2f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -5,7 +5,10 @@ from huggingface_hub import InferenceClient
5
  client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
6
 
7
  # Function to stream the compliance suggestions as they are generated
8
- def analyze_compliance_stream(code, compliance_standard):
 
 
 
9
  prompt = f"Analyze the following code for {compliance_standard} compliance and suggest modifications or refactoring to meet the guidelines:\n\n{code}"
10
 
11
  messages = [
@@ -27,10 +30,18 @@ def analyze_compliance_stream(code, compliance_standard):
27
  compliance_suggestions += chunk.choices[0].delta.content
28
  yield compliance_suggestions # Yield incremental content to display immediately
29
 
 
 
 
30
  # Create Gradio interface with the modified layout
31
  with gr.Blocks() as app:
32
  gr.Markdown("## Code Compliance Advisor")
33
  gr.Markdown("Analyze your code for legal compliance and security standards (e.g., GDPR, HIPAA) and receive actionable suggestions.")
 
 
 
 
 
34
 
35
  with gr.Row():
36
  # First column for input components
@@ -41,6 +52,7 @@ with gr.Blocks() as app:
41
  label="Compliance Standard",
42
  value="GDPR"
43
  )
 
44
  analyze_button = gr.Button("Analyze Compliance")
45
 
46
  # Second column for output
@@ -49,7 +61,7 @@ with gr.Blocks() as app:
49
  output_markdown = gr.Markdown()
50
 
51
  # Link button to function with inputs and outputs
52
- analyze_button.click(fn=analyze_compliance_stream, inputs=[code_input, compliance_standard], outputs=output_markdown)
53
 
54
  # Run the Gradio app
55
  app.launch()
 
5
  client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
6
 
7
  # Function to stream the compliance suggestions as they are generated
8
+ def analyze_compliance_stream(code, compliance_standard, consent):
9
+ if not consent:
10
+ return "You must consent to the processing of your code snippet."
11
+
12
  prompt = f"Analyze the following code for {compliance_standard} compliance and suggest modifications or refactoring to meet the guidelines:\n\n{code}"
13
 
14
  messages = [
 
30
  compliance_suggestions += chunk.choices[0].delta.content
31
  yield compliance_suggestions # Yield incremental content to display immediately
32
 
33
+ # Delete the code snippet after processing
34
+ del code
35
+
36
  # Create Gradio interface with the modified layout
37
  with gr.Blocks() as app:
38
  gr.Markdown("## Code Compliance Advisor")
39
  gr.Markdown("Analyze your code for legal compliance and security standards (e.g., GDPR, HIPAA) and receive actionable suggestions.")
40
+ gr.Markdown("### Privacy Notice")
41
+ gr.Markdown("""
42
+ By using this tool, you consent to the processing of your code snippet for compliance analysis. Your code will be sent to a third-party model for analysis and the results will be displayed to you. We do not store your code or the results unless required by law.
43
+ You have the right to access and erase your data. If you wish to request access to your data or have it erased, please contact us at [[email protected]].
44
+ """)
45
 
46
  with gr.Row():
47
  # First column for input components
 
52
  label="Compliance Standard",
53
  value="GDPR"
54
  )
55
+ consent_checkbox = gr.Checkbox(label="I consent to the processing of my code snippet", value=False)
56
  analyze_button = gr.Button("Analyze Compliance")
57
 
58
  # Second column for output
 
61
  output_markdown = gr.Markdown()
62
 
63
  # Link button to function with inputs and outputs
64
+ analyze_button.click(fn=analyze_compliance_stream, inputs=[code_input, compliance_standard, consent_checkbox], outputs=output_markdown)
65
 
66
  # Run the Gradio app
67
  app.launch()