Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
@@ -102,13 +102,15 @@ def send_selected_story(title, model_name, system_prompt):
|
|
102 |
data = [] # Reset data for new story
|
103 |
tokenizer, model = load_model(model_name)
|
104 |
selected_story = title
|
|
|
105 |
for story in stories:
|
106 |
if story["title"] == title:
|
|
|
107 |
system_prompt = f"""
|
108 |
{system_prompt}
|
109 |
Here is the story:
|
110 |
---
|
111 |
-
{
|
112 |
---
|
113 |
"""
|
114 |
combined_message = system_prompt.strip()
|
@@ -120,7 +122,7 @@ Here is the story:
|
|
120 |
question_prompt = "Please ask a simple question about the story to encourage interaction."
|
121 |
_, formatted_history, chat_history = interact(question_prompt, chat_history)
|
122 |
|
123 |
-
return formatted_history, chat_history, gr.update(value=[]) # Reset the data table
|
124 |
else:
|
125 |
print("Combined message is empty.")
|
126 |
else:
|
@@ -190,6 +192,8 @@ with gr.Blocks() as demo:
|
|
190 |
with gr.Column(scale=2):
|
191 |
chatbot_output = gr.Chatbot(label="Chat History")
|
192 |
|
|
|
|
|
193 |
with gr.Row():
|
194 |
with gr.Column(scale=1):
|
195 |
score_input = gr.Slider(minimum=0, maximum=5, step=1, label="Score")
|
@@ -200,7 +204,7 @@ with gr.Blocks() as demo:
|
|
200 |
|
201 |
chat_history_json = gr.JSON(value=[], visible=False)
|
202 |
|
203 |
-
send_story_button.click(fn=send_selected_story, inputs=[story_dropdown, model_dropdown, system_prompt_input], outputs=[chatbot_output, chat_history_json, data_table])
|
204 |
send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json], outputs=[chatbot_input, chatbot_output, chat_history_json])
|
205 |
save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown], outputs=[data_table, comment_input])
|
206 |
|
|
|
102 |
data = [] # Reset data for new story
|
103 |
tokenizer, model = load_model(model_name)
|
104 |
selected_story = title
|
105 |
+
story_text = ""
|
106 |
for story in stories:
|
107 |
if story["title"] == title:
|
108 |
+
story_text = story['story']
|
109 |
system_prompt = f"""
|
110 |
{system_prompt}
|
111 |
Here is the story:
|
112 |
---
|
113 |
+
{story_text}
|
114 |
---
|
115 |
"""
|
116 |
combined_message = system_prompt.strip()
|
|
|
122 |
question_prompt = "Please ask a simple question about the story to encourage interaction."
|
123 |
_, formatted_history, chat_history = interact(question_prompt, chat_history)
|
124 |
|
125 |
+
return formatted_history, chat_history, story_text, gr.update(value=[]) # Reset the data table
|
126 |
else:
|
127 |
print("Combined message is empty.")
|
128 |
else:
|
|
|
192 |
with gr.Column(scale=2):
|
193 |
chatbot_output = gr.Chatbot(label="Chat History")
|
194 |
|
195 |
+
story_display = gr.Textbox(label="Selected Story", lines=10, interactive=False)
|
196 |
+
|
197 |
with gr.Row():
|
198 |
with gr.Column(scale=1):
|
199 |
score_input = gr.Slider(minimum=0, maximum=5, step=1, label="Score")
|
|
|
204 |
|
205 |
chat_history_json = gr.JSON(value=[], visible=False)
|
206 |
|
207 |
+
send_story_button.click(fn=send_selected_story, inputs=[story_dropdown, model_dropdown, system_prompt_input], outputs=[chatbot_output, chat_history_json, story_display, data_table])
|
208 |
send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json], outputs=[chatbot_input, chatbot_output, chat_history_json])
|
209 |
save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown], outputs=[data_table, comment_input])
|
210 |
|