WHG2023 commited on
Commit
5753724
·
1 Parent(s): 7376d7d

feat: Add ethical data collection with user consent

Browse files
Files changed (2) hide show
  1. .gitignore +0 -0
  2. app.py +32 -3
.gitignore CHANGED
Binary files a/.gitignore and b/.gitignore differ
 
app.py CHANGED
@@ -8,10 +8,24 @@ import base64
8
  import tempfile
9
  import re
10
  import urllib.parse
 
11
 
12
  # Load environment variables from .env file
13
  load_dotenv()
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # --- New Agentic Backend Integration ---
16
  try:
17
  from real_ai_agents_implementation import AgenticNegotiator, NegotiationState
@@ -119,7 +133,7 @@ def create_negotiation_transcript_display(transcript: List[Dict]) -> str:
119
 
120
  return markdown
121
 
122
- def run_patent_architect_in_ui(invention_disclosure: str) -> Generator[List, None, None]:
123
  """
124
  This is the new main UI function that runs the true agentic workflow.
125
  It no longer calls an external backend.
@@ -145,6 +159,10 @@ def run_patent_architect_in_ui(invention_disclosure: str) -> Generator[List, Non
145
  yield [negotiation_html, prior_art_section, summary_section, figures_section, claims_section, status]
146
  return
147
 
 
 
 
 
148
  # --- Start the Real Agentic Workflow ---
149
  negotiator = AgenticNegotiator(invention_disclosure)
150
 
@@ -249,7 +267,16 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"), t
249
  placeholder="Describe the core of your invention. Focus on what it does and what makes it novel. The AI agent team will analyze the technical fundamentals.",
250
  info="Provide a clear, concise description. Details are good, but the core concept is essential."
251
  )
252
- generate_btn = gr.Button("Develop Patent Strategy", variant="primary", size="lg")
 
 
 
 
 
 
 
 
 
253
 
254
  # --- STEP 2: LIVE ANALYSIS ---
255
  gr.Markdown("""
@@ -313,9 +340,11 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"), t
313
  label="Invention Examples (click one to get started)"
314
  )
315
 
 
 
316
  generate_btn.click(
317
  fn=run_patent_architect_in_ui,
318
- inputs=[invention_input],
319
  outputs=[negotiation_display, prior_art_output, summary_output, figures_output, claims_output, status_display]
320
  )
321
 
 
8
  import tempfile
9
  import re
10
  import urllib.parse
11
+ from datetime import datetime
12
 
13
  # Load environment variables from .env file
14
  load_dotenv()
15
 
16
+ # --- Data Logging (with consent) ---
17
+ def log_user_data(invention_disclosure: str):
18
+ """Logs the user's invention disclosure to a file if consent is given."""
19
+ try:
20
+ with open("user_data_log.txt", "a") as f:
21
+ log_entry = {
22
+ "timestamp": datetime.now().isoformat(),
23
+ "invention_disclosure": invention_disclosure
24
+ }
25
+ f.write(json.dumps(log_entry) + "\n")
26
+ except Exception as e:
27
+ print(f"Error logging user data: {e}")
28
+
29
  # --- New Agentic Backend Integration ---
30
  try:
31
  from real_ai_agents_implementation import AgenticNegotiator, NegotiationState
 
133
 
134
  return markdown
135
 
136
+ def run_patent_architect_in_ui(invention_disclosure: str, consent: bool) -> Generator[List, None, None]:
137
  """
138
  This is the new main UI function that runs the true agentic workflow.
139
  It no longer calls an external backend.
 
159
  yield [negotiation_html, prior_art_section, summary_section, figures_section, claims_section, status]
160
  return
161
 
162
+ # --- Log data only if consent is given ---
163
+ if consent:
164
+ log_user_data(invention_disclosure)
165
+
166
  # --- Start the Real Agentic Workflow ---
167
  negotiator = AgenticNegotiator(invention_disclosure)
168
 
 
267
  placeholder="Describe the core of your invention. Focus on what it does and what makes it novel. The AI agent team will analyze the technical fundamentals.",
268
  info="Provide a clear, concise description. Details are good, but the core concept is essential."
269
  )
270
+
271
+ with gr.Row(elem_classes="consent-row"):
272
+ consent_checkbox = gr.Checkbox(
273
+ label="I agree to let the developer collect my anonymized invention data to improve this tool.",
274
+ value=False,
275
+ interactive=True,
276
+ info="We will only store the invention text and a timestamp. No personal data is collected. See our Privacy Policy."
277
+ )
278
+
279
+ generate_btn = gr.Button("Develop Patent Strategy", variant="primary", size="lg", interactive=False)
280
 
281
  # --- STEP 2: LIVE ANALYSIS ---
282
  gr.Markdown("""
 
340
  label="Invention Examples (click one to get started)"
341
  )
342
 
343
+ consent_checkbox.change(lambda x: gr.update(interactive=x), consent_checkbox, generate_btn)
344
+
345
  generate_btn.click(
346
  fn=run_patent_architect_in_ui,
347
+ inputs=[invention_input, consent_checkbox],
348
  outputs=[negotiation_display, prior_art_output, summary_output, figures_output, claims_output, status_display]
349
  )
350