@@ -124,7 +124,7 @@ def main():
124124 else :
125125 try :
126126 # GEMINI Replace with your Gemini Api key
127- GOOGLE_API_KEY = "AIzaSyC9Qos7UR9jjb5WatykUZumrla8KvTamfE"
127+ GOOGLE_API_KEY = os . getenv ( 'gemini-api' )
128128 genai .configure (api_key = GOOGLE_API_KEY )
129129 model = genai .GenerativeModel (selected_model )
130130 prompt = user_input
@@ -150,22 +150,22 @@ def main():
150150 except Exception as e :
151151 st .error (f"An error occurred: { e } " )
152152
153- export_to_csv (st .session_state .chat_history )
153+ # export_to_csv(st.session_state.chat_history)
154154
155155
156156 except Exception as e :
157157 st .error (f"An error occurred: { e } " )
158158
159- def export_to_csv (chat_history ):
160- filename = "chat_history.csv"
161- latest_conversation = chat_history [- 2 :] # Get only the latest conversation
162- with open (filename , "a+" , newline = "" ) as csvfile :
163- fieldnames = ["User Input" , "Bot Response" ]
164- writer = csv .DictWriter (csvfile , fieldnames = fieldnames )
165- if csvfile .tell () == 0 : # Check if the file is empty
166- writer .writeheader () # Write header if file is empty
167- if len (latest_conversation ) == 2 : # Check if the latest conversation is complete
168- writer .writerow ({"User Input" : latest_conversation [0 ]["content" ], "Bot Response" : latest_conversation [1 ]["content" ]})
159+ # def export_to_csv(chat_history):
160+ # filename = "chat_history.csv"
161+ # latest_conversation = chat_history[-2:] # Get only the latest conversation
162+ # with open(filename, "a+", newline="") as csvfile:
163+ # fieldnames = ["User Input", "Bot Response"]
164+ # writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
165+ # if csvfile.tell() == 0: # Check if the file is empty
166+ # writer.writeheader() # Write header if file is empty
167+ # if len(latest_conversation) == 2: # Check if the latest conversation is complete
168+ # writer.writerow({"User Input": latest_conversation[0]["content"], "Bot Response": latest_conversation[1]["content"]})
169169
170170def display_conversation (conversation_id ):
171171 c .execute ("SELECT * FROM chat_history WHERE conversation_id=?" , (conversation_id ,))
0 commit comments