Spaces:
Build error
Build error
Commit
·
265877f
1
Parent(s):
0f8cdfc
Update app.py
Browse files
app.py
CHANGED
@@ -14,14 +14,18 @@ def get_conversation_history(chat_tutor):
|
|
14 |
|
15 |
### Instructor Interface Helper Functions ###
|
16 |
def get_instructor_prompt(fileobj):
|
|
|
17 |
file_path = fileobj.name
|
18 |
-
|
19 |
-
|
20 |
return instructor_prompt
|
21 |
|
22 |
-
def embed_prompt(
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
|
26 |
### User Interfaces ###
|
27 |
with gr.Blocks() as demo:
|
@@ -106,7 +110,7 @@ with gr.Blocks() as demo:
|
|
106 |
# Set the secret prompt in this session and embed it to the study tutor
|
107 |
prompt_submit_btn = gr.Button("Submit")
|
108 |
prompt_submit_btn.click(
|
109 |
-
fn=embed_prompt, inputs=[instructor_prompt], outputs=[view_secret]
|
110 |
).then(
|
111 |
fn=create_reference_store,
|
112 |
inputs=[study_tutor, prompt_submit_btn, instructor_prompt, file_input_none, instructor_input_none, api_input, instructor_prompt],
|
|
|
14 |
|
15 |
### Instructor Interface Helper Functions ###
|
16 |
def get_instructor_prompt(fileobj):
|
17 |
+
# get file path
|
18 |
file_path = fileobj.name
|
19 |
+
with open(file_path, "r") as f:
|
20 |
+
instructor_prompt = f.read()
|
21 |
return instructor_prompt
|
22 |
|
23 |
+
def embed_prompt(prompt, chat_tutor):
|
24 |
+
# update secret
|
25 |
+
os.environ["SECRET_PROMPT"] = prompt
|
26 |
+
# update tutor
|
27 |
+
chat_tutor.learning_objectives = prompt
|
28 |
+
return os.environ.get("SECRET_PROMPT"), chat_tutor
|
29 |
|
30 |
### User Interfaces ###
|
31 |
with gr.Blocks() as demo:
|
|
|
110 |
# Set the secret prompt in this session and embed it to the study tutor
|
111 |
prompt_submit_btn = gr.Button("Submit")
|
112 |
prompt_submit_btn.click(
|
113 |
+
fn=embed_prompt, inputs=[instructor_prompt, study_tutor], outputs=[view_secret, study_tutor]
|
114 |
).then(
|
115 |
fn=create_reference_store,
|
116 |
inputs=[study_tutor, prompt_submit_btn, instructor_prompt, file_input_none, instructor_input_none, api_input, instructor_prompt],
|