Spaces:
Runtime error
Runtime error
Update pages/summarizer.py
Browse files16 unmodified lines171819202122232425262728293031323334351 unmodified line373839404142434445464748495016 unmodified linesst.error(f"Error querying Hugging Face API: {e}")return {"summary_text": f"Error querying Hugging Face API: {e}"}def main():st.set_page_config(layout="centered")st.title("Chat Summarizer")# User input for chat messageuser_message = st.text_input("User Message", "Enter your message here...")# Process user input and query Hugging Face APIif st.button("Summarize"):if user_message:# Construct input text for summarization (no system message)input_text = f"User: {user_message}"# Query Hugging Face API for summarization1 unmodified lineresponse = query_huggingface(payload)# Extract summary text from the API responsesummary_text = response[0]["summary_text"] if isinstance(response, list) else response.get("summary_text", "")# Display summary textst.text_area("Summary", value=summary_text)with st.sidebar:if st.button("Chat With PDF"):st.switch_page('app.py')if __name__ == "__main__":main()16 unmodified lines17181920212223242526272829303132333435363738391 unmodified line414243444546474849505152535455565716 unmodified linesst.error(f"Error querying Hugging Face API: {e}")return {"summary_text": f"Error querying Hugging Face API: {e}"}def main():st.set_page_config(layout="wide")st.title("Chat Summarizer")# Initialize a list to store chat messageschat_history = []# User input for chat messageuser_message = st.text_input("Provide a Chat/Long description to summarize")# Process user input and query Hugging Face API on button clickif st.button("Send"):if user_message:# Add user message to chat historychat_history.append({"speaker": "User", "message": user_message})# Construct input text for summarizationinput_text = f"User: {user_message}"# Query Hugging Face API for summarization1 unmodified lineresponse = query_huggingface(payload)# Extract summary text from the API responsesummary_text = response.get("summary_text", "")# Add summarization response to chat historychat_history.append({"speaker": "Bot", "message": summary_text})# Display chat history as a conversationfor chat in chat_history:if chat["speaker"] == "User":st.text_input("User", chat["message"], disabled=True)elif chat["speaker"] == "Bot":st.text_area("Bot", chat["message"], disabled=True)if __name__ == "__main__":main()
pages/summarizer.py+20-13