import streamlit as st import os import pandas as pd from together import Together from helper import * # Set page config with a favicon st.set_page_config( page_title="Duel Agent Simulator", layout="wide") # Custom CSS for premium styling and animations st.markdown(""" """, unsafe_allow_html=True) # Title with animation st.markdown("
⚡ Duel Agent Simulator ⚡
", unsafe_allow_html=True) # Sidebar - Instruction Manual with st.sidebar: st.image("favicon.ico", width=48) with st.expander("📖 Instruction Manual"): st.markdown(""" ## ⚡ Duel Agent Simulator Guide - Input a **topic** below. - Click **Run Simulation!** to generate the interview. - See the **conversation** unfold live! **Tip:** Each interaction gets better as the agent learns! """) user_topic = st.text_input("Enter a topic", "Data Science") col1, col2 = st.columns(2) with col1: submit_button = st.button("🚀 Start Simulation!") with col2: if st.button("🔁 Reset Session"): st.session_state.messages = [] st.rerun() # Initialize chat history if "messages" not in st.session_state: st.session_state.messages = [] # Display chat messages for message in st.session_state.messages: with st.chat_message(message["role"]): st.markdown(message["content"]) # Create Agents interviewer, interviewee, judge, humorist, stats_guru = call_gemini, call_gemini, call_gemini, call_gemini, call_gemini # Lists to store results iter, list_of_iters, list_of_questions, list_of_answers, list_of_judge_comments, list_of_passes, list_of_jokes, list_of_stats = 0, [], [], [], [], [], [], [] if submit_button: st.chat_message("user").markdown(f"**User Topic:** {user_topic}") st.session_state.messages.append({"role": "user", "content": user_topic}) while True: question = interviewer(f"Ask a question about this topic: {user_topic}") with st.spinner("🤖 Interviewer thinking..."): st.chat_message("assistant").markdown(f"**Interviewer:** {question}") st.session_state.messages.append({"role": "assistant", "content": question}) if iter < 5: answer = interviewee(f"Answer the question: {question} in a mediocre way as an inexperienced interviewee.") else: answer = interviewee(f"Answer the question: {question}, learning from the judge's feedback: {judge_comments}") st.chat_message("user").markdown(f"**Interviewee:** {answer}") st.session_state.messages.append({"role": "user", "content": answer}) judge_comments = judge(f"Evaluate: {question}\nAnswer: {answer}\nRate 1-10 and provide feedback.") st.success(f"🧑⚖️ Judge: {judge_comments}") joke = humorist(f"Make a joke about the interviewee's answer: {answer}") st.warning(f"🎭 **Humorist:** {joke}") st.session_state.messages.append({"role": "assistant", "content": joke}) stats_comment = stats_guru(f"Give an interesting statistical insight or fact based on this topic: {user_topic}") st.info(f"📊 **Statistics Guru:** {stats_comment}") st.session_state.messages.append({"role": "assistant", "content": stats_comment}) passed_or_not = 1 if '8' in judge_comments else 0 list_of_iters.append(iter) list_of_questions.append(question) list_of_answers.append(answer) list_of_judge_comments.append(judge_comments) list_of_jokes.append(joke) list_of_stats.append(stats_comment) list_of_passes.append(passed_or_not) with st.expander("📊 Simulation Summary"): st.table(pd.DataFrame({ "Iteration": list_of_iters, "Questions": list_of_questions, "Answers": list_of_answers, "Judge Feedback": list_of_judge_comments, "Jokes": list_of_jokes, "Stats": list_of_stats, "Passed": list_of_passes })) if '8' in judge_comments: break iter += 1