ishworrsubedii commited on
Commit
179af5c
1 Parent(s): 94a57a0

remove: pdf code

Browse files
Files changed (2) hide show
  1. app.py +12 -53
  2. requirements.txt +1 -3
app.py CHANGED
@@ -7,9 +7,6 @@ from logic import LLMClient, CodeProcessor
7
  from batch_code_logic_csv import csv_read_batch_code
8
  import zipfile
9
  import io
10
- import markdown2
11
- import pdfkit
12
- import tempfile
13
 
14
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
15
  llm_obj = LLMClient(client)
@@ -51,36 +48,16 @@ if code_dict:
51
  st.markdown(markdown_output)
52
 
53
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
54
-
55
- with tempfile.NamedTemporaryFile(delete=False, suffix=".md") as tmp_md_file:
56
- tmp_md_file.write(markdown_output.encode('utf-8'))
57
- tmp_md_file_path = tmp_md_file.name
58
-
59
- with open(tmp_md_file_path, "r") as md_file:
60
- st.download_button(
61
- label=f"Download {unique_key} Result as Markdown",
62
- data=md_file,
63
- file_name=f"code_analysis_{unique_key}_{timestamp}.md",
64
- mime="text/markdown"
65
- )
66
-
67
- html_output = markdown2.markdown(markdown_output)
68
- with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_pdf_file:
69
- pdf_file_path = tmp_pdf_file.name
70
- pdfkit.from_string(html_output, pdf_file_path)
71
-
72
- with open(pdf_file_path, "rb") as pdf_file:
73
- st.download_button(
74
- label=f"Download {unique_key} Result as PDF",
75
- data=pdf_file,
76
- file_name=f"code_analysis_{unique_key}_{timestamp}.pdf",
77
- mime="application/pdf"
78
- )
79
 
80
  if st.sidebar.button("Batch Predict"):
81
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
82
  all_markdowns = {}
83
-
84
  for key, code_text in code_dict.items():
85
  markdown_output = processor.process_code(code_text, model_choice)
86
  all_markdowns[key] = markdown_output
@@ -88,30 +65,12 @@ if code_dict:
88
  with st.expander(f"Analysis for {key}"):
89
  st.markdown(markdown_output)
90
 
91
- with tempfile.NamedTemporaryFile(delete=False, suffix=".md") as tmp_md_file:
92
- tmp_md_file.write(markdown_output.encode('utf-8'))
93
- tmp_md_file_path = tmp_md_file.name
94
-
95
- with open(tmp_md_file_path, "r") as md_file:
96
- st.download_button(
97
- label=f"Download {key} Result as Markdown",
98
- data=md_file,
99
- file_name=f"code_analysis_{key}_{timestamp}.md",
100
- mime="text/markdown"
101
- )
102
-
103
- html_output = markdown2.markdown(markdown_output)
104
- with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_pdf_file:
105
- pdf_file_path = tmp_pdf_file.name
106
- pdfkit.from_string(html_output, pdf_file_path)
107
-
108
- with open(pdf_file_path, "rb") as pdf_file:
109
- st.download_button(
110
- label=f"Download {key} Result as PDF",
111
- data=pdf_file,
112
- file_name=f"code_analysis_{key}_{timestamp}.pdf",
113
- mime="application/pdf"
114
- )
115
 
116
  zip_buffer = io.BytesIO()
117
  with zipfile.ZipFile(zip_buffer, "w") as zip_file:
 
7
  from batch_code_logic_csv import csv_read_batch_code
8
  import zipfile
9
  import io
 
 
 
10
 
11
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
12
  llm_obj = LLMClient(client)
 
48
  st.markdown(markdown_output)
49
 
50
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
51
+ st.download_button(
52
+ label=f"Download {unique_key} Result as Markdown",
53
+ data=markdown_output,
54
+ file_name=f"code_analysis_{unique_key}_{timestamp}.md",
55
+ mime="text/markdown"
56
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  if st.sidebar.button("Batch Predict"):
59
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
60
  all_markdowns = {}
 
61
  for key, code_text in code_dict.items():
62
  markdown_output = processor.process_code(code_text, model_choice)
63
  all_markdowns[key] = markdown_output
 
65
  with st.expander(f"Analysis for {key}"):
66
  st.markdown(markdown_output)
67
 
68
+ st.download_button(
69
+ label=f"Download {key} Result as Markdown",
70
+ data=markdown_output,
71
+ file_name=f"code_analysis_{key}_{timestamp}.md",
72
+ mime="text/markdown"
73
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  zip_buffer = io.BytesIO()
76
  with zipfile.ZipFile(zip_buffer, "w") as zip_file:
requirements.txt CHANGED
@@ -1,6 +1,4 @@
1
  groq
2
  streamlit
3
  pandas
4
- numpy
5
- pdfkit
6
- markdown2
 
1
  groq
2
  streamlit
3
  pandas
4
+ numpy