Spaces:
Runtime error
Runtime error
Update pages/Phase1.py
Browse files- pages/Phase1.py +4 -6
pages/Phase1.py
CHANGED
@@ -21,11 +21,11 @@ model_info = {
|
|
21 |
}
|
22 |
}
|
23 |
|
24 |
-
def format_prompt(
|
25 |
prompt = ""
|
26 |
if custom_instructions:
|
27 |
prompt += f"[INST] {custom_instructions} [/INST]"
|
28 |
-
prompt += f"[INST] {
|
29 |
return prompt
|
30 |
|
31 |
def reset_conversation():
|
@@ -99,9 +99,6 @@ if uploaded_file is not None:
|
|
99 |
if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
100 |
|
101 |
custom_instruction = "Act like a Human in conversation"
|
102 |
-
|
103 |
-
if "pdf_text" in st.session_state:
|
104 |
-
prompt = f"{st.session_state.pdf_text}\n\nQuestion: {prompt}"
|
105 |
|
106 |
# Display user message in chat message container
|
107 |
with st.chat_message("user"):
|
@@ -109,7 +106,8 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
109 |
# Add user message to chat history
|
110 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
111 |
|
112 |
-
|
|
|
113 |
|
114 |
# Display assistant response in chat message container
|
115 |
with st.chat_message("assistant"):
|
|
|
21 |
}
|
22 |
}
|
23 |
|
24 |
+
def format_prompt(context, question, custom_instructions=None):
|
25 |
prompt = ""
|
26 |
if custom_instructions:
|
27 |
prompt += f"[INST] {custom_instructions} [/INST]"
|
28 |
+
prompt += f"{context}\n\n[INST] {question} [/INST]"
|
29 |
return prompt
|
30 |
|
31 |
def reset_conversation():
|
|
|
99 |
if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
100 |
|
101 |
custom_instruction = "Act like a Human in conversation"
|
|
|
|
|
|
|
102 |
|
103 |
# Display user message in chat message container
|
104 |
with st.chat_message("user"):
|
|
|
106 |
# Add user message to chat history
|
107 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
108 |
|
109 |
+
context = st.session_state.pdf_text if "pdf_text" in st.session_state else ""
|
110 |
+
formated_text = format_prompt(context, prompt, custom_instruction)
|
111 |
|
112 |
# Display assistant response in chat message container
|
113 |
with st.chat_message("assistant"):
|