Refact AI Agent Fact #1: Understanding the Knowledge Database
The Knowledge Database is a cornerstone of Refact Agent, enabling you to store and retrieve technical information efficiently based on semantic similarity. Here's an in-depth look at how it works, why it's valuable, and how to use it effectively.

What Is the Knowledge Database?
The Knowledge Database is an internal vector database within Refact Agent. It serves as a repository for storing, searching, and retrieving information based on meaning rather than exact words. Think of it as a dynamic, smart collection of technical knowledge.

How Knowledge Is Stored
When you use the create_knowledge() function, the following happens:

Processing & Conversion:

The input information is converted into vector embeddings—numerical representations of the text that capture its meaning.

Storage & Metadata:

The data is stored in the vector database along with metadata like:

Search key

Language/framework

Additional parameters you provide

Each entry is assigned a unique identifier (e.g., "🗃️2c8a2ae033").

Physical Storage:

If using the cloud-based version: Stored on Refact's servers.

If using a local installation: Stored within the Refact Agent's directory.
**
Why It's Valuable**
Semantic Search: Retrieve knowledge even when your query differs from the original wording by matching concepts.

Efficiency: Save time by accessing solutions and patterns for problems that have already been solved.

Scalability: The database grows over time, becoming a valuable repository of expertise for you and your team.

How Retrieval Works
When you use the knowledge() function with a search key:

Your query is converted into a vector embedding.

The system identifies the most similar entries in the database based on vector similarity.

It returns matches ranked by relevance, not just keyword matching.

How to Use the Knowledge Database

  1. Searching for Knowledge Use the knowledge() function to search for relevant solutions:

/knowledge Python relative import errors
This will retrieve the most relevant entries related to Python import issues.

  1. Creating Knowledge Entries After solving a problem, contribute to the database with the create_knowledge() function:

/create_knowledge
You'll need to provide:

Tools Used: Technologies involved (e.g., Python, PyQt5).

Applied To: Concepts or components the solution applies to (e.g., "taskforge, Python package structure").

Search Key: A descriptive phrase for semantic search (e.g., "Python import system errors").

Language/Framework: Programming language or framework used.

Knowledge Entry: Detailed explanation of the problem, solution, and implementation.

3. Viewing Existing Entries
To see the current knowledge entries:

/knowledge knowledge entries count
This returns a list of entries, each with a unique identifier for reference.

Best Practices for Knowledge Entries
Be Specific: Include examples, code snippets, and step-by-step instructions.

Explain Why: Document the reasoning behind your approach.

Provide Context: Mention the project, language, and framework for clarity.

Use Clear Structure: Organize with headings, lists, and code blocks.

Consider Edge Cases: Highlight limitations or alternative approaches.

Example Knowledge Entry Template
Problem Description: State the issue you tackled.

Root Cause: Explain why it happened.

Solution: Describe your fix.

Implementation: Share specific code/configurations.

Alternatives: Discuss other potential solutions.

Lessons Learned: Share insights or takeaways.

Getting Started
Here are some commands to try:

Search for knowledge:

/knowledge Python error handling
View all entries:

/knowledge knowledge entries count
Create a new entry:

/create_knowledge
By actively contributing to the Knowledge Database, you'll help it grow into a comprehensive resource for tackling technical challenges efficiently.