shukdevdatta123 commited on
Commit
d437c5a
·
verified ·
1 Parent(s): 990ba8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -91
app.py CHANGED
@@ -351,69 +351,6 @@ class PersonalAIResearchAssistant:
351
  "response": content,
352
  "knowledge_base_state": context
353
  }
354
-
355
- def generate_weekly_report(self) -> Dict:
356
- """
357
- Generate a weekly summary of research and insights
358
-
359
- Returns:
360
- Weekly report of activity and key findings
361
- """
362
- # Get weekly statistics
363
- one_week_ago = datetime.now().isoformat() # Simplified, should subtract 7 days
364
-
365
- # Count activities in the last week
366
- recent_research = [d for d in self.knowledge_base["research_digests"]
367
- if d["timestamp"] > one_week_ago]
368
- recent_code = [c for c in self.knowledge_base["code_analyses"]
369
- if c["timestamp"] > one_week_ago]
370
- recent_connections = [c for c in self.knowledge_base["concept_connections"]
371
- if c["timestamp"] > one_week_ago]
372
-
373
- # Build context for the report
374
- context = {
375
- "period": "weekly",
376
- "research_count": len(recent_research),
377
- "code_analyses_count": len(recent_code),
378
- "concept_connections_count": len(recent_connections),
379
- "topics_explored": list(set([r["topic"] for r in recent_research])),
380
- "recent_research": recent_research[:3], # Include only top 3
381
- "recent_connections": recent_connections[:3]
382
- }
383
-
384
- # Build the prompt
385
- prompt = f"""Generate a weekly research summary based on the following activity:
386
-
387
- {json.dumps(context, indent=2)}
388
-
389
- Please include:
390
- 1. Overview of research activity
391
- 2. Key findings and insights
392
- 3. Emerging patterns or trends
393
- 4. Suggestions for further exploration
394
-
395
- Format as a concise weekly report.
396
- """
397
-
398
- # Make the API call
399
- response = self.client.chat.completions.create(
400
- messages=[
401
- {"role": "system", "content": "You are a research assistant generating a weekly summary of research activities and findings."},
402
- {"role": "user", "content": prompt}
403
- ],
404
- model=self.model
405
- )
406
-
407
- content = response.choices[0].message.content
408
-
409
- report = {
410
- "type": "weekly_report",
411
- "timestamp": datetime.now().isoformat(),
412
- "content": content,
413
- "stats": context
414
- }
415
-
416
- return report
417
 
418
  def get_kb_stats(self):
419
  """Get statistics about the knowledge base"""
@@ -600,24 +537,6 @@ def query_knowledge_base(query):
600
  except Exception as e:
601
  return f"Error: {str(e)}"
602
 
603
- def generate_report_handler():
604
- """Generate weekly report"""
605
- # Check if API key is set
606
- check_result = check_api_key()
607
- if check_result:
608
- return check_result
609
-
610
- try:
611
- # Generate report
612
- result = para_instance.generate_weekly_report()
613
-
614
- # Format response
615
- response = f"# Weekly Research Report\n\n{result['content']}"
616
-
617
- return response
618
- except Exception as e:
619
- return f"Error: {str(e)}"
620
-
621
  # Create the Gradio interface
622
  def create_gradio_app():
623
  # Define CSS for styling
@@ -803,15 +722,6 @@ def create_gradio_app():
803
  outputs=[kb_output]
804
  )
805
 
806
- report_btn = gr.Button("Generate Weekly Report")
807
- report_output = gr.Markdown("Report will appear here...")
808
-
809
- report_btn.click(
810
- fn=generate_report_handler,
811
- inputs=[],
812
- outputs=[report_output]
813
- )
814
-
815
  gr.Markdown("""
816
  ### Example Queries:
817
  - "What have we learned about quantum computing?"
@@ -835,7 +745,6 @@ def create_gradio_app():
835
  - Code execution and analysis
836
  - Concept connections discovery
837
  - Persistent knowledge base
838
- - Weekly research reports
839
  """)
840
 
841
  return app
 
351
  "response": content,
352
  "knowledge_base_state": context
353
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
 
355
  def get_kb_stats(self):
356
  """Get statistics about the knowledge base"""
 
537
  except Exception as e:
538
  return f"Error: {str(e)}"
539
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  # Create the Gradio interface
541
  def create_gradio_app():
542
  # Define CSS for styling
 
722
  outputs=[kb_output]
723
  )
724
 
 
 
 
 
 
 
 
 
 
725
  gr.Markdown("""
726
  ### Example Queries:
727
  - "What have we learned about quantum computing?"
 
745
  - Code execution and analysis
746
  - Concept connections discovery
747
  - Persistent knowledge base
 
748
  """)
749
 
750
  return app