Wajahat698 commited on
Commit
11ed729
·
verified ·
1 Parent(s): 73c3387

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -21
app.py CHANGED
@@ -203,18 +203,9 @@ def clean_text(text):
203
  return cleaned_text
204
 
205
 
206
- def get_trust_tip_and_suggestion(used_tips, used_suggestions):
207
- available_tips = [tip for tip in trust_tips if tip not in used_tips]
208
- available_suggestions = [suggestion for suggestion in suggestions if suggestion not in used_suggestions]
209
-
210
- if not available_tips: # Reset if no available tips
211
- available_tips = trust_tips
212
- if not available_suggestions: # Reset if no available suggestions
213
- available_suggestions = suggestions
214
-
215
- trust_tip = random.choice(available_tips)
216
- suggestion = random.choice(available_suggestions)
217
-
218
  return trust_tip, suggestion
219
 
220
 
@@ -644,21 +635,15 @@ if prompt :
644
  #cleaned_text = re.sub(r'<span[^>]*>', '', cleaned_text)
645
  # Display the response
646
 
647
- trust_tip, suggestion = get_trust_tip_and_suggestion(st.session_state.used_trust_tips, st.session_state.used_suggestions)
648
-
649
- # Update used trust tips and suggestions
650
- st.session_state.used_trust_tips.add(trust_tip)
651
- st.session_state.used_suggestions.add(suggestion)
652
 
653
  combined_text = f"{cleaned_text}\n\n---\n\n**Trust Tip**: {trust_tip}\n\n**Suggestion**: {suggestion}"
654
  st.markdown(combined_text, unsafe_allow_html=True)
655
  #seprtor= st.markdown("---") # Add a separator
656
  #t_tip= st.markdown(f"**Trust Tip**: {trust_tip}")
657
  #s_sug- st.markdown(f"**Suggestion**: {suggestion}")
658
- if not st.session_state.chat_history or st.session_state.chat_history[-1]["content"] != cleaned_text:
659
- st.session_state.chat_history.append({"role": "assistant", "content": cleaned_text})
660
-
661
- copy_to_clipboard(cleaned_text)
662
 
663
 
664
 
@@ -671,6 +656,10 @@ if prompt :
671
  st.write(full_response)
672
 
673
  # Add AI response to chat history
 
 
 
 
674
 
675
 
676
 
 
203
  return cleaned_text
204
 
205
 
206
+ def get_trust_tip_and_suggestion():
207
+ trust_tip = random.choice(trust_tips)
208
+ suggestion = random.choice(suggestions)
 
 
 
 
 
 
 
 
 
209
  return trust_tip, suggestion
210
 
211
 
 
635
  #cleaned_text = re.sub(r'<span[^>]*>', '', cleaned_text)
636
  # Display the response
637
 
638
+ trust_tip, suggestion = get_trust_tip_and_suggestion()
639
+ =
 
 
 
640
 
641
  combined_text = f"{cleaned_text}\n\n---\n\n**Trust Tip**: {trust_tip}\n\n**Suggestion**: {suggestion}"
642
  st.markdown(combined_text, unsafe_allow_html=True)
643
  #seprtor= st.markdown("---") # Add a separator
644
  #t_tip= st.markdown(f"**Trust Tip**: {trust_tip}")
645
  #s_sug- st.markdown(f"**Suggestion**: {suggestion}")
646
+
 
 
 
647
 
648
 
649
 
 
656
  st.write(full_response)
657
 
658
  # Add AI response to chat history
659
+ if not st.session_state.chat_history or st.session_state.chat_history[-1]["content"] != cleaned_text:
660
+ st.session_state.chat_history.append({"role": "assistant", "content": combined_text})
661
+
662
+ copy_to_clipboard(cleaned_text)
663
 
664
 
665