Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -83,6 +83,11 @@ def reset_conversation():
|
|
83 |
st.session_state.messages = []
|
84 |
return None
|
85 |
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
|
88 |
|
@@ -146,6 +151,10 @@ for message in st.session_state.messages:
|
|
146 |
# Accept user input
|
147 |
if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
148 |
|
|
|
|
|
|
|
|
|
149 |
# Display user message in chat message container
|
150 |
with st.chat_message("user"):
|
151 |
st.markdown(prompt)
|
@@ -160,10 +169,7 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
160 |
headers=headers)
|
161 |
|
162 |
output = client.text_generation(
|
163 |
-
|
164 |
-
{"role": m["role"], "content": m["content"]}
|
165 |
-
for m in st.session_state.messages
|
166 |
-
],
|
167 |
temperature=temp_values,#0.5
|
168 |
max_tokens=3000,
|
169 |
)
|
|
|
83 |
st.session_state.messages = []
|
84 |
return None
|
85 |
|
86 |
+
def format_promt(message, custom_instructions=None):
|
87 |
+
if custom_instructions:
|
88 |
+
promt += f"[INST] {custom_instructions} [/INST]"
|
89 |
+
promt += f"[INST] {message} [/INST]"
|
90 |
+
return promt
|
91 |
|
92 |
|
93 |
|
|
|
151 |
# Accept user input
|
152 |
if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
153 |
|
154 |
+
custom_instruction = "Act like a Human in conversation"
|
155 |
+
|
156 |
+
formated_text = format_promt(prompt, custom_instruction)
|
157 |
+
|
158 |
# Display user message in chat message container
|
159 |
with st.chat_message("user"):
|
160 |
st.markdown(prompt)
|
|
|
169 |
headers=headers)
|
170 |
|
171 |
output = client.text_generation(
|
172 |
+
formated_text
|
|
|
|
|
|
|
173 |
temperature=temp_values,#0.5
|
174 |
max_tokens=3000,
|
175 |
)
|