Skip to content

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

audit: fix documentation_qna_agent - add env comments, fix em dashes, replace print with logging

Tiioluwaniaa02e4a5e72d
diff --git a/ai_agents/documentation_qna_agent/.env.example b/ai_agents/documentation_qna_agent/.env.example
index de4da52..02830f5 100644
--- a/ai_agents/documentation_qna_agent/.env.example
+++ b/ai_agents/documentation_qna_agent/.env.example
@@ -1,4 +1,6 @@
+# Get your NVIDIA NIM API key at https://build.nvidia.com/
NVIDIA_API_KEY=your_nvidia_api_key_here
+# NVIDIA NIM model ID used for summarization and Q&A
NVIDIA_MODEL=deepseek-ai/deepseek-v4-flash
# Set to 1 if a documentation site blocks autonomous fetchers via robots.txt
# FETCH_IGNORE_ROBOTS=0
diff --git a/ai_agents/documentation_qna_agent/README.md b/ai_agents/documentation_qna_agent/README.md
index 15d72ef..b576111 100644
--- a/ai_agents/documentation_qna_agent/README.md
+++ b/ai_agents/documentation_qna_agent/README.md
@@ -98,7 +98,7 @@ Open the URL shown in the terminal (typically `http://localhost:8501`).
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
-| `NVIDIA_API_KEY` | Yes | — | API key from [build.nvidia.com](https://build.nvidia.com) (free, no credit card) |
+| `NVIDIA_API_KEY` | Yes | N/A | API key from [build.nvidia.com](https://build.nvidia.com) (free, no credit card) |
| `NVIDIA_MODEL` | No | `deepseek-ai/deepseek-v4-flash` | NVIDIA NIM model ID used for summarization and Q&A |
| `FETCH_IGNORE_ROBOTS` | No | `0` | Set to `1` to bypass robots.txt restrictions for autonomous fetching |
diff --git a/ai_agents/documentation_qna_agent/agent_service.py b/ai_agents/documentation_qna_agent/agent_service.py
index 24cef61..6195983 100644
--- a/ai_agents/documentation_qna_agent/agent_service.py
+++ b/ai_agents/documentation_qna_agent/agent_service.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import logging
import os
import re
import sys
@@ -15,9 +16,11 @@ from langchain_openai import ChatOpenAI
load_dotenv(override=True)
+logger = logging.getLogger(__name__)
+
NVIDIA_BASE_URL = "https://integrate.api.nvidia.com/v1"
MODEL_ID = os.getenv("NVIDIA_MODEL", "deepseek-ai/deepseek-v4-flash")
-print(f"Using NVIDIA model: {MODEL_ID}")
+logger.info("Using NVIDIA model: %s", MODEL_ID)
SYSTEM_PROMPT = """You are a Documentation QnA Agent. You help users understand documentation
using the fetched documentation content provided in the conversation.
@@ -26,7 +29,7 @@ When answering questions:
- Prefer the documentation content already provided in the conversation.
- Use the fetch tool only when you need additional pages or sections from the
same documentation site. Always pass the exact documentation URL given by the
- user — never invent or modify URLs.
+ user; never invent or modify URLs.
- For long pages, use start_index to read additional sections in chunks.
- Base your answers only on the fetched documentation content.
- If the information is not in the documentation, say so clearly.
diff --git a/ai_agents/documentation_qna_agent/app.py b/ai_agents/documentation_qna_agent/app.py
index a8fa6f3..ee54b0b 100644
--- a/ai_agents/documentation_qna_agent/app.py
+++ b/ai_agents/documentation_qna_agent/app.py
@@ -1,13 +1,16 @@
-"""Documentation QnA Agent — Streamlit chat UI."""
+"""Documentation QnA Agent - Streamlit chat UI."""
from __future__ import annotations
import asyncio
+import logging
from urllib.parse import urlparse
import streamlit as st
from dotenv import load_dotenv
+logging.basicConfig(level=logging.INFO, format="%(message)s")
+
from agent_service import answer_question, fetch_documentation
load_dotenv()