Ravi theja K commited on
Commit
71a6503
·
verified ·
1 Parent(s): e716375

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -138,21 +138,15 @@ def generate_arctic_response():
138
  abort_chat(f"Conversation length too long. Please keep it under {max_tokens} tokens.")
139
 
140
  st.session_state.messages.append({"role": "assistant", "content": ""})
141
- for event_index, event in enumerate(replicate.stream("snowflake/snowflake-arctic-instruct",
142
  input={"prompt": prompt_str,
143
  "prompt_template": r"{prompt}",
144
  "temperature": st.session_state.temperature,
145
  "top_p": st.session_state.top_p,
146
- })):
147
- if (event_index + 0) % 50 == 0:
148
- if not check_safety():
149
- abort_chat("I cannot answer this question.")
150
- st.session_state.messages[-1]["content"] += str(event)
151
- yield str(event)
152
-
153
- # Final safety check...
154
- if not check_safety():
155
- abort_chat("I cannot answer this question.")
156
 
157
  if __name__ == "__main__":
158
  main()
 
138
  abort_chat(f"Conversation length too long. Please keep it under {max_tokens} tokens.")
139
 
140
  st.session_state.messages.append({"role": "assistant", "content": ""})
141
+ for event in replicate.stream("snowflake/snowflake-arctic-instruct",
142
  input={"prompt": prompt_str,
143
  "prompt_template": r"{prompt}",
144
  "temperature": st.session_state.temperature,
145
  "top_p": st.session_state.top_p,
146
+ }):
147
+ print(str(event), end="")
148
+
149
+
 
 
 
 
 
 
150
 
151
  if __name__ == "__main__":
152
  main()