Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,9 +37,8 @@ def num_tokens_from_messages(messages, model="gpt-3.5-turbo"):
|
|
37 |
num_tokens += 2 # every reply is primed with <im_start>assistant
|
38 |
return num_tokens
|
39 |
|
40 |
-
def initialize_chat():
|
41 |
-
# This function initializes the chat with
|
42 |
-
initial_question = "I'm 14 years old female and want to become a graphic designer. I'm living in Uttar Pradesh in India. How can I start?"
|
43 |
chat_history = [(None, initial_question)]
|
44 |
response, follow_up_questions, token_info = generate_response(initial_question, 0)
|
45 |
chat_history.append((None, response))
|
@@ -186,6 +185,10 @@ with gr.Blocks(css=css) as demo:
|
|
186 |
elem_id="follow-up-questions",
|
187 |
label="Follow up Quiestions"
|
188 |
)
|
|
|
|
|
|
|
|
|
189 |
with gr.Column(scale=1, elem_id="chat-container"):
|
190 |
chatbot = gr.Chatbot(
|
191 |
value=chat_history,
|
@@ -209,7 +212,11 @@ with gr.Blocks(css=css) as demo:
|
|
209 |
inputs=[txt],
|
210 |
label="Questions"
|
211 |
)
|
212 |
-
|
|
|
|
|
|
|
|
|
213 |
|
214 |
chatbot.like(print_like_dislike, None, None)
|
215 |
|
|
|
37 |
num_tokens += 2 # every reply is primed with <im_start>assistant
|
38 |
return num_tokens
|
39 |
|
40 |
+
def initialize_chat(initial_question):
|
41 |
+
# This function initializes the chat with the user-provided initial question.
|
|
|
42 |
chat_history = [(None, initial_question)]
|
43 |
response, follow_up_questions, token_info = generate_response(initial_question, 0)
|
44 |
chat_history.append((None, response))
|
|
|
185 |
elem_id="follow-up-questions",
|
186 |
label="Follow up Quiestions"
|
187 |
)
|
188 |
+
initial_question_input = gr.Textbox(
|
189 |
+
placeholder="Type your initial question here...",
|
190 |
+
label="Initial Question"
|
191 |
+
)
|
192 |
with gr.Column(scale=1, elem_id="chat-container"):
|
193 |
chatbot = gr.Chatbot(
|
194 |
value=chat_history,
|
|
|
212 |
inputs=[txt],
|
213 |
label="Questions"
|
214 |
)
|
215 |
+
initial_question_input.submit(
|
216 |
+
fn=initialize_chat,
|
217 |
+
inputs=[initial_question_input],
|
218 |
+
outputs=[chatbot, follow_up_questions_md, token_info]
|
219 |
+
)
|
220 |
|
221 |
chatbot.like(print_like_dislike, None, None)
|
222 |
|