Skip to content

A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.

added Agentic RAG with Firecrawl + Qwen

Joel James796bc357d3d0
diff --git a/agentic_rag/README.md b/agentic_rag_with_o-3-mini_and_duckduckgo/README.md
similarity index 89%
rename from agentic_rag/README.md
rename to agentic_rag_with_o-3-mini_and_duckduckgo/README.md
index c1bee0b..342451e 100644
--- a/agentic_rag/README.md
+++ b/agentic_rag_with_o-3-mini_and_duckduckgo/README.md
@@ -1,4 +1,4 @@
-# PDF RAG Agent with Milvus, Agno and OpenAI
+# PDF RAG Agent using Milvus, Agno, OpenAI & DuckDuckGo
A Streamlit application demonstrating a Retrieval-Augmented Generation (RAG) workflow using OpenAI (`gpt-4o-mini`), Agno, Milvus, and DuckDuckGo for web search.
@@ -22,13 +22,16 @@ A Streamlit application demonstrating a Retrieval-Augmented Generation (RAG) wor
1. **Clone Repository & Navigate:**
```bash
git clone https://github.com/Sumanth077/awesome-ai-apps-and-agents.git
- cd awesome-ai-apps-and-agents/agentic_rag
+
+ cd awesome-ai-apps-and-agents/agentic_rag_with_o-3-mini_and_duckduckgo
```
2. **Environment & Dependencies:**
```bash
python3 -m venv venv
- source venv/bin/activate # Or . env\Scripts\activate on Windows
+
+ source venv/bin/activate # or venv\Scripts\activate on Windows
+
pip install -r requirements.txt
```
diff --git a/agentic_rag/app.py b/agentic_rag_with_o-3-mini_and_duckduckgo/app.py
similarity index 100%
rename from agentic_rag/app.py
rename to agentic_rag_with_o-3-mini_and_duckduckgo/app.py
diff --git a/agentic_rag/requirements.txt b/agentic_rag_with_o-3-mini_and_duckduckgo/requirements.txt
similarity index 100%
rename from agentic_rag/requirements.txt
rename to agentic_rag_with_o-3-mini_and_duckduckgo/requirements.txt
diff --git a/agentic_rag_with_qwen_and_firecrawl/README.md b/agentic_rag_with_qwen_and_firecrawl/README.md
new file mode 100644
index 0000000..6d1044f
--- /dev/null
+++ b/agentic_rag_with_qwen_and_firecrawl/README.md
@@ -0,0 +1,72 @@
+# PDF RAG Agent with Milvus, Agno, Qwen and FireCrawl
+
+A Streamlit application demonstrating a Retrieval-Augmented Generation (RAG) workflow using Qwen3:8b, Agno, Milvus, and FireCrawl for crawling through relevant websites.
+
+## Features
+
+- Upload PDFs & process PDF documents.
+- Generate BGE embeddings (`bge-small-en-v1.5`).
+- Uses Qwen model (via Ollama) for LLM responses.
+- Milvus vector store for semantic search.
+- Firecrawl API integration for structured and up-to-date web search.
+- Interactive Streamlit chat interface.
+
+## Prerequisites
+
+- Python 3.8+
+- FireCrawl API Key
+- Docker (for Milvus)
+- Running Milvus Instance
+
+## Setup
+
+1. **Clone Repository & Navigate:**
+ ```bash
+ git clone https://github.com/Sumanth077/awesome-ai-apps-and-agents.git
+
+ cd awesome-ai-apps-and-agents/agentic_rag_with_qwen_and_firecrawl
+ ```
+
+2. **Environment & Dependencies:**
+ ```bash
+ python3 -m venv venv
+
+ source venv/bin/activate # Or venv\Scripts\activate on Windows
+
+ pip install -r requirements.txt
+ ```
+
+3. **FireCrawl API Key:**
+ Set the `FIRECRAWL_API_KEY` environment variable or add it to your Streamlit secrets (`.streamlit/secrets.toml`).
+
+4. **Start Milvus:**
+ Follow the official Milvus guide to start a standalone instance using Docker:
+ [https://milvus.io/docs/install_standalone-docker.md](https://milvus.io/docs/install_standalone-docker.md)
+ *Ensure it's accessible (usually `http://localhost:19530`).*
+
+## Usage
+
+1. **Ensure Milvus is running.**
+2. **Run the app:**
+ ```bash
+ streamlit run app.py
+ ```
+3. Open the provided URL (e.g., `http://localhost:8501`).
+4. Upload a PDF, click "Process Document", and start chatting!
+
+## How it Works
+
+- PDF text is chunked and embedded using `bge-small-en-v1.5` from SentenceTransformers.
+- Embeddings are stored in Milvus for semantic retrieval.
+- User query triggers the Agno Agent:
+ - Searches Milvus vector store for relevant context.
+ - Falls back to Firecrawl for live web results if context is weak or missing.
+ - Uses the locally hosted Qwen model via Ollama to synthesize a final response.
+
+## Contributing
+
+Contributions, issues, and feature requests are welcome. Please feel free to submit a Pull Request or open an issue.
+
+## License
+
+This project is licensed under the MIT License. See the LICENSE file for details (if one exists).
\ No newline at end of file
diff --git a/agentic_rag_with_qwen_and_firecrawl/app.py b/agentic_rag_with_qwen_and_firecrawl/app.py
new file mode 100644
index 0000000..727374c
--- /dev/null
+++ b/agentic_rag_with_qwen_and_firecrawl/app.py
@@ -0,0 +1,195 @@
+import streamlit as st
+from agno.models.ollama import Ollama
+from agno.agent import Agent
+from agno.knowledge.pdf import PDFKnowledgeBase
+from agno.vectordb.milvus import Milvus
+from agno.tools.firecrawl import FirecrawlTools
+import os
+from dotenv import load_dotenv
+import base64
+from sentence_transformers import SentenceTransformer
+
+# Load embedder
+embedding_model = SentenceTransformer("BAAI/bge-small-en-v1.5")
+
+class CustomEmbedder:
+ def __init__(self):
+ self.model = SentenceTransformer("BAAI/bge-small-en-v1.5")
+ self.dimensions = 384 # Required by agno Milvus wrapper
+
+ def get_embedding(self, text: str) -> list[float]:
+ return self.model.encode([text])[0].tolist()
+
+ def embed(self, texts: list[str]) -> list[list[float]]:
+ return self.model.encode(texts, show_progress_bar=False).tolist()
+
+ def get_embedding_and_usage(self, texts: list[str]):
+ embeddings = self.embed(texts)
+ usage = {
+ "input_tokens": sum(len(t.split()) for t in texts),
+ "output_vectors": len(embeddings),
+ }
+ return embeddings, usage
+
+# Set Streamlit page config
+st.set_page_config(
+ page_title="PDF RAG Agent (Local R1)",
+ page_icon="πŸ“š",
+ layout="wide"
+)
+
+# Custom CSS styling
+st.markdown("""
+<style>
+.stApp { color: #FAFAFA; }
+.stSidebar > div:first-child {
+ background-image: linear-gradient(to bottom, #262936, #1e202a);
+}
+[data-testid="stChatMessage"] {
+ background-color: rgba(74, 74, 106, 0.4);
+ border-radius: 0.5rem;
+ padding: 1rem;
+ margin-bottom: 0.5rem;
+}
+[data-testid="stChatMessage"] p { color: inherit; }
+.pdf-preview-container {
+ border: 1px solid #4A4A6A;
+ border-radius: 0.5rem;
+ padding: 0.5rem;
+ background-color: #262936;
+ margin-bottom: 1rem;
+}
+</style>
+""", unsafe_allow_html=True)
+
+load_dotenv()
+
+firecrawl_api_key = os.getenv("FIRECRAWL_API_KEY")
+
+# Milvus Vector DB
+MILVUS_URI = os.getenv("MILVUS_URI", "http://localhost:19530")
+COLLECTION_NAME = "rag_documents_local"
+
+# Configure Milvus with the custom embedder
+vector_db = Milvus(
+ collection=COLLECTION_NAME,
+ uri=MILVUS_URI,
+ embedder=CustomEmbedder()
+)
+
+# Create Agent
+def get_rag_agent(knowledge_base: PDFKnowledgeBase, model_id="qwen3:8b", debug_mode=True):
+ model = Ollama(id=model_id)
+ instructions = [
+ "1. Knowledge Base Search:",
+ " - ALWAYS start by searching the knowledge base using search_knowledge_base tool",
+ " - Analyze ALL returned documents thoroughly before responding",
+ " - If multiple documents are returned, synthesize the information coherently",
+ "2. External Search:",
+ " - If knowledge base search yields insufficient results, use duckduckgo_search",
+ " - Focus on reputable sources and recent information",
+ " - Cross-reference information from multiple sources when possible",
+ "3. Citation Precision:",
+ " - Reference page numbers and section headers",
+ " - Distinguish between main content and appendices",
+ "4. Response Quality:",
+ " - Provide specific citations and sources for claims",
+ " - Structure responses with clear sections and bullet points when appropriate",
+ " - Include relevant quotes from source materials",
+ " - Avoid hedging phrases like 'based on my knowledge' or 'depending on the information'",
+ "5. Response Structure:",
+ " - Use markdown for formatting technical content",
+ " - Create bullet points for lists found in documents",
+ " - Preserve important formatting from original PDF",
+ "6. User Interaction:",
+ " - Ask for clarification if the query is ambiguous",
+ " - Break down complex questions into manageable parts",
+ " - Proactively suggest related topics or follow-up questions",
+ "7. Error Handling:",
+ " - If no relevant information is found, clearly state this",
+ " - Suggest alternative approaches or questions",
+ " - Be transparent about limitations in available information",
+ ]
+
+ return Agent(
+ model=model,
+ knowledge=knowledge_base,
+ description="You are a helpful Agent called 'Agentic RAG' assisting with questions about a PDF document.", # Updated description
+ instructions=instructions,
+ search_knowledge=True,
+ markdown=True,
+ tools=[FirecrawlTools(api_key=firecrawl_api_key, scrape=False, crawl=True)],
+ show_tool_calls=True,
+ add_datetime_to_instructions=False,
+ debug_mode=debug_mode,
+ )
+
+# PDF Viewer
+def display_pdf_preview(pdf_path):
+ try:
+ with open(pdf_path, "rb") as f:
+ base64_pdf = base64.b64encode(f.read()).decode("utf-8")
+ st.markdown(f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="100%" height="300px"></iframe>', unsafe_allow_html=True)
+ except Exception as e:
+ st.error(f"Error displaying PDF: {e}")
+
+# Session State Init
+for key in ["messages", "document_loaded", "agent", "knowledge_base"]:
+ if key not in st.session_state:
+ st.session_state[key] = [] if key == "messages" else None
+
+# Sidebar: Upload PDF
+with st.sidebar:
+ st.markdown("## Upload PDF")
+ uploaded_file = st.file_uploader("Choose a PDF", type=["pdf"])
+
+ if uploaded_file:
+ pdf_path = "temp_uploaded.pdf"
+ with open(pdf_path, "wb") as f:
+ f.write(uploaded_file.read())
+
+ display_pdf_preview(pdf_path)
+
+ if not st.session_state.document_loaded:
+ if st.button("Process Document"):
+ with st.spinner("Indexing document..."):
+ kb = PDFKnowledgeBase(path=pdf_path, vector_db=vector_db)
+
+ kb.load(recreate=True)
+ agent = get_rag_agent(kb)
+
+ st.session_state.knowledge_base = kb
+ st.session_state.agent = agent
+ st.session_state.document_loaded = True
+ st.session_state.messages = []
+ st.rerun()
+
+ else:
+ st.markdown("βœ… Document indexed!")
+
+# Main Chat Area
+st.markdown("# Chat with your PDF")
+if not st.session_state.document_loaded:
+ st.info("πŸ‘ˆ Upload and process a PDF to begin.")
+else:
+ for msg in st.session_state.messages:
+ with st.chat_message(msg["role"]):
+ st.markdown(msg["content"])
+
+ if prompt := st.chat_input("Ask something about your document..."):
+ st.session_state.messages.append({"role": "user", "content": prompt})
+ with st.chat_message("user"):
+ st.markdown(prompt)
+
+ with st.chat_message("assistant"):
+ msg_box = st.empty()
+ try:
+ response = st.session_state.agent.run(prompt)
+ content = response.content
+ msg_box.markdown(content)
+ except Exception as e:
+ content = f"Error: {e}"
+ st.error(content)
+
+ st.session_state.messages.append({"role": "assistant", "content": content})
+ st.rerun()
\ No newline at end of file
diff --git a/agentic_rag_with_qwen_and_firecrawl/requirements.txt b/agentic_rag_with_qwen_and_firecrawl/requirements.txt
new file mode 100644
index 0000000..71b00ba
--- /dev/null
+++ b/agentic_rag_with_qwen_and_firecrawl/requirements.txt
@@ -0,0 +1,94 @@
+agno==1.5.10
+aiohappyeyeballs==2.6.1
+aiohttp==3.12.12
+aiosignal==1.3.2
+altair==5.5.0
+annotated-types==0.7.0
+anyio==4.9.0
+async-timeout==5.0.1
+attrs==25.3.0
+blinker==1.9.0
+cachetools==5.5.2
+certifi==2025.4.26
+charset-normalizer==3.4.2
+click==8.2.1
+colorama==0.4.6
+docstring_parser==0.16
+exceptiongroup==1.3.0
+filelock==3.18.0
+firecrawl-py==2.8.0
+frozenlist==1.7.0
+fsspec==2025.5.1
+gitdb==4.0.12
+GitPython==3.1.44
+grpcio==1.67.1
+h11==0.16.0
+httpcore==1.0.9
+httpx==0.28.1
+huggingface-hub==0.32.4
+idna==3.10
+Jinja2==3.1.6
+joblib==1.5.1
+jsonschema==4.24.0
+jsonschema-specifications==2025.4.1
+markdown-it-py==3.0.0
+MarkupSafe==3.0.2
+mdurl==0.1.2
+mpmath==1.3.0
+multidict==6.4.4
+narwhals==1.42.0
+nest-asyncio==1.6.0
+networkx==3.4.2
+numpy==2.2.6
+ollama==0.5.1
+packaging==24.2
+pandas==2.3.0
+pillow==11.2.1
+propcache==0.3.2
+protobuf==6.31.1
+pyarrow==20.0.0
+pydantic==2.11.5
+pydantic-settings==2.9.1
+pydantic_core==2.33.2
+pydeck==0.9.1
+Pygments==2.19.1
+pymilvus==2.5.11
+pypdf==5.6.0
+python-dateutil==2.9.0.post0
+python-dotenv==1.1.0
+python-multipart==0.0.20
+pytz==2025.2
+PyYAML==6.0.2
+referencing==0.36.2
+regex==2024.11.6
+requests==2.32.4
+rich==14.0.0
+rpds-py==0.25.1
+safetensors==0.5.3
+scikit-learn==1.7.0
+scipy==1.15.3
+sentence-transformers==4.1.0
+shellingham==1.5.4
+six==1.17.0
+smmap==5.0.2
+sniffio==1.3.1
+streamlit==1.45.1
+sympy==1.14.0
+tenacity==9.1.2
+threadpoolctl==3.6.0
+tokenizers==0.21.1
+toml==0.10.2
+tomli==2.2.1
+torch==2.7.1
+tornado==6.5.1
+tqdm==4.67.1
+transformers==4.52.4
+typer==0.16.0
+typing-inspection==0.4.1
+typing_extensions==4.14.0
+tzdata==2025.2
+ujson==5.10.0
+urllib3==2.4.0
+watchdog==6.0.0
+websockets==15.0.1
+yarl==1.20.1