@@ -118,6 +118,15 @@ def main():
118118 with st .expander ("General Settings" , expanded = False ):
119119 st .session_state .display_cost = st .checkbox ("Display Cost/API" , value = False )
120120 st .session_state .show_logs = st .checkbox ("Show Logs" , value = False )
121+ # Display the logs
122+ if st .session_state .show_logs :
123+ # read the logs file langchain-coder.log and dipaly the logs as markdown with beautify
124+ file_format = st .session_state .file_format = st .sidebar .selectbox ("Select file format" , ["Markdown" , "Text" ], index = 0 )
125+ with open ("langchain-coder.log" , "r" ) as file :
126+ logs = file .read ()
127+ # download the logs
128+ file_name = f"data_{ random .randint (10000 , 99999 )} .{ file_format .lower ()} "
129+ st .sidebar .download_button (label = "Export Data" , data = logs .encode (), file_name = file_name , mime = file_format .lower ())
121130
122131 # Setting options for Open AI
123132 if st .session_state .ai_option == "Open AI" :
@@ -219,7 +228,9 @@ def main():
219228 with save_code_col :
220229 save_submitted = st .form_submit_button ("Export File" )
221230 if save_submitted :
222- general_utils .download_code (st .session_state .generated_code ,code_file )
231+ code_file_format = code_file .split ("." )[- 1 ]
232+ st .sidebar .download_button (label = "Export Code" , data = st .session_state .generated_code .encode (), file_name = code_file , mime = code_file_format .lower ())
233+ #general_utils.download_code(st.session_state.generated_code,code_file)
223234
224235 # Generate Code button in the third column
225236 with generate_code_col :
@@ -307,15 +318,7 @@ def main():
307318 if selected_model == "code-bison" or selected_model == "code-gecko" :
308319 cost , cost_per_whole_string , total_cost = general_utils .codey_generation_cost (st .session_state .generated_code )
309320 st .table ([["Cost/1K Token" , f"{ cost } USD" ], ["Cost/Whole String" , f"{ cost_per_whole_string } USD" ], ["Total Cost" , f"{ total_cost } USD" ]])
310- # Display the logs
311- if st .session_state .show_logs :
312- # read the logs file langchain-coder.log and dipaly the logs as markdown with beautify
313- file_format = st .session_state .file_format = st .selectbox ("Select file format" , ["Markdown" , "Text" ], index = 0 )
314- with open ("langchain-coder.log" , "r" ) as file :
315- logs = file .read ()
316- # download the logs
317- file_name = f"data_{ random .randint (10000 , 99999 )} .{ file_format .lower ()} "
318- st .sidebar .download_button (label = "Export Data" , data = logs .encode (), file_name = file_name , mime = file_format .lower ())
321+
319322
320323
321324 # Expander for coding guidelines
0 commit comments