Spaces:
Build error
Build error
Commit
·
26dfd6d
1
Parent(s):
d8ad4e5
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import pandas as pd
|
|
4 |
from functools import partial
|
5 |
from ai_classroom_suite.UIBaseComponents import *
|
6 |
|
7 |
-
### Chatbot Functions ###
|
8 |
def get_tutor_reply(chat_tutor):
|
9 |
chat_tutor.get_tutor_reply()
|
10 |
return gr.update(value="", interactive=True), chat_tutor.conversation_memory, chat_tutor
|
@@ -25,7 +25,6 @@ def embed_prompt(instructor_prompt):
|
|
25 |
|
26 |
### User Interfaces ###
|
27 |
with gr.Blocks() as demo:
|
28 |
-
|
29 |
#initialize tutor (with state)
|
30 |
study_tutor = gr.State(SlightlyDelusionalTutor())
|
31 |
|
@@ -77,9 +76,9 @@ with gr.Blocks() as demo:
|
|
77 |
|
78 |
# Instructor interface
|
79 |
with gr.Tab("Instructor Only"):
|
80 |
-
# API Authentication functionality
|
81 |
-
# Instead of ask students to provide key, the key is now provided by the instructor
|
82 |
"""
|
|
|
|
|
83 |
To permanently set the key, go to Settings -> Variables and secrets -> Secrets,
|
84 |
then replace OPENAI_API_KEY value with whatever openai key of the instructor.
|
85 |
"""
|
@@ -99,6 +98,7 @@ with gr.Blocks() as demo:
|
|
99 |
file_input.upload(fn=get_instructor_prompt, inputs=file_input, outputs=instructor_prompt)
|
100 |
|
101 |
# Placeholders components
|
|
|
102 |
file_input_none = gr.File(visible=False)
|
103 |
instructor_input_none = gr.TextArea(visible=False)
|
104 |
learning_objectives_none = gr.Textbox(visible=False)
|
@@ -109,8 +109,17 @@ with gr.Blocks() as demo:
|
|
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,
|
113 |
outputs=[study_tutor, prompt_submit_btn]
|
114 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
demo.queue().launch(server_name='0.0.0.0', server_port=7860)
|
|
|
4 |
from functools import partial
|
5 |
from ai_classroom_suite.UIBaseComponents import *
|
6 |
|
7 |
+
### User Interface Chatbot Functions ###
|
8 |
def get_tutor_reply(chat_tutor):
|
9 |
chat_tutor.get_tutor_reply()
|
10 |
return gr.update(value="", interactive=True), chat_tutor.conversation_memory, chat_tutor
|
|
|
25 |
|
26 |
### User Interfaces ###
|
27 |
with gr.Blocks() as demo:
|
|
|
28 |
#initialize tutor (with state)
|
29 |
study_tutor = gr.State(SlightlyDelusionalTutor())
|
30 |
|
|
|
76 |
|
77 |
# Instructor interface
|
78 |
with gr.Tab("Instructor Only"):
|
|
|
|
|
79 |
"""
|
80 |
+
API Authentication functionality
|
81 |
+
Instead of ask students to provide key, the key is now provided by the instructor.
|
82 |
To permanently set the key, go to Settings -> Variables and secrets -> Secrets,
|
83 |
then replace OPENAI_API_KEY value with whatever openai key of the instructor.
|
84 |
"""
|
|
|
98 |
file_input.upload(fn=get_instructor_prompt, inputs=file_input, outputs=instructor_prompt)
|
99 |
|
100 |
# Placeholders components
|
101 |
+
text_input_none = gr.Textbox(visible=False)
|
102 |
file_input_none = gr.File(visible=False)
|
103 |
instructor_input_none = gr.TextArea(visible=False)
|
104 |
learning_objectives_none = gr.Textbox(visible=False)
|
|
|
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],
|
113 |
outputs=[study_tutor, prompt_submit_btn]
|
114 |
)
|
115 |
+
|
116 |
+
# TODO: The instructor prompt is now only set in session if not go to Settings/secret,
|
117 |
+
# to "permanently" set the secret prompt not seen by the students who use this space,
|
118 |
+
# one possible way is to recreate the instructor interface in another space,
|
119 |
+
# and load it here to chain with the student interface
|
120 |
+
|
121 |
+
# TODO: Currently, the instructor prompt is handled as text input and stored in the vector store (and in the learning objective),
|
122 |
+
# which means the tutor now is still a question-answering tutor who viewed the prompt as context input.
|
123 |
+
# We need to find a way to provide the prompt directly to the model and set its status.
|
124 |
|
125 |
demo.queue().launch(server_name='0.0.0.0', server_port=7860)
|