# Knowledge Base

Source: https://docs.ops0.com/docs/iac/knowledge-base

The Knowledge Base lets you feed custom documentation into the IaC AI assistant. Add your internal runbooks, architecture docs, module READMEs, or any reference material — the AI will retrieve and cite relevant content when generating code or answering questions in the IaC editor chat.

---

## How It Works

### Add a source
Provide a URL or paste markdown content in **Settings → IaC → Knowledge Sources**.

### Ingestion
ops0 fetches and processes the content in the background. Status moves from **Pending → Indexing → Indexed**.

### Embedding
Content is split into chunks and stored as vector embeddings using OpenAI `text-embedding-3-small`.

### Retrieval
When you ask the AI assistant a question, relevant chunks are retrieved from your knowledge base and included in the AI's context automatically.

---

## Managing Knowledge Sources

Navigate to **Settings → IaC → Knowledge Sources** to manage your knowledge base.

### Adding a Source

### Click Add Source
Click the **+ Add Source** button.

### Choose content type
Select **URL** (fetch from a web page) or **Markdown** (paste content directly).

### Enter content
For URLs: enter the full URL (e.g. `https://docs.mycompany.com/platform/networking`).
For Markdown: paste your content into the text area.

### Add name and tags (optional)
Give the source a descriptive name and optional tags for organization.

### Save
Click **Save**. Ingestion begins immediately in the background.

### Source Status

| Status | Meaning |
|--------|---------|
| **Pending** | Queued for ingestion |
| **Indexing** | Currently fetching and embedding content |
| **Indexed** | Ready — the AI will use this source |
| **Failed** | Ingestion failed (check URL accessibility or content format) |
| **Disabled** | Source exists but is excluded from retrieval |

### Source Actions

| Action | Description |
|--------|-------------|
| **Edit** | Update name, tags, or scope |
| **Reindex** | Re-fetch and re-embed the source (use after content updates) |
| **Disable / Enable** | Toggle whether the source is used in retrieval |
| **Delete** | Remove source and all its embeddings |

---

## Source Types

### URL Sources

ops0 fetches the page at the provided URL and extracts the readable text content. Useful for:

- Internal wiki pages or Confluence docs
- Public provider documentation
- Architecture decision records
- Module READMEs hosted on GitHub or GitLab

**URL accessibility**

The URL must be publicly accessible or reachable from the ops0 backend. Password-protected pages and pages that require JavaScript rendering may not ingest correctly. Use the Markdown source type for those.

### Markdown Sources

Paste raw Markdown content directly. Useful for:

- Content behind authentication that can't be fetched by URL
- Internal standards docs copy-pasted from Confluence or Notion
- Runbooks or SOPs in Markdown format
- Custom module documentation

---

## Scoping Sources

Sources can be scoped to control which projects can use them:

| Scope | Behaviour |
|-------|-----------|
| **Organization** | Available to all projects in the org |
| **Project** | Available only to a specific IaC project |

Set scope when creating or editing a source.

---

## What the AI Does With Knowledge Sources

When you ask a question in the IaC editor chat, the assistant:

1. Converts your question to an embedding
2. Searches your indexed sources for semantically similar chunks
3. Injects the most relevant chunks into the AI prompt as context
4. Generates a response that references your documentation

This means questions like *"How should we configure our internal VPC module?"* or *"What's the company standard for tagging?"* can be answered using your own docs rather than generic provider documentation.

**Embeddings required**

Knowledge Base requires an OpenAI API key configured in **Settings → API Configuration**. Without it, sources can be saved but ingestion will fail.

---

## Reindexing Sources

If the source content has changed (e.g. you updated your wiki page), reindex the source to pick up the changes:

1. Navigate to **Settings → IaC → Knowledge Sources**
2. Find the source
3. Click **Reindex**

Reindexing re-fetches the URL or re-processes the markdown and rebuilds all embeddings for that source.

---

## Troubleshooting

### Source stuck in "Indexing"

The ingestion job may have timed out. Click **Reindex** to retry.

### Source shows "Failed"

Common causes:
- **URL not reachable** — check the URL is accessible from outside your network
- **No API key** — verify OpenAI API key is configured in Settings → API Configuration
- **Empty content** — the URL returned no readable text (e.g. a pure JavaScript SPA)

### AI not using my sources

- Confirm the source status is **Indexed** (not Pending, Failed, or Disabled)
- Check the source scope — a project-scoped source is only used within that specific project
- Rephrase your question to be more specific to the topic in your docs

---

## Related

- [Editor](https://docs.ops0.com/docs/iac/editor): AI-powered IaC editor where Knowledge Base context is applied

- [API Configuration](https://docs.ops0.com/docs/settings/api-configuration): Configure the OpenAI API key required for embeddings
