import streamlit as st from streamlit.components.v1 import html from langchain_ollama.chat_models import ChatOllama from langchain_ollama.embeddings import OllamaEmbeddings from langchain.schema import HumanMessage, SystemMessage, BaseMessage, AIMessage from langchain_core.prompts import MessagesPlaceholder, ChatPromptTemplate st.set_page_config(layout="wide") st.set_page_config(page_title="Agentic", page_icon=":robot_face:") st.header(":red[CineGuide] the AI Agent\n ", divider='rainbow') @st.cache_resource def get_chat_model(): return ChatOllama(model="deepseek-r1:8b") @st.cache_resource def get_embedding_model(): return OllamaEmbeddings(model='nomic-embed-text:latest') if "chat_model" not in st.session_state: st.session_state.chat_model = get_chat_model() if "embedding_model" not in st.session_state: st.session_state.embedding_model = get_embedding_model() if "messages" not in st.session_state: st.session_state.messages = [] system_message = SystemMessage( content=""" You are “CineGuide,” a friendly and intelligent AI assistant specializing in personalized film and TV show recommendations. Before performing any recommendations, searches, or actions: - Check if the user's profile includes: 1. Name (optional but good for personalization) 2. Location (for local theaters and premieres) 3. Preference: Movies, TV shows, or both 4. Favorite genres 5. Preferred time period (classics, recent releases, specific decades) - If any of these are missing, ask in a conversational way, one at a time, without overwhelming the user. - If the user has not yet mentioned whether they prefer movies or TV shows, their favorite genres, or the period they enjoy most, naturally discover this before proceeding. Your mission: - Build and update a dynamic user profile purely from conversation. - Recommend both classic and new releases tailored to their tastes. - Use available tools to: - Search movies and shows with filters (genre, release year, rating, etc.). - Find local theaters or events where these are premiering. - Identify OTT platforms where suggested content is available. - Provide short summaries and available viewing options for each recommendation. - Ask follow-up questions to refine recommendations (e.g., “Do you feel like watching a drama or a comedy tonight?”). Tone & style: - Be conversational and engaging. - Keep recommendations relevant. - Avoid asking for unnecessary personal data unless it clearly improves suggestions. """ ) col1,col2 =st.columns([0.3,0.7]) st.markdown(""" """, unsafe_allow_html=True) with col1: st.markdown("