Spaces:
Sleeping
Sleeping
| """Interaction logger page""" | |
| import streamlit as st | |
| from datetime import datetime, timedelta | |
| from typing import Dict, List, Any, Optional | |
| def show(): | |
| """Display interaction logger page""" | |
| st.title("Log Interaction") | |
| # Get services | |
| db_service = st.session_state.services['db'] | |
| interaction_service = st.session_state.services['interaction'] | |
| llm_service = st.session_state.services['llm'] | |
| # Get user's accounts | |
| accounts = db_service.get_user_accounts(st.session_state.user['id']) | |
| if not accounts: | |
| st.warning("No accounts found. Please contact your administrator.") | |
| return | |
| # Interaction form | |
| with st.form("interaction_form"): | |
| # Select account | |
| selected_account = st.selectbox( | |
| "Account", | |
| options=accounts, | |
| format_func=lambda x: x['name'] | |
| ) | |
| # Interaction type | |
| interaction_type = st.selectbox( | |
| "Interaction Type", | |
| options=[ | |
| 'meeting', 'call', 'email', 'presentation', | |
| 'workshop', 'proposal_review' | |
| ] | |
| ) | |
| # Location and duration | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| location = st.radio( | |
| "Location", | |
| options=['Virtual', 'In-Person'] | |
| ) | |
| with col2: | |
| if location == 'Virtual': | |
| platform = st.selectbox( | |
| "Platform", | |
| options=['Zoom', 'Teams', 'Google Meet'] | |
| ) | |
| duration = st.number_input( | |
| "Duration (minutes)", | |
| min_value=5, | |
| max_value=240, | |
| value=30, | |
| step=5 | |
| ) | |
| # Transcript | |
| transcript = st.text_area( | |
| "Interaction Notes/Transcript", | |
| height=200, | |
| help="Enter meeting notes, conversation summary, or email content" | |
| ) | |
| submitted = st.form_submit_button("Save Interaction") | |
| if submitted and transcript: | |
| # Prepare interaction data | |
| interaction_data = { | |
| 'type': interaction_type, | |
| 'account_id': selected_account['id'], | |
| 'owner_id': st.session_state.user['id'], | |
| 'transcript': transcript, | |
| 'metadata': { | |
| 'location': location, | |
| 'platform': platform if location == 'Virtual' else None, | |
| 'duration': duration | |
| } | |
| } | |
| # Save interaction | |
| with st.spinner("Processing interaction..."): | |
| try: | |
| interaction_id = interaction_service.create_interaction( | |
| db_service, | |
| llm_service, | |
| interaction_data | |
| ) | |
| st.success("Interaction logged successfully!") | |
| # Show summary | |
| interaction = db_service.get_recent_interactions( | |
| st.session_state.user['id'], | |
| limit=1 | |
| )[0] | |
| with st.expander("View Summary", expanded=True): | |
| st.markdown("### Summary") | |
| st.write(interaction['summary']) | |
| if interaction['metadata'].get('key_points'): | |
| st.markdown("### Key Points") | |
| for point in interaction['metadata']['key_points']: | |
| st.write(f"- {point}") | |
| if interaction['metadata'].get('action_items'): | |
| st.markdown("### Action Items") | |
| for item in interaction['metadata']['action_items']: | |
| st.write(f"- {item}") | |
| except Exception as e: | |
| st.error(f"Error saving interaction: {str(e)}") | |
| # Show recent interactions | |
| st.markdown("---") | |
| st.subheader("Recent Interactions") | |
| recent = db_service.get_recent_interactions( | |
| st.session_state.user['id'], | |
| limit=5 | |
| ) | |
| for interaction in recent: | |
| with st.expander( | |
| f"{interaction['type']} with {interaction['account_name']} on {interaction['created_at'][:10]}" | |
| ): | |
| st.write(f"Summary: {interaction['summary']}") | |
| if interaction['sentiment_score']: | |
| st.write(f"Sentiment: {interaction['sentiment_score']:.2f}") | |
| if interaction['metadata'].get('location'): | |
| st.write(f"Location: {interaction['metadata']['location']}") |