import streamlit as st from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.docstore.document import Document from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores.faiss import FAISS from langchain.llms import OpenAI from langchain.chains import RetrievalQA import os data = """ My name is Krishnasai Paleti, my friends call me Krishna. Im a masters student at Penn State University majoring in Computer Science and Engineering on track to graduate in May 2025. I specialize in Data Science, Machine Learning, Large Language models (LLMs) and Natural Language Processing(NLP). I believe in learning by doing and I work on personal projects whenever I get time. Outside acadamia, you can find me either cooking or playing badminton. My favorite cuisines are Italian and Indian. I love cooking with veggies and I try to add as many veggies as possible in the dishes I cook. Lets delve more into myself. My favorite color keeps changing based on my mood! I generally prefer darker shades of colors. My favorite movie is "The Intern" starring Robert De Niro and Anne Hathaway. I am the first generation of my family to study in the US. Fun fact: I always strive to improve, even in the smallest or least important tasks. This does drain me out at times, but my drive burns more brighter day by day! I am very detail-oriented, sometimes down to the first principles of the task I'm working on. I'm extremely loyal and expect the bare minimum of honesty from my close confidants. I am passionate about making a mark with my work. As a highly motivated individual, I am driven by my passion for continuous improvement and strive to implement the principle of KAIZEN in all aspects of my life. Penn State is my second masters degree. My first degree was an integrated masters (Bachelors and Masters in 5 years) from IIIT in Computer Science and Engineering with a Specialization in Systems Design. System Design never made me exclaim with joy as Data Science or ML did. I consider data science as a game to figure out the clues hidden in the data to solve the case. Hence I started working on Machine Learning from my third year, taking up internships whenever possible. This path eventually led to me pursuing my thesis on Large Language Models and Prompt based tuning. The caveat was that I started my thesis before ChatGPT was released and I witnessed the giant strides the world took in the field of LLMs. My thesis which focused on Prompt Based Finetuning in a Few Shot Setting aimed to reduce computation costs and training time. This approach is particularly effective in data scarce scenarios. """ # Step 2: Split the data into chunks text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=20) texts = text_splitter.split_text(data) documents = [Document(page_content=text) for text in texts] # Step 3: Create vector store using FAISS and OpenAI embeddings embeddings = OpenAIEmbeddings(openai_api_key=os.getenv("OPEN_API_KEY")) vectorstore = FAISS.from_documents(documents, embeddings) llm = OpenAI( openai_api_key=os.getenv("OPEN_API_KEY"), temperature=0.7 ) # between 0 to 1, more towards 1 is more creative answers. # Build the RAG chain (Retrieval + LLM) qa_chain = RetrievalQA.from_chain_type( llm=llm, chain_type="stuff", # Use "stuff" to limit LLM to only use retrieved context retriever=vectorstore.as_retriever(), return_source_documents=True, ) # Function to process query def process_query(query): # Run the RAG pipeline result = qa_chain(query) # Get the retrieved source documents source_documents = result["source_documents"] # If no relevant documents were retrieved, return "I don't know" if not source_documents: return "I'm sorry, I don't have information related to your query." # Otherwise, return the generated answer from the context return result["result"] st.title("Krishnasai Paleti's Landing Page [Prototype - This is my pet project that I work on when I have nothing else to do during my busy semester]") # Layout with picture on the top left and chatbot in the center col1, col2 = st.columns([1, 2]) with col1: st.image("https://huggingface.co/spaces/pk248/AboutMe/resolve/main/pookie_pic.jpg", use_column_width=True) with col2: st.header("Wanna Know about me?") query = st.text_input( "Enter your query:", placeholder="Ask a question about Krishna" ) if st.button("Get Answer"): if query: response = process_query(query) st.write(f"**Answer**: {response}") else: st.write("Please enter a query.") # Links Section st.header("Links") st.markdown( """
Download My Resume GitHub Profile LinkedIn Profile
""", unsafe_allow_html=True, )