from transformers import pipeline import pandas as pd qa_pipeline = pipeline("question-answering", model='deepset/roberta-base-squad2') def chatbot(question): with open(r"ayurdata.txt", "r", encoding="utf-8") as file: context = file.read() answer = qa_pipeline(question=question, context=context) return answer def prints(questions): response = chatbot(questions) return response['answer'] import streamlit as st st.title("Ford AI Bot") if "messages" not in st.session_state: st.session_state.messages = [] st.session_state.messages.append({ 'role':'assistant', 'content':"Hi! I'm your AI Bot" }) for message in st.session_state.messages: with st.chat_message(message["role"]): st.markdown(message["content"]) prompt = st.chat_input("What is up?") if prompt: with st.chat_message("user"): st.markdown(prompt) st.session_state.messages.append({"role":"user","content":prompt}) response = f"ChatBot: {prints(prompt)}" with st.chat_message("assistant"): st.markdown(response) st.session_state.messages.append({"role":"assistant","content":response})