<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: EzioDeviox</title>
    <description>The latest articles on Forem by EzioDeviox (@eziodeviox).</description>
    <link>https://forem.com/eziodeviox</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2359396%2F56fa128f-f8f0-4155-8677-1bbede7d0c2d.jpg</url>
      <title>Forem: EzioDeviox</title>
      <link>https://forem.com/eziodeviox</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/eziodeviox"/>
    <language>en</language>
    <item>
      <title>🌟 Let’s Grow Together on GitHub! Fork, Star, and Watch Each Other’s Repos 🚀</title>
      <dc:creator>EzioDeviox</dc:creator>
      <pubDate>Fri, 08 Nov 2024 22:10:40 +0000</pubDate>
      <link>https://forem.com/eziodeviox/lets-grow-together-on-github-fork-star-and-watch-each-others-repos-2c8n</link>
      <guid>https://forem.com/eziodeviox/lets-grow-together-on-github-fork-star-and-watch-each-others-repos-2c8n</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe1otmoq7xardm11vx3e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe1otmoq7xardm11vx3e.jpg" alt="Image description" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello Dev Community! 👋 Are you looking to expand your GitHub presence, connect with other devs, and show off your projects? Let’s support each other by &lt;strong&gt;forking&lt;/strong&gt;, &lt;strong&gt;starring&lt;/strong&gt;, and &lt;strong&gt;watching&lt;/strong&gt; each other’s repositories! Here’s the deal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fork, Star, and Watch&lt;/strong&gt; my repo 👉 &lt;a href="https://github.com/EzioDEVio/RAG-project" rel="noopener noreferrer"&gt;EzioDEVio/RAG-project&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leave a comment&lt;/strong&gt; with your repo link here or any note once you've done the above, and I’ll gladly do the same for your repo! 💖&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s dive into GitHub basics for anyone new to these features and make this campaign accessible for all! 🌱&lt;/p&gt;




&lt;h3&gt;
  
  
  👾 What is GitHub?
&lt;/h3&gt;

&lt;p&gt;GitHub is a &lt;strong&gt;platform for developers to collaborate, host, and share their projects&lt;/strong&gt;. It’s where you can store code, manage versioning, handle bug tracking, and even run CI/CD pipelines. But GitHub is also a social network for devs to connect, learn, and grow! Here’s a breakdown of key GitHub features to help you make the most of this platform.&lt;/p&gt;




&lt;h3&gt;
  
  
  🗃️ Key GitHub Concepts
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;Repositories (Repos)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;A &lt;strong&gt;repository&lt;/strong&gt; is like a digital workspace containing all the project files and version history. Repos keep track of every change, organize your project, and allow collaboration with others on open-source projects. Anything can live in a repo, from a simple script to a full-fledged application!&lt;/p&gt;

&lt;h4&gt;
  
  
  2. &lt;strong&gt;Forks 🍴&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;A &lt;strong&gt;fork&lt;/strong&gt; is your personal copy of someone else’s repo. Forking lets you freely experiment without affecting the original project. This is essential in open source: you can contribute to someone else’s project, suggest improvements, and submit pull requests to share your updates.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How to Fork a Repo&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;Go to the repo you want to fork.&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Fork&lt;/strong&gt; button at the top right corner.&lt;/li&gt;
&lt;li&gt;Now, you have a copy in your GitHub account! You can make changes, experiment, or contribute back to the original project.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. &lt;strong&gt;Stars ⭐&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;A &lt;strong&gt;star&lt;/strong&gt; shows appreciation for a project and makes it easier for you to revisit later. Think of it as a GitHub “like.” When you star a repo, you’re bookmarking it as a project of interest, which also gives the creator feedback and visibility.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How to Star a Repo&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Visit the repo you’re interested in.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Star&lt;/strong&gt; button at the top right.&lt;/li&gt;
&lt;li&gt;Voila! You’ve shown your support, and it’s easy to find in your starred repos later.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. &lt;strong&gt;Watchers 👀&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;When you &lt;strong&gt;watch&lt;/strong&gt; a repo, you receive notifications for updates—like new issues, pull requests, or releases. It’s perfect for staying informed about projects you’re invested in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How to Watch a Repo&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Go to the repo page.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Watch&lt;/strong&gt; button at the top right.&lt;/li&gt;
&lt;li&gt;Select the notification level you want (all activity or just releases).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  🌈 Contribution is Key
&lt;/h3&gt;

&lt;p&gt;If you’ve forked a repo and made updates, you can share those changes with the original project through a &lt;strong&gt;pull request&lt;/strong&gt;. Pull requests (PRs) are the heart of GitHub collaboration, allowing developers to contribute to projects they love.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Make changes&lt;/strong&gt; to your forked repo.&lt;/li&gt;
&lt;li&gt;Open a &lt;strong&gt;pull request&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Go to the original repository.&lt;/li&gt;
&lt;li&gt;Navigate to the &lt;strong&gt;Pull Requests&lt;/strong&gt; tab and start a new pull request.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Write a brief summary of your updates, submit it, and if accepted, your contribution will be part of the main project!&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  ⭐ Why Forks, Stars, and Contributions Matter
&lt;/h3&gt;

&lt;p&gt;Starring and forking a repo, along with making contributions, helps build a &lt;strong&gt;strong GitHub profile&lt;/strong&gt;. It demonstrates involvement in the dev community and your interests and skills, which can lead to collaborations and new opportunities.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔥 Join the Campaign and Let’s Grow Together!
&lt;/h3&gt;

&lt;p&gt;To participate in this campaign:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fork, Star, and Watch&lt;/strong&gt; my repo: &lt;a href="https://github.com/EzioDEVio/RAG-project" rel="noopener noreferrer"&gt;EzioDEVio/RAG-project&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leave a comment&lt;/strong&gt; here with your repo link or a quick note once you’ve done the above steps, and I’ll gladly return the support by forking, starring, and watching your repo!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s boost our GitHub profiles and build connections. Don’t forget to comment so we can keep this momentum going and help each other grow! 🚀&lt;/p&gt;

&lt;p&gt;🔗 Connect with Me&lt;br&gt;
Let’s stay connected! You can find me on these platforms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;X (Twitter): @KhalidIQ2021&lt;/li&gt;
&lt;li&gt;DEV Community: dev.to/eziodeviox&lt;/li&gt;
&lt;li&gt;Kaggle: kaggle.com/eziodevio&lt;/li&gt;
&lt;li&gt;Hugging Face: huggingface.co/EzioDevio
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Building a Document Retrieval &amp; Q&amp;A System with OpenAI and Streamlit</title>
      <dc:creator>EzioDeviox</dc:creator>
      <pubDate>Wed, 06 Nov 2024 03:33:47 +0000</pubDate>
      <link>https://forem.com/eziodeviox/building-a-document-retrieval-qa-system-with-openai-and-streamlit-3mo8</link>
      <guid>https://forem.com/eziodeviox/building-a-document-retrieval-qa-system-with-openai-and-streamlit-3mo8</guid>
      <description>&lt;p&gt;Hello, Dev Community! 🌐&lt;/p&gt;

&lt;p&gt;Today, I’m excited to walk you through my project: EzioDevIo RAG (Retrieval-Augmented Generation). This system allows users to upload PDF documents, ask questions based on their content, and receive real-time answers generated by OpenAI's GPT-3.5 Turbo model. This is particularly useful for navigating large documents or quickly extracting relevant information. 🎓📄&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmahd0oz6z4zslu3vxide.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmahd0oz6z4zslu3vxide.jpg" alt="Image description" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the complete code on my GitHub: EzioDevIo RAG Project. Let’s dive into the project and break down each step!&lt;/p&gt;

&lt;p&gt;🚀 Dive into the full codebase and setup instructions in the &lt;a href="https://github.com/EzioDEVio/RAG-project" rel="noopener noreferrer"&gt;EzioDevIo RAG Project GitHub Repository&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Overview&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What You’ll Learn&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to integrate OpenAI’s language models with PDF document retrieval.&lt;/li&gt;
&lt;li&gt;How to create a user-friendly interface using Streamlit.&lt;/li&gt;
&lt;li&gt;How to containerize the application with Docker for easy deployment.
Project Features&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Upload PDFs and get information from them.&lt;/li&gt;
&lt;li&gt;Ask questions based on the content of the uploaded PDFs.&lt;/li&gt;
&lt;li&gt;Real-time responses generated by OpenAI’s gpt-3.5-turbo model.&lt;/li&gt;
&lt;li&gt;Easy deployment with Docker for scalability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;Here’s the final structure of our project directory: *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAG-project/
├── .env                       # Environment variables (API key)
├── app.py                     # Streamlit app for the RAG system
├── document_loader.py         # Code for loading and processing PDF documents
├── retriever.py               # Code for indexing and retrieving documents
├── main.py                    # Main script for RAG pipeline
├── requirements.txt           # List of required libraries
├── Dockerfile                 # Dockerfile for containerizing the app
├── .gitignore                 # Ignore sensitive and unnecessary files
├── data/
│   └── uploaded_pdfs/         # Folder to store uploaded PDFs
└── images/
    └── openai_api_setup.png   # Example image for OpenAI API setup instructions

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 1: Setting Up the Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.8+: To run the application locally.&lt;/li&gt;
&lt;li&gt;OpenAI API Key: You’ll need this to access OpenAI’s models. Sign up at OpenAI API to get your key.&lt;/li&gt;
&lt;li&gt;Docker: Optional, but recommended for containerizing the application for deployment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Clone the Repository and Set Up the Virtual Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.1. Clone the Repository&lt;/strong&gt;&lt;br&gt;
Start by cloning the project repository from GitHub and navigating into the project directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/EzioDEVio/RAG-project.git
cd RAG-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.2. Set Up a Virtual Environment&lt;/strong&gt;&lt;br&gt;
To isolate project dependencies, create and activate a virtual environment. This helps prevent conflicts with other projects’ packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv venv
source venv/bin/activate  # On Windows, use `venv\Scripts\activate`

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.3. Install Dependencies&lt;/strong&gt;&lt;br&gt;
Install the required Python libraries listed in requirements.txt. This includes OpenAI for the language model, Streamlit for the UI, PyMuPDF for PDF handling, and FAISS for efficient similarity search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.4. Configure Your OpenAI API Key&lt;/strong&gt;&lt;br&gt;
Create a .env file in the project root directory. This file will store your OpenAI API key securely. Add the following line to the file, replacing your_openai_api_key_here with your actual API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OPENAI_API_KEY=your_openai_api_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Tip: Make sure .env is added to your .gitignore file to avoid exposing your API key if you push your project to a public repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Understanding the Project Structure&lt;/strong&gt;&lt;br&gt;
Here’s a quick overview of the directory structure to help you navigate the code:&lt;br&gt;
Here’s a quick overview of the directory structure to help you navigate the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAG-project/
├── .env                       # Environment variables (API key)
├── app.py                     # Streamlit app for the RAG system
├── document_loader.py         # Code for loading and processing PDF documents
├── retriever.py               # Code for indexing and retrieving documents
├── main.py                    # Main script for RAG pipeline
├── requirements.txt           # List of required libraries
├── Dockerfile                 # Dockerfile for containerizing the app
├── .gitignore                 # Ignore sensitive and unnecessary files
├── data/
│   └── uploaded_pdfs/         # Folder to store uploaded PDFs
└── images/
    └── openai_api_setup.png   # Example image for OpenAI API setup instructions

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each file has a specific role:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;app.py: Manages the Streamlit interface, allowing users to upload files and ask questions.&lt;/li&gt;
&lt;li&gt;document_loader.py: Handles loading and processing of PDFs using PyMuPDF.&lt;/li&gt;
&lt;li&gt;retriever.py: Uses FAISS to index document text and retrieve relevant sections based on user queries.&lt;/li&gt;
&lt;li&gt;main.py: Ties everything together, including calling OpenAI’s API to generate responses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Building the Core Code&lt;/strong&gt;&lt;br&gt;
Now, let’s dive into the main components of the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.1. Loading Documents (document_loader.py)&lt;/strong&gt;&lt;br&gt;
The document_loader.py file is responsible for extracting text from PDFs. Here, we use the PyMuPDF library to process each page in the PDF and store the text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import fitz  # PyMuPDF
import os

def load_documents_from_folder(folder_path):
    documents = []
    for filename in os.listdir(folder_path):
        if filename.endswith(".pdf"):
            with fitz.open(os.path.join(folder_path, filename)) as pdf:
                text = "".join(page.get_text() for page in pdf)
            documents.append({"text": text, "filename": filename})
    return documents

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: This function reads all PDF files in a specified folder, extracts the text from each page, and adds the text to a list of dictionaries. Each dictionary represents a document with its text and filename.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.2. Document Indexing and Retrieval (retriever.py)&lt;/strong&gt;&lt;br&gt;
FAISS (Facebook AI Similarity Search) helps us to perform similarity searches. We use it to create an index of the document embeddings, which allows us to retrieve relevant sections when users ask questions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores.faiss import FAISS

def create_index(documents):
    embeddings = OpenAIEmbeddings()
    texts = [doc["text"] for doc in documents]
    metadata = [{"filename": doc["filename"]} for doc in documents]
    return FAISS.from_texts(texts, embeddings, metadata=metadata)

def retrieve_documents(index, query):
    return index.similarity_search(query)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;create_index: Converts document text into embeddings using OpenAIEmbeddings and creates an index with FAISS.&lt;br&gt;
retrieve_documents: Searches for relevant document sections based on the user query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.3. Generating Responses (main.py)&lt;/strong&gt;&lt;br&gt;
This module processes user queries, retrieves relevant documents, and generates answers using OpenAI’s language model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import openai
import os
from dotenv import load_dotenv
from document_loader import load_documents_from_folder
from retriever import create_index, retrieve_documents

load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")

def generate_response(query, retrieved_docs):
    context = "\n\n".join([doc["text"][:1000] for doc in retrieved_docs])
    messages = [
        {"role": "system", "content": "You are a helpful assistant..."},
        {"role": "user", "content": f"Context: {context}\n\nQuestion: {query}"}
    ]
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=messages,
        max_tokens=150,
        temperature=0.3,
    )
    return response.choices[0].message['content'].strip()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;generate_response: Creates a prompt with context from retrieved documents and the user’s query, then sends it to OpenAI’s API. The response is then returned as the answer.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Creating the Streamlit Interface (app.py)&lt;/strong&gt;&lt;br&gt;
Streamlit provides an interactive front end, making it easy for users to upload files and ask questions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from document_loader import load_documents_from_folder
from retriever import create_index, retrieve_documents
from main import generate_response

st.title("EzioDevIo RAG")
st.write("Upload a PDF, then ask questions based on its content. Get responses in real-time!")

uploaded_files = st.file_uploader("Upload PDF(s)", type="pdf", accept_multiple_files=True)
if uploaded_files:
    documents = [{"text": file.read().decode("utf-8"), "filename": file.name} for file in uploaded_files]
    index = create_index(documents)
    st.success("Files uploaded successfully!")

query = st.text_input("Enter your question here:")
if st.button("Get Answer"):
    if query:
        retrieved_docs = retrieve_documents(index, query)
        answer = generate_response(query, retrieved_docs)
        st.write("**Answer:**")
        st.write(answer)
    else:
        st.warning("Please enter a question.")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This code creates a simple UI with Streamlit, allowing users to upload PDFs and type questions.&lt;/li&gt;
&lt;li&gt;When users click "Get Answer," the app retrieves relevant documents and generates an answer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Dockerizing the Application&lt;/strong&gt;&lt;br&gt;
Docker allows you to package the app into a container, making it easy to deploy.&lt;/p&gt;

&lt;p&gt;Dockerfile&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Dependency Installation Stage
FROM python:3.8-slim as builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Final Stage
FROM python:3.8-slim
RUN useradd -m nonrootuser
USER nonrootuser
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.enableCORS=false"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We use a multi-stage build to keep the final image lean.&lt;br&gt;
The application runs as a non-root user for security.&lt;/p&gt;

&lt;p&gt;Running the Docker Container&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build the Docker Image:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t ezio_rag_app .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Run the Container:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 8501:8501 --env-file .env ezio_rag_app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 7: Setting Up CI/CD with GitHub Actions&lt;/strong&gt;&lt;br&gt;
For production readiness, add a CI/CD pipeline to build, test, and scan Docker images. You can find the .github/workflows file in the repository for this setup.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;br&gt;
This project combines OpenAI’s language model capabilities with document retrieval to create a functional and interactive tool. If you enjoyed this project, please star the GitHub repository and follow me here on Dev Community. Let’s build more amazing projects together! 🚀&lt;/p&gt;

&lt;p&gt;👉 View the GitHub Repository 🚀 &lt;a href="https://github.com/EzioDEVio/RAG-project" rel="noopener noreferrer"&gt;EzioDevIo RAG Project GitHub Repository&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>rag</category>
      <category>streamlit</category>
      <category>openai</category>
      <category>python</category>
    </item>
  </channel>
</rss>
