“AI Business Assistant (RAG-Powered)”
📁 Folder Structure
ai_business_assistant/
│
├── app.py # Streamlit main app
├── build_index.py # Creates the vector database
├── data/
│ └── business.txt # Your business knowledge base
├── faiss_index/ # Auto-created folder (after running build_index.py)
├── requirements.txt # Dependencies
└── README.md # (optional) Info about the project
📄 1. requirements.txt
langchain
openai
faiss-cpu
streamlit
pypdf
tiktoken
📘 2. data/business.txt
You can write or paste any business content here.
Example:
Artificial Intelligence (AI) is transforming business processes across industries.
Startups in 2025 are focusing on AI-driven marketing, customer personalization, and automation.
Digital transformation strategies now include machine learning-based analytics, predictive insights, and chatbots.
AI can help small businesses optimize their sales and reduce costs through smart automation.
You can later replace or add PDFs with business research reports.
⚙️ 3. build_index.py
This file prepares your vector database (FAISS).
from langchain.document_loaders import TextLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import FAISS
import os
os.environ["OPENAI_API_KEY"] = "your_openai_api_key_here"
loader = TextLoader("data/business.txt")
docs = loader.load()
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
chunks = splitter.split_documents(docs)
embeddings = OpenAIEmbeddings()
db = FAISS.from_documents(chunks, embeddings)
db.save_local("faiss_index")
print("✅ FAISS vector index built and saved successfully!")
Run this first (to create the FAISS index):
python build_index.py
💻 4. app.py
This is your Streamlit web app — the front-end interface.
import streamlit as st
from langchain.chains import RetrievalQA
from langchain.llms import OpenAI
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import FAISS
import os
os.environ["OPENAI_API_KEY"] = "your_openai_api_key_here"
embeddings = OpenAIEmbeddings()
db = FAISS.load_local("faiss_index", embeddings, allow_dangerous_deserialization=True)
retriever = db.as_retriever(search_kwargs={"k": 3})
llm = OpenAI(model_name="gpt-4-turbo", temperature=0.3)
qa = RetrievalQA.from_chain_type(llm=llm, retriever=retriever)
st.set_page_config(page_title="AI Business Assistant", page_icon="💼")
st.title("💼 AI Business Assistant")
st.markdown("Ask any question about business, startups, or AI trends!")
query = st.text_input("🔍 Enter your question here:")
if st.button("Ask"):
if query.strip():
with st.spinner("Thinking..."):
result = qa.run(query)
st.success(result)
else:
st.warning("Please enter a question.")
▶️ 5. Run Your App
pip install -r requirements.txt
python build_index.py
streamlit run app.py