brunhild217 commited on
Commit
64470b0
·
1 Parent(s): 1946f3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import pandas as pd
4
  from functools import partial
5
  from ai_classroom_suite.UIBaseComponents import *
6
- from ai_classroom_suite.MediaVectorStores import get_document_segments
7
 
8
  # Testing purpose
9
  class EchoingTutor(SlightlyDelusionalTutor):
@@ -38,14 +38,13 @@ def get_tutor_reply(chat_tutor):
38
  def get_conversation_history(chat_tutor):
39
  return chat_tutor.conversation_memory, chat_tutor
40
 
41
- def create_prompt_store(chat_tutor, vs_button, upload_files, openai_auth):
42
  text_segs = []
43
  upload_segs = []
44
 
45
- if upload_files:
46
- print(upload_files)
47
- upload_fnames = [f.name for f in upload_files]
48
- upload_segs = get_document_segments(upload_fnames, 'file', chunk_size=700, chunk_overlap=100)
49
 
50
  # get the full list of everything
51
  all_segs = text_segs + upload_segs
@@ -163,7 +162,7 @@ with gr.Blocks() as demo:
163
  fn=embed_prompt, inputs=[instructor_prompt], outputs=[test_secret]
164
  ).then(
165
  fn=create_prompt_store,
166
- inputs=[study_tutor, prompt_submit_btn, file_input, api_input],
167
  outputs=[study_tutor, prompt_submit_btn]
168
  )
169
  # TODO: may need a way to set the secret prompt permanently in settings/secret
 
3
  import pandas as pd
4
  from functools import partial
5
  from ai_classroom_suite.UIBaseComponents import *
6
+ from ai_classroom_suite.MediaVectorStores import *
7
 
8
  # Testing purpose
9
  class EchoingTutor(SlightlyDelusionalTutor):
 
38
  def get_conversation_history(chat_tutor):
39
  return chat_tutor.conversation_memory, chat_tutor
40
 
41
+ def create_prompt_store(chat_tutor, vs_button, text_cp, openai_auth):
42
  text_segs = []
43
  upload_segs = []
44
 
45
+ if text_cp.strip():
46
+ text_segs = get_document_segments(text_cp, 'text', chunk_size=700, chunk_overlap=100)
47
+ [doc.metadata.update({'source':'text box'}) for doc in text_segs];
 
48
 
49
  # get the full list of everything
50
  all_segs = text_segs + upload_segs
 
162
  fn=embed_prompt, inputs=[instructor_prompt], outputs=[test_secret]
163
  ).then(
164
  fn=create_prompt_store,
165
+ inputs=[study_tutor, prompt_submit_btn, instructor_prompt, api_input],
166
  outputs=[study_tutor, prompt_submit_btn]
167
  )
168
  # TODO: may need a way to set the secret prompt permanently in settings/secret