This directory contains minimal, reproducible examples to help new contributors and GSoC students understand how the KnowledgeSpace AI Agent works.
- Python: 3.11 or higher
- Google API Key: Required for Gemini LLM (get one free at Google AI Studio)
From the project root:
# Using UV (recommended)
uv sync
# Or using pip
pip install -r requirements.txtCreate a .env file in the project root (or set environment variables):
# Required: Your Google Gemini API key
GOOGLE_API_KEY=your_api_key_here
# Use standard Gemini API (not Vertex AI)
GEMINI_USE_VERTEX=falseNote: The examples require only
GOOGLE_API_KEYto run. Other environment variables (BigQuery, Vertex AI Vector Search) are optional and only needed for full production functionality.
# From the project root
cd examples
python basic_demo.pyThe script will:
- Initialize the NeuroscienceAssistant agent
- Send a sample query about neuroscience datasets
- Display:
- The final synthesized response produced by the agent
- (Optionally) selected intermediate signals for learning and debugging purposes
Example Output (illustrative):
============================================================
KnowledgeSpace Agent - Basic Demo
============================================================
Initializing the NeuroscienceAssistant...
✓ Agent initialized successfully
Sending query: "Find datasets about hippocampus neurons in mice"
Processing... (this may take a few seconds)
--- Agent Response ---
### 🔬 Neuroscience Datasets Found
#### 1. Mouse Hippocampus CA1 Recordings
- **Source:** DANDI Archive
- **Description:** Extracellular recordings from hippocampal neurons...
...
| File | Purpose |
|---|---|
README.md |
This setup guide |
basic_demo.py |
Minimal Python script demonstrating agent usage |
local_knowledge.json |
Sample mock dataset entries (for reference only) |
Note:
local_knowledge.jsonis provided as illustrative sample data for contributors; the current agent uses remote KnowledgeSpace APIs and does not directly load this file.
A simplified view of the agent's high-level workflow:
This diagram is a conceptual overview intended for learning and onboarding purposes.
User Query
↓
┌─────────────────────┐
│ 1. Extract Keywords │ ← Gemini extracts search terms
│ 2. Detect Intents │ ← Classify query type (data discovery, etc.)
└─────────────────────┘
↓
┌─────────────────────┐
│ 3. Execute Search │ ← Query KnowledgeSpace API + Vector DB
└─────────────────────┘
↓
┌─────────────────────┐
│ 4. Fuse Results │ ← Combine and rank results
└─────────────────────┘
↓
┌─────────────────────┐
│ 5. Synthesize │ ← Gemini generates natural language response
└─────────────────────┘
↓
Final Response
Make sure you've set the environment variable:
# Windows PowerShell
$env:GOOGLE_API_KEY = "your_key_here"
# Windows CMD
set GOOGLE_API_KEY=your_key_here
# Linux/macOS
export GOOGLE_API_KEY=your_key_hereMake sure you're running from the correct directory and dependencies are installed:
cd knowledge-space-agent
uv sync # or pip install -e .
cd examples
python basic_demo.pyIf you see rate limit errors, wait a few seconds and try again. The free Gemini API tier has request limits.
- Explore
backend/agents.pyto understand the full agent implementation - Check
backend/ks_search_tool.pyfor KnowledgeSpace API integration - Visit the hosted demo to see the full application