# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Khoj AI Service
spec:
    description: |
        Khoj is an open source, personal AI, understands pdf, plaintext, markdown, org-mode files, and notion pages (Obsidian and more client).

        The deployment includes:
        - PostgreSQL database with pgvector extension for vector similarity search.
        - Terrarium sandbox for secure Python code execution.
        - SearxNG search engine for web search capabilities.
        - Khoj computer
        - khoj-ai
    coverImage: https://assets.khoj.dev/khoj-logo-sideways-1200x540.png
    icon: https://docs.khoj.dev/img/favicon-128x128.ico
    tags:
        - AI
        - Personal AI
        - Vector Search
        - Embedding
        - Second Brain
    readme: |
        Khoj is an open source, personal AI, understands pdf, plaintext, markdown, org-mode files, and notion pages (Obsidian and more client).

        ## Services

        - **database**: PostgreSQL with pgvector extension for storing vector embeddings.
        - **sandbox**: Simple, fast container image builder for Python applications.
        - **search**: SearxNG search engine for web search integration.
        - **computer**: Khoj computer.
        - **server**: Khoj main server connecting all components.

        ## Configuration

        Environment variables can be customized to configure database connection, admin email, admin password.

        ## Usage
        You can integrate Khoj with various LLM providers by setting the respective API keys in the environment variables. For example, you can set `OPENAI_API_KEY`, `GEMINI_API_KEY`, and `ANTHROPIC_API_KEY` to use OpenAI, Google Gemini, and Anthropic models respectively.

        After deployment, access the Khoj server on the exposed port. Use the admin credentials to log in and configure the platform.

        Integrate with your note taking system, such as Obsidian, to enhance your personal AI experience. for more detail visit the docs.

        ## Documentation

        For more information, visit the [Khoj documentation](https://docs.khoj.dev/).
    services:
        - name: postgres
          icon: https://www.gravatar.com/avatar/13f5f68d4c3448bdef716217cd0cd0cb?s=120&r=g&d=404
          template: PREBUILT
          spec:
            id: postgres
            source:
                image: bryanlin16899/postgres-vector-postgis:17.4
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/postgresql/data
            instructions:
                - title: Connection String
                  content: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}
                - title: PostgreSQL Connect Command (psql)
                  content: psql "postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}"
                - title: PostgreSQL username
                  content: ${POSTGRES_USERNAME}
                - title: PostgreSQL password
                  content: ${POSTGRES_PASSWORD}
                - title: PostgreSQL database
                  content: ${POSTGRES_DATABASE}
                - title: PostgreSQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: PostgreSQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                PGDATA:
                    default: /var/lib/postgresql/data/pgdata
                POSTGRES_CONNECTION_STRING:
                    default: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
                    expose: true
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: true
                POSTGRES_DB:
                    default: zeabur_db
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: ${POSTGRES_CONNECTION_STRING}
                    expose: true
                POSTGRES_USER:
                    default: zeabur_user
                POSTGRES_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
        - name: sandbox
          icon: https://docs.khoj.dev/img/favicon-128x128.ico
          template: PREBUILT
          spec:
            id: sandbox
            source:
                image: ghcr.io/khoj-ai/terrarium:latest
        - name: search
          icon: https://docs.khoj.dev/img/favicon-128x128.ico
          template: PREBUILT
          spec:
            id: search
            source:
                image: docker.io/searxng/searxng:latest
            volumes:
                - id: config
                  dir: /etc/searxng
            env:
                SEARXNG_BASE_URL:
                    default: http://localhost:8080/
                    expose: true
        - name: computer
          icon: https://docs.khoj.dev/img/favicon-128x128.ico
          template: PREBUILT
          spec:
            id: computer
            source:
                image: ghcr.io/khoj-ai/khoj-computer:latest
            ports:
                - id: vnc
                  port: 5900
                  type: TCP
            volumes:
                - id: home
                  dir: /home/operator
        - name: server
          icon: https://docs.khoj.dev/img/favicon-128x128.ico
          template: PREBUILT
          spec:
            id: server
            source:
                image: ghcr.io/khoj-ai/khoj:latest
            ports:
                - id: http
                  port: 42110
                  type: TCP
            volumes:
                - id: config
                  dir: /root/.khoj/
                - id: models-cache
                  dir: /root/.cache/torch/sentence_transformers
                - id: huggingface-cache
                  dir: /root/.cache/huggingface
            env:
                ANTHROPIC_API_KEY:
                    default: ${ANTHROPIC_API_KEY}
                    expose: true
                GEMINI_API_KEY:
                    default: ${GEMINI_API_KEY}
                    expose: true
                KHOJ_ADMIN_EMAIL:
                    default: ${KHOJ_ADMIN_EMAIL}
                    expose: true
                KHOJ_ADMIN_PASSWORD:
                    default: ${KHOJ_ADMIN_PASSWORD}
                    expose: true
                KHOJ_DEBUG:
                    default: "False"
                    expose: true
                KHOJ_DJANGO_SECRET_KEY:
                    default: secret
                    expose: true
                KHOJ_OPERATOR_ENABLED:
                    default: "False"
                    expose: true
                KHOJ_SEARXNG_URL:
                    default: http://search:8080
                    expose: true
                KHOJ_TERRARIUM_URL:
                    default: http://sandbox:8080
                    expose: true
                OPENAI_API_KEY:
                    default: ${OPENAI_API_KEY}
                    expose: true
                POSTGRES_DB:
                    default: postgres
                    expose: true
                POSTGRES_HOST:
                    default: database
                    expose: true
                POSTGRES_PASSWORD:
                    default: postgres
                    expose: true
                POSTGRES_PORT:
                    default: "5432"
                    expose: true
                POSTGRES_USER:
                    default: postgres
                    expose: true
localization:
    zh-CN:
        description: Khoj 是一个开源的个人 AI，支持理解 pdf、纯文本、markdown、org-mode 文件和 notion 页面（包括 Obsidian 等客户端）。
        readme: |
            Khoj 是一个开源的个人 AI，支持理解 pdf、纯文本、markdown、org-mode 文件和 notion 页面（包括 Obsidian 等客户端）。

            ## 服务

            - **database**：带有 pgvector 扩展的 PostgreSQL，用于存储向量嵌入。
            - **sandbox**：用于安全执行 Python 代码的 Terrarium 沙箱。
            - **search**：用于网络搜索集成的 SearxNG 搜索引擎。
            - **computer**：Khoj 计算服务。
            - **server**：连接所有组件的 Khoj 主服务器。

            ## 配置

            可以自定义环境变量以配置数据库连接、管理员邮箱、管理员密码以及各种 LLM 提供商的 API 密钥。

            ## 使用

            你可以通过设置环境变量中的相应 API 密钥，将 Khoj 集成到各种大型语言模型提供商。例如，设置 `OPENAI_API_KEY`、`GEMINI_API_KEY` 和 `ANTHROPIC_API_KEY`，分别使用 OpenAI、Google Gemini 和 Anthropic 的模型。

            部署后，通过暴露的端口访问 Khoj 服务器。使用管理员凭据登录并配置平台。

            将 Khoj 集成到你的笔记系统中，如 Obsidian，以增强你的个人 AI 体验。更多详情请访问文档。

            ## 文档

            更多信息，请访问 [Khoj 文档](https://docs.khoj.dev/)。
    zh-TW:
        description: Khoj 是一個開源的個人 AI，支援理解 pdf、純文字、markdown、org-mode 檔案和 notion 頁面（包括 Obsidian 等客戶端）。
        readme: |-
            Khoj 是一個開源的個人 AI，支援理解 pdf、純文字、markdown、org-mode 檔案和 notion 頁面（包括 Obsidian 等客戶端）。

            ## 服務

            - **database**：帶有 pgvector 擴充功能的 PostgreSQL，用於儲存向量嵌入。
            - **sandbox**：用於安全執行 Python 程式碼的 Terrarium 沙箱。
            - **search**：用於網路搜尋整合的 SearxNG 搜尋引擎。
            - **computer**：Khoj 計算服務。
            - **server**：連接所有組件的 Khoj 主伺服器。

            ## 設定

            可以自訂環境變數以設定資料庫連線、管理員電子郵件、管理員密碼以及各種大型語言模型提供商的 API 金鑰。

            ## 使用

            你可以透過設定環境變數中的相應 API 金鑰，將 Khoj 整合到各種大型語言模型提供商。例如，設定 `OPENAI_API_KEY`、`GEMINI_API_KEY` 和 `ANTHROPIC_API_KEY`，分別使用 OpenAI、Google Gemini 和 Anthropic 的模型。

            部署後，透過export的port或domain存取 Khoj 伺服器。使用管理員信箱與密碼登入並設定平台。

            將 Khoj 整合到你的筆記系統中，如 Obsidian，以增強你的個人 AI 體驗。更多詳情請訪問文件。

            ## 文件

            更多資訊，請參考 [Khoj 文件](https://docs.khoj.dev/)。
