jblocher commited on
Commit
a836ef0
·
1 Parent(s): f683932

export at TXT button

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -38,6 +38,13 @@ I am your Advanced Corp Val AI Coach. I'm here to help you with your final refle
38
  #model = "gpt-3.5-turbo" # free and fast
39
  #model = "gpt-4" # latest and greatest, not yet available
40
 
 
 
 
 
 
 
 
41
  def CustomChatGPT(message, history):
42
  history_openai_format = [{"role": "system", "content": sys_message}]
43
  for human, assistant in history:
@@ -61,8 +68,7 @@ def CustomChatGPT(message, history):
61
  gradio.ChatInterface(fn=CustomChatGPT,
62
  theme = 'gradio/soft',
63
  title = "Advanced Corp Val AI Coach",
 
64
  description = des).queue().launch()
65
 
66
 
67
-
68
-
 
38
  #model = "gpt-3.5-turbo" # free and fast
39
  #model = "gpt-4" # latest and greatest, not yet available
40
 
41
+ # to export chat history
42
+ def save_as_txt(chatbot, filename = 'chat_dialogue.txt'):
43
+ chatbot = list_to_str(chatbot)
44
+ with open(filename, 'w') as file:
45
+ file.write(chatbot)
46
+ files.download(filename)
47
+
48
  def CustomChatGPT(message, history):
49
  history_openai_format = [{"role": "system", "content": sys_message}]
50
  for human, assistant in history:
 
68
  gradio.ChatInterface(fn=CustomChatGPT,
69
  theme = 'gradio/soft',
70
  title = "Advanced Corp Val AI Coach",
71
+ additional_inputs=[gr.Button("TXT").click(save_as_txt, chatbot, None)],
72
  description = des).queue().launch()
73
 
74