### Copy Environment Example File - Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Creates a new environment configuration file `.env` by copying the provided example `.env.example`. Users need to edit the newly created `.env` file to customize application settings for their local environment. ```bash cp .env.example .env ``` -------------------------------- ### Navigate to Project Frontend Directory - Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Changes the current working directory in the terminal. It moves into the `cognita/frontend` subdirectory, which is necessary before running other project-specific commands like installing dependencies or starting the server. ```bash cd cognita/frontend ``` -------------------------------- ### Install Frontend Project Dependencies - Yarn Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Executes the Yarn install command to download and set up all project dependencies specified in the `package.json` file. This command must be run from within the project's root directory (`cognita/frontend`). ```bash yarn install ``` -------------------------------- ### Building and Starting Cognita with Ollama, Infinity and Docker Compose (Shell) Source: https://github.com/truefoundry/cognita/blob/main/README.md Combines starting core services with the optional `ollama` and `infinity` profiles, while also ensuring that all relevant Docker images are rebuilt locally (`--build` flag) before starting the containers. Use this when local changes affect any of the services included. ```Shell docker-compose --env-file compose.env --profile ollama --profile infinity up --build ``` -------------------------------- ### Install Node.js 18 on Linux - Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Installs Node.js version 18 on Debian/Ubuntu-based Linux systems. It updates package lists, installs necessary properties, adds the NodeSource repository, and then installs Node.js using apt. Requires root privileges (`sudo`). ```bash sudo apt-get update sudo apt-get upgrade sudo apt-get install software-properties-common curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install nodejs ``` -------------------------------- ### Starting Cognita with Ollama and Infinity Server (Shell) Source: https://github.com/truefoundry/cognita/blob/main/README.md This command starts the core Cognita services along with optional services for local LLM serving (`ollama`) and embedding/reranking (`infinity-server`) by activating their respective Docker Compose profiles. It also uses environment variables from `compose.env`. ```Shell docker-compose --env-file compose.env --profile ollama --profile infinity up ``` -------------------------------- ### Install Yarn 1.22.19 Globally - npm Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Installs a specific version (1.22.19) of the Yarn package manager globally. This command uses npm, which must be installed as part of the Node.js installation. ```bash npm install -g yarn@1.22.19 ``` -------------------------------- ### Install Node.js 18 on macOS - Homebrew Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Installs Node.js version 18 on macOS using the Homebrew package manager. This command assumes Homebrew is already installed and configured on the system. ```bash brew install node@18 ``` -------------------------------- ### Sample Frontend Environment Configuration - .env Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Illustrates the structure and typical variables found in the frontend's `.env` configuration file. These variables control backend API URLs, feature toggles, path configurations, and file upload limits for the application. ```bash VITE_QA_FOUNDRY_URL=http://localhost:8000 VITE_DOCS_QA_DELETE_COLLECTIONS=true VITE_DOCS_QA_STANDALONE_PATH=/ VITE_DOCS_QA_ENABLE_REDIRECT=false VITE_DOCS_QA_MAX_UPLOAD_SIZE_MB=200 ``` -------------------------------- ### Run Frontend Development Server - Yarn Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Starts the local development server for the frontend application. This command enables features like hot-reloading and typically serves the application for local testing and development purposes at a specified port (e.g., http://localhost:5001). ```bash yarn dev ``` -------------------------------- ### Starting Core Cognita Services with Docker Compose (Shell) Source: https://github.com/truefoundry/cognita/blob/main/README.md Executes the default Docker Compose setup defined in `docker-compose.yml`. It utilizes environment variables from `compose.env` to bring up essential services like the metadata database, vector database, backend API, and frontend UI. ```Shell docker-compose --env-file compose.env up ``` -------------------------------- ### Build Frontend for Production - Yarn Bash Source: https://github.com/truefoundry/cognita/blob/main/frontend/README.md Executes the build process for the frontend application, preparing it for deployment to a production environment. This command compiles, optimizes, and packages the application's assets, typically creating a build directory with static files. ```bash yarn build:prod ``` -------------------------------- ### Building and Starting Core Cognita Services with Docker Compose (Shell) Source: https://github.com/truefoundry/cognita/blob/main/README.md This command is similar to the basic `up` command but includes the `--build` flag. This forces Docker Compose to rebuild the images for services defined in the compose file, which is necessary when local code changes or new requirements have been added. ```Shell docker-compose --env-file compose.env up --build ``` -------------------------------- ### Copying Model Config File (Shell) Source: https://github.com/truefoundry/cognita/blob/main/README.md This command copies the `models_config.sample.yaml` file to `models_config.yaml`. This creates the primary configuration file used by the Docker Compose setup, allowing users to customize model providers for the RAG system. ```Shell cp models_config.sample.yaml models_config.yaml ``` -------------------------------- ### Testing MarkdownParser Python Source: https://github.com/truefoundry/cognita/blob/main/README.md This Python snippet shows how to use the `MarkdownParser` to process a local markdown file. It instantiates the parser and calls the asynchronous `get_chunks` method using `asyncio.run` to obtain a list of document chunks generated from the file content, which is then printed. ```python import asyncio from backend.modules.parsers import MarkdownParser parser = MarkdownParser() chunks = asyncio.run( parser.get_chunks( filepath="sample-data/creditcards/diners-club-black.md", ) ) print(chunks) ``` -------------------------------- ### Testing LocalDirLoader Python Source: https://github.com/truefoundry/cognita/blob/main/README.md This Python snippet demonstrates how to instantiate and test the `LocalDirLoader` class, a built-in data loader for Cognita. It configures a `DataSource` object pointing to a local directory URI and uses the loader to load data points into a destination directory, finally printing the loaded data point objects. ```python from backend.modules.dataloaders import LocalDirLoader from backend.types import DataSource data_source = DataSource( type="local", uri="sample-data/creditcards", ) loader = LocalDirLoader() loaded_data_pts = loader.load_full_data( data_source=data_source, dest_dir="test/creditcards", ) for data_pt in loaded_data_pts: print(data_pt) ``` -------------------------------- ### Defining Custom Query Controller Python Source: https://github.com/truefoundry/cognita/blob/main/README.md These Python snippets illustrate how to define a custom query controller class within Cognita's API server framework. The `@query_controller` decorator is used to register the class and define its base route, while HTTP method decorators like `@post` are applied to class methods to expose them as specific API endpoints under the controller's base route. ```python from backend.server.decorator import query_controller @query_controller("/my-controller") class MyCustomController(): ... from backend.server.decorator import post @query_controller("/my-controller") class MyCustomController(): ... @post("/answer") def answer(query: str): # Write code to express your logic for answer # This API will be exposed as POST /my-controller/answer ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.