arif97 commited on
Commit
4f3a66e
1 Parent(s): d987e6a

Couple of Changes

Browse files
Dump/040d67b0-1360-4e48-935d-5efb1eec3605---Arif_Waghbakriwala.pdf ADDED
Binary file (91.7 kB). View file
 
__pycache__/_helper_functions.cpython-312.pyc CHANGED
Binary files a/__pycache__/_helper_functions.cpython-312.pyc and b/__pycache__/_helper_functions.cpython-312.pyc differ
 
_helper_functions.py CHANGED
@@ -890,52 +890,51 @@ def display_question_box(container):
890
 
891
 
892
 
893
- # # --------------------------------------------------------- Front-End Functions/Class 10
894
- import streamlit as st
895
  import markdown
896
-
897
-
898
  def display_citations(heading, contents, container):
899
- # Define CSS styles for the flip card with unique class names
900
- css_styles = """
 
901
  <style>
902
- @keyframes move-in-from-left {
903
- 0% {
904
  transform: translateX(-100%);
905
  opacity: 0;
906
- }
907
- 100% {
908
  transform: translateX(0);
909
  opacity: 1;
910
- }
911
- }
912
- .fancy-container {
913
  display: flex;
914
  justify-content: center;
915
  align-items: center;
916
  margin: 30px auto;
917
  animation: move-in-from-left 1s ease-out forwards;
918
- }
919
- .fancy-card {
920
  width: 500px;
921
  height: 200px;
922
  perspective: 1000px;
923
  position: relative;
924
  border-radius: 20px;
925
  overflow: hidden; /* Ensure contents do not overflow */
926
- }
927
- .fancy-card-inner {
928
  width: 100%;
929
  height: 100%;
930
  text-align: center;
931
  transition: transform 1.25s;
932
  transform-style: preserve-3d;
933
  border-radius: 20px;
934
- }
935
- .fancy-card:hover .fancy-card-inner {
936
  transform: rotateY(180deg);
937
- }
938
- .fancy-card-front, .fancy-card-back {
939
  position: absolute;
940
  width: 100%;
941
  height: 100%;
@@ -949,13 +948,13 @@ def display_citations(heading, contents, container):
949
  border-radius: 20px;
950
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
951
  overflow: hidden; /* Ensure contents do not overflow */
952
- }
953
- .fancy-card-front {
954
  background: linear-gradient(to bottom right, #000, #222);
955
  color: white;
956
  animation: fancy-wiggle 0.5s ease-in-out infinite;
957
- }
958
- .fancy-card-front h2 {
959
  font-size: 20px;
960
  font-style: italic;
961
  color: white;
@@ -965,50 +964,47 @@ def display_citations(heading, contents, container):
965
  word-wrap: break-word; /* Ensure long words wrap */
966
  overflow-wrap: break-word; /* Ensure long words wrap */
967
  word-break: break-all; /* Ensure words break if too long */
968
- }
969
- @keyframes fancy-wiggle {
970
- 0% { transform: translateX(-4px); }
971
- 50% { transform: translateX(4px); }
972
- 100% { transform: translateX(-4px); }
973
- }
974
- .fancy-card-back {
975
  background: linear-gradient(to bottom right, #ffd700, #ffff00);
976
  background-color: #f7f7f7;
977
  color: #333;
978
  transform: rotateY(180deg);
979
  overflow: auto; /* Enable vertical and horizontal scrolling */
980
-
981
- }
982
- .fancy-card-back p {
983
  margin: 10px 0px; /* Add margin to separate paragraphs */
984
- # word-wrap: break-word; /* Ensure long words wrap */
985
- # overflow-wrap: break-word; /* Ensure long words wrap */
986
  word-break: normal; /* Ensure words break if too long */
987
- }
988
- .fancy-card-back a {
989
  color: blue; /* Make links blue */
990
  text-decoration: underline; /* Underline links */
991
  word-wrap: break-word; /* Ensure long links wrap */
992
  overflow-wrap: break-word; /* Ensure long links wrap */
993
  word-break: normal; /* Ensure words break if too long */
994
  display: inline-block;
995
- }
996
  </style>
997
  """
998
 
999
  # Convert markdown contents to HTML
1000
- import markdown
1001
  html_contents = markdown.markdown(contents)
1002
 
1003
  # Define the HTML structure for the fancy card
1004
  html_content = f"""
1005
- <div class="fancy-container">
1006
- <div class="fancy-card">
1007
- <div class="fancy-card-inner">
1008
- <div class="fancy-card-front">
1009
  <h2>{heading}</h2>
1010
  </div>
1011
- <div class="fancy-card-back">
1012
  {html_contents}
1013
  </div>
1014
  </div>
@@ -1022,7 +1018,6 @@ def display_citations(heading, contents, container):
1022
 
1023
 
1024
  def display_allCitations(resp, contain):
1025
-
1026
  for res in resp['context']:
1027
  if res.metadata['source'].endswith('.pdf') or res.metadata['source'].endswith('.txt'):
1028
  headingText = f"{res.metadata['source'].split("---")[-1]} &nbsp;&nbsp Page No.&nbsp;&nbsp;{res.metadata['page']}"
@@ -1030,4 +1025,5 @@ def display_allCitations(resp, contain):
1030
  headingText = f"{res.metadata['source']}"
1031
 
1032
  contents_text = f"A <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> Content <br><br> {res.page_content}"
1033
- display_citations(headingText, contents_text, contain)
 
 
890
 
891
 
892
 
893
+ # --------------------------------------------------------- Front-End Functions/Class 10
 
894
  import markdown
895
+ import random
 
896
  def display_citations(heading, contents, container):
897
+ unique_id = str(random.randint(10000000, 99999999))
898
+
899
+ css_styles = f"""
900
  <style>
901
+ @keyframes move-in-from-left {{
902
+ 0% {{
903
  transform: translateX(-100%);
904
  opacity: 0;
905
+ }}
906
+ 100% {{
907
  transform: translateX(0);
908
  opacity: 1;
909
+ }}
910
+ }}
911
+ .fancy-container-{unique_id} {{
912
  display: flex;
913
  justify-content: center;
914
  align-items: center;
915
  margin: 30px auto;
916
  animation: move-in-from-left 1s ease-out forwards;
917
+ }}
918
+ .fancy-card-{unique_id} {{
919
  width: 500px;
920
  height: 200px;
921
  perspective: 1000px;
922
  position: relative;
923
  border-radius: 20px;
924
  overflow: hidden; /* Ensure contents do not overflow */
925
+ }}
926
+ .fancy-card-inner-{unique_id} {{
927
  width: 100%;
928
  height: 100%;
929
  text-align: center;
930
  transition: transform 1.25s;
931
  transform-style: preserve-3d;
932
  border-radius: 20px;
933
+ }}
934
+ .fancy-card-{unique_id}:hover .fancy-card-inner-{unique_id} {{
935
  transform: rotateY(180deg);
936
+ }}
937
+ .fancy-card-front-{unique_id}, .fancy-card-back-{unique_id} {{
938
  position: absolute;
939
  width: 100%;
940
  height: 100%;
 
948
  border-radius: 20px;
949
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
950
  overflow: hidden; /* Ensure contents do not overflow */
951
+ }}
952
+ .fancy-card-front-{unique_id} {{
953
  background: linear-gradient(to bottom right, #000, #222);
954
  color: white;
955
  animation: fancy-wiggle 0.5s ease-in-out infinite;
956
+ }}
957
+ .fancy-card-front-{unique_id} h2 {{
958
  font-size: 20px;
959
  font-style: italic;
960
  color: white;
 
964
  word-wrap: break-word; /* Ensure long words wrap */
965
  overflow-wrap: break-word; /* Ensure long words wrap */
966
  word-break: break-all; /* Ensure words break if too long */
967
+ }}
968
+ @keyframes fancy-wiggle {{
969
+ 0% {{ transform: translateX(-4px); }}
970
+ 50% {{ transform: translateX(4px); }}
971
+ 100% {{ transform: translateX(-4px); }}
972
+ }}
973
+ .fancy-card-back-{unique_id} {{
974
  background: linear-gradient(to bottom right, #ffd700, #ffff00);
975
  background-color: #f7f7f7;
976
  color: #333;
977
  transform: rotateY(180deg);
978
  overflow: auto; /* Enable vertical and horizontal scrolling */
979
+ }}
980
+ .fancy-card-back-{unique_id} p {{
 
981
  margin: 10px 0px; /* Add margin to separate paragraphs */
 
 
982
  word-break: normal; /* Ensure words break if too long */
983
+ }}
984
+ .fancy-card-back-{unique_id} a {{
985
  color: blue; /* Make links blue */
986
  text-decoration: underline; /* Underline links */
987
  word-wrap: break-word; /* Ensure long links wrap */
988
  overflow-wrap: break-word; /* Ensure long links wrap */
989
  word-break: normal; /* Ensure words break if too long */
990
  display: inline-block;
991
+ }}
992
  </style>
993
  """
994
 
995
  # Convert markdown contents to HTML
996
+
997
  html_contents = markdown.markdown(contents)
998
 
999
  # Define the HTML structure for the fancy card
1000
  html_content = f"""
1001
+ <div class="fancy-container-{unique_id}" id="{unique_id}">
1002
+ <div class="fancy-card-{unique_id}" id="{unique_id}">
1003
+ <div class="fancy-card-inner-{unique_id}" id="{unique_id}">
1004
+ <div class="fancy-card-front-{unique_id}" id="{unique_id}">
1005
  <h2>{heading}</h2>
1006
  </div>
1007
+ <div class="fancy-card-back-{unique_id}" id="{unique_id}">
1008
  {html_contents}
1009
  </div>
1010
  </div>
 
1018
 
1019
 
1020
  def display_allCitations(resp, contain):
 
1021
  for res in resp['context']:
1022
  if res.metadata['source'].endswith('.pdf') or res.metadata['source'].endswith('.txt'):
1023
  headingText = f"{res.metadata['source'].split("---")[-1]} &nbsp;&nbsp Page No.&nbsp;&nbsp;{res.metadata['page']}"
 
1025
  headingText = f"{res.metadata['source']}"
1026
 
1027
  contents_text = f"A <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> Content <br><br> {res.page_content}"
1028
+ display_citations(headingText, contents_text, contain)
1029
+ time.sleep(0.5)