import streamlit as st import os from openai import OpenAI class ChatBot: def __init__(self): self.client = OpenAI(api_key=os.environ["OPENAI_API_KEY"]) self.history = [{"role": "system", "content": "You are a helpful assistant."}] def generate_response(self, prompt: str) -> str: self.history.append({"role": "user", "content": prompt}) completion = self.client.chat.completions.create( model="gpt-4o", messages=self.history ) response = completion.choices[0].message.content self.history.append({"role": "assistant", "content": response}) return response def get_history(self) -> list: return self.history # Credit: Time def current_year(): now = datetime.now() return now st.set_page_config(layout="wide") st.title("Yin's Profile πŸ€–") with st.sidebar: with st.expander("Instruction Manual"): st.markdown(""" ## Yin's Profile πŸ€– Chatbot This Streamlit app allows you to chat with GPT-4o model. ### How to Use: 1. **Input**: Type your prompt into the chat input box labeled "What is up?". 2. **Response**: The app will display a response from GPT-4o. 3. **Chat History**: Previous conversations will be shown on the app. ### Credits: - **Developer**: [Yiqiao Yin](https://www.y-yin.io/) | [App URL](https://huggingface.co/spaces/eagle0504/gpt-4o-demo) | [LinkedIn](https://www.linkedin.com/in/yiqiaoyin/) | [YouTube](https://youtube.com/YiqiaoYin/) Enjoy chatting with Yin's assistant! """) # Example: st.success("Example: Who is Yiqiao Yin?") st.success("Example: What did Yiqiao do at graduate school?") st.success("Example: Where to find published papers by Yiqiao?") st.success("Example: What is Yiqiao's view on AI?") st.success("Example: What are some online links by Yiqiao I can read about?") st.success("Example: What is Yiqiao's view on stock market?") # Credit: current_year = current_year().year # This will print the current year st.markdown( f"""
Copyright Β© 2010-{current_year} Present Yiqiao Yin
""", unsafe_allow_html=True, ) # Add a button to clear the session state if st.button("Clear Session"): st.session_state.messages = [] st.experimental_rerun() # Initialize chat history if "messages" not in st.session_state: st.session_state.messages = [] # Ensure messages are a list of dictionaries if not isinstance(st.session_state.messages, list): st.session_state.messages = [] if not all(isinstance(msg, dict) for msg in st.session_state.messages): st.session_state.messages = [] # Display chat messages from history on app rerun for message in st.session_state.messages: with st.chat_message(message["role"]): st.markdown(message["content"]) time_now = current_year() yiqiaoyin_profile = f""" Yin's Profile: Full Name: Yiqiao Yin Pronoun: He/Him Current time: {time_now} Yiqiao has been in the AI/ML space since 2015, leading all forms of AI-backed solutions including but not limited to Computer Vision, Natural Language Models (NLP), and most recently Large Language Models (LLMs) and Generative AI. He is currently a Tech Lead at Vertex Inc, a global leading provider of tax technologies πŸ“ŠπŸ’». Previously, he was a Senior ML Engineer at an S&P 500 company, LabCorp, developing AI-driven solutions πŸ§ πŸ’» in drug diagnostics, drug development, operations management, and financial decisions for our global leaders in life sciences πŸŒπŸ”¬ (see Labcorp SEC filings here). He has also held positions such as enterprise-level Data Scientist at Bayer (a EURO STOXX 50 company), Quantitative Researcher (apprenticeship) at AQR (a global hedge fund pioneering in alternative quantitative strategies to portfolio management and factor-based trading), and Equity Trader at T3 Trading on Wall Street (where I was briefly licensed Series 56 by FINRA). He supervises a small fund specializing in algorithmic trading (since 2011, performance is here) in equity market, cryptocurrencies, and real estate investment. He also runs his own monetized YouTube Channel. Feel free to add me on LinkedIn. πŸš€πŸ“ˆ Though he started in Finance, Yin's AI career started from academic environment. He was a PhD student in Statistics at Columbia University from September of 2020 to December of 2021 πŸ“ˆπŸŽ“. He earned a B.A. in Mathematics, and an M.S. in Finance from University of Rochester πŸ’ΌπŸ“Š. His research interests are wide-ranging in representation learning, including Feature Learning, Deep Learning, Computer Vision (CV), and Natural Language Processing (NLP) πŸ€–πŸ‘€. Additionally, he has some prior research experience in Financial Economics and Asset Pricing πŸ’ΉπŸ“‰. Google scholar: 'https://scholar.google.com/citations?hl=en&user=Ju6m_O4AAAAJ' Personal site: 'https://www.y-yin.io/' YouTube: 'https://www.youtube.com/@YiqiaoYin' LinkedIn: 'https://www.linkedin.com/in/yiqiaoyin' When Yiqiao was in PhD program at Columbia University, he investigated heavily in a domain known as dimension reduction and he focused on developing tools for scientists to understand the important features that affect the prediction outcome. He has multiple papers published on the topic known as I-score or Influence Score (Influence Measure) that is a non-parametric dimension reduction technique on supervised learning. The work gave him the foundation of statistical machine learning and experience of conducting independcent research. For more published work by Yiqiao, please check out the site 'https://www.y-yin.io/' under 'Research'. View about stock market: Yiqiao believed that stock market is mostly fairly efficient. Many research groups and companies are doing great things out there with advanced tools. However, market does get "noisy" once in a while and that breeds opportunity. Yiqiao personally trades off a momentum strategy and he has his own market timing algorithm. This app 'https://huggingface.co/spaces/eagle0504/technical-trader' demonstrates how Yiqiao times the entry point should he decides to enter a stock. This app 'https://huggingface.co/spaces/eagle0504/Momentum-Strategy-Screener' demonstrates how Yiqiao weighs the stocks in his portfolio. View about AI: Yiqiao has good faith in today's advancement of AI technology and is a big supporter of AI-backed technology to boost business operation and enhance corporate strategy. Many clients and companies Yiqiao worked with in the past led him to conclude that 'AI alone may falter and stray, but built around a corporate strategy, it paves the way.' Yiqiao built a series of AI-backed apps: - GPT-4o demo: 'https://huggingface.co/spaces/eagle0504/gpt-4o-demo' - Llama demo: 'https://huggingface.co/spaces/eagle0504/meta-llama' - Software-as-a-Service or SAAS demo: 'https://huggingface.co/spaces/eagle0504/saas-template' - Technical Trader (a timing strategy) demo: 'https://huggingface.co/spaces/eagle0504/stable-audio-demo' - Momentum Strategy (a trading algorithm) demo: 'https://huggingface.co/spaces/eagle0504/Momentum-Strategy-Screener' - Stable Audio demo: 'https://huggingface.co/spaces/eagle0504/stable-audio-demo' - Duel Agent Simulation (a chain of thoughts/abstraction) demo: 'https://huggingface.co/spaces/eagle0504/duel-agent-simulation' - Intelligent Document Processing demo: 'https://huggingface.co/spaces/eagle0504/IDP-Demo' """ # React to user input if prompt := st.chat_input("πŸ˜‰ Ask any question or feel free to use the examples provided in the left sidebar."): # Display user message in chat message container st.chat_message("user").markdown(prompt) # Add user message to chat history st.session_state.messages.append({"role": "system", "content": f"You know the following about Mr. Yiqiao Yin: {yiqiaoyin_profile}"}) st.session_state.messages.append({"role": "user", "content": prompt}) # API Call bot = ChatBot() bot.history = st.session_state.messages.copy() # Update history from messages response = bot.generate_response(prompt) # Display assistant response in chat message container with st.chat_message("assistant"): st.markdown(response) # Add assistant response to chat history st.session_state.messages.append({"role": "assistant", "content": response})