為 Cognee 建立 DEV.to 連接器:為 AI 智能體建立開發者知識庫
Building a DEV.to Connector for Cognee: Giving AI Agents a Developer Knowledge Base
Cognee 的開源 DEV.to 數據源連接器可將開發者教程、工程見解及技術文件匯入 AI 智能體的記憶圖譜。連接器支援按標籤或作者篩選文章,並提供文件模式及 DLT 數據源模式,讓 Cognee 建立知識圖譜並搜尋互相關聯的內容。
How we built an open-source DEV.to data-source connector for Cognee to ingest developer tutorials, engineering insights, and technical documentation into an AI agent's memory graph.
Building a DEV.to Connector for Cognee: Giving AI Agents a Developer Knowledge Base
AI coding assistants and autonomous developer agents are rapidly becoming everyday teammates for engineering teams. However, agents often suffer from stale context, shallow search, and fragmented recall when asked nuanced questions about real-world software practices.
As part of Mergetober, I built the DEV.to Data-Source Connector for Cognee
, the open-source memory engine for AI agents.
In this article, I will walk through why this integration is valuable, how Cognee’s graph-memory architecture works, how the connector is built, and how you can use it to build your own Developer Knowledge Base AI Agent.
- What is Cognee?
Traditional Retrieval-Augmented Generation (RAG) often flattens documents into isolated vector chunks. When an agent queries a RAG system, it retrieves disparate chunks but misses the relationships between tools, concepts, and authors.
Cognee
solves this by organizing information into a knowledge graph augmented with semantic vectors:
add(): Ingests raw text, codebases, or SaaS data feeds into a named dataset.
cognify(): Uses an LLM to extract entities, map conceptual connections, generate summaries, and build a unified graph memory.
search(): Queries the graph to retrieve interconnected answers that help agents reason with precision.
- Why Connect DEV.to to Cognee?
DEV.to
is one of the most vibrant technical communities on the web, hosting tens of thousands of practical tutorials, architecture comparisons, debugging guides, and deep-dives written by working developers.
By connecting DEV.to directly into Cognee's memory:
Engineering Teams can ingest articles about their chosen tech stacks (e.g. FastAPI, Kubernetes, LangChain) into a local AI assistant.
Coding Agents can recall up-to-date best practices, community tips, and common pitfalls directly inside their reasoning loop.
Developers can create personalized memory layers that index their own bookmarked or published reading lists.
- Architecture of the DEV.to Connector
The connector resides in cognee-community under packages/connector/devto:
text
cognee-community/
└── packages/
└── connector/
└── devto/
├── cognee_community_connector_devto/
│ ├── init.py
│ └── devto.py # Ingestion logic & DLT source
├── examples/
│ └── example.py # Complete runnable demo
├── tests/
│ └── test_devto.py # Pytest test suite with mocks
├── pyproject.toml # Poetry packaging
└── README.md # Setup and documentation
Key Technical Highlights:
Tag & Author Filtering: Developers can ingest articles filtered by tags (e.g., python, ai, beginners) or by author username.
Dual-Mode Ingestion:
Document Mode (fetch_devto_documents): Formats articles with author metadata, tags, reading time, and markdown bodies so that cognee.cognify() can build deep knowledge graphs.
DLT Source Mode (devto_source): Integrates seamlessly with Cognee’s underlying dlt (data load tool) pipelines via cognee.remember().
Resilience & Rate Limits: Gracefully supports public unauthenticated access and optional API key authentication (api-key).
Unit Tested: Fully tested using mocked HTTP endpoints to ensure bulletproof CI/CD runs.
- How It Works in Practice
Here is how simple it is to turn DEV.to articles into a queryable AI memory brain:
python
import asyncio
import os
import cognee
from cognee_community_connector_devto import fetch_devto_documents
os.environ["LLM_API_KEY"] = "your-api-key"
async def main():
# 1. Fetch the latest technical articles tagged with 'python'
print("Fetching DEV.to technical articles...")
documents = fetch_devto_documents(
tag="python",
per_page=5,
fetch_full_content=False,
)
# 2. Add into Cognee's dataset
print(f"Adding {len(documents)} articles into Cognee memory...")
await cognee.add(documents, dataset_name="devto_knowledge_base")
# 3. Cognify into an interconnected knowledge graph
print("Cognifying articles into graph memory...")
await cognee.cognify(datasets=["devto_knowledge_base"])
# 4. Search and reason over the memory
query = "What Python libraries and patterns were recommended in the community?"
results = await cognee.search(query, datasets=["devto_knowledge_base"])
print("\nAI Agent Answer:")
print(results)
if name == "main":
asyncio.run(main())
When Cognee runs cognify(), it doesn't just store the text—it creates nodes for the authors, the libraries mentioned, and the concepts discussed, connecting them in a graph!
- Real-World Use Cases
Company Brain for Developer Tools: An AI agent that stays up-to-date with tutorials and announcements from developer tooling teams.
Onboarding Assistant for Junior Devs: An internal chatbot grounded with curated DEV.to guides on clean code, Git workflows, and architecture patterns.
Personalized Research Companion: Ingesting your personal reading list so your local AI assistant remembers everything you read.
- Links & Resources
Pull Request: topoteretes/cognee-community#578
Cognee Community Repo: topoteretes/cognee-community
Mergetober Hackathon: WeMakeDevs Mergetober
來源:DEV Community · dev.to