eagle0504 commited on
Commit
16eba78
·
1 Parent(s): f10822f

spinner added

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -56,28 +56,29 @@ if prompt := st.chat_input("What is up?"):
56
  # Add user message to chat history
57
  st.session_state.messages.append({"role": "user", "content": prompt})
58
 
59
- if option == "Sentiment Analysis":
60
- pipe_sentiment_analysis = pipeline("sentiment-analysis")
61
- if prompt:
62
- out = pipe_sentiment_analysis(prompt)
63
- doc = f"""
64
- Prompt: {prompt}
65
- Sentiment: {out[0]["label"]}
66
- Score: {out[0]["score"]}
67
- """
68
- elif option == "Medical Summarization":
69
- pipe_summarization = pipeline(
70
- "summarization", model="Falconsai/medical_summarization"
71
- )
72
- if prompt:
73
- out = pipe_summarization(prompt)
74
- doc = out[0]["summary_text"]
75
- elif option == "ChatGPT":
76
- if prompt:
77
- out = call_chatgpt(query=prompt)
78
- doc = out
79
- else:
80
- None
 
81
 
82
  response = f"{doc}"
83
  # Display assistant response in chat message container
 
56
  # Add user message to chat history
57
  st.session_state.messages.append({"role": "user", "content": prompt})
58
 
59
+ with st.spinner("Wait for it..."):
60
+ if option == "Sentiment Analysis":
61
+ pipe_sentiment_analysis = pipeline("sentiment-analysis")
62
+ if prompt:
63
+ out = pipe_sentiment_analysis(prompt)
64
+ doc = f"""
65
+ Prompt: {prompt}
66
+ Sentiment: {out[0]["label"]}
67
+ Score: {out[0]["score"]}
68
+ """
69
+ elif option == "Medical Summarization":
70
+ pipe_summarization = pipeline(
71
+ "summarization", model="Falconsai/medical_summarization"
72
+ )
73
+ if prompt:
74
+ out = pipe_summarization(prompt)
75
+ doc = out[0]["summary_text"]
76
+ elif option == "ChatGPT":
77
+ if prompt:
78
+ out = call_chatgpt(query=prompt)
79
+ doc = out
80
+ else:
81
+ doc = ""
82
 
83
  response = f"{doc}"
84
  # Display assistant response in chat message container