### Install sentence-transformers and Start oobabooga Server Source: https://github.com/cinnamon/kotaemon/blob/main/docs/local_model.md Install the necessary Python package for embeddings and start the text-generation-webui OpenAI compatible server. Ensure you are in the text-generation-webui src directory. ```bash # install sentence-transformer for embeddings creation pip install sentence_transformers # change to text-generation-webui src dir python server.py --api ``` -------------------------------- ### Install Docling with Kotaemon Source: https://github.com/cinnamon/kotaemon/blob/main/docs/integrations/docling.md Install the necessary packages for Docling integration with Kotaemon. This command installs Kotaemon with the docling extra and ensures local development setup. ```bash uv pip install -e "libs/kotaemon[docling]" ``` -------------------------------- ### Install MS GraphRAG Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Install the GraphRAG library with a specific version and the 'future' package for non-Docker installations. ```shell pip install "graphrag<=0.3.6" future ``` -------------------------------- ### Start Kotaemon Web Server Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Command to start the Kotaemon web server after setting up the environment and configuration. The application will launch in the browser. ```shell python app.py ``` -------------------------------- ### Install Kotaemon Project Template Source: https://github.com/cinnamon/kotaemon/blob/main/templates/project-default/{{cookiecutter.project_name}}/README.md Commands to set up a new Python environment, clone the project repository, install the project locally, and generate the project structure using the Kotaemon CLI. ```bash # Create new conda env (optional) conda create -n {{ cookiecutter.project_name }} python=3.10 conda activate {{ cookiecutter.project_name }} # Clone and install the project git clone "<{{ cookiecutter.project_name }}-repo>" cd "<{{ cookiecutter.project_name }}-repo>" pip install -e . # Generate the project structure cd .. kh start-project ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/contributing.md Install pre-commit hooks to ensure code quality and consistency before committing changes. ```shell pre-commit install ``` -------------------------------- ### Install nano-GraphRAG Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Install the nano-GraphRAG library using pip. This may require resolving version conflicts. ```shell pip install nano-graphrag ``` ```shell pip uninstall hnswlib chroma-hnswlib && pip install chroma-hnswlib ``` -------------------------------- ### Install LightRAG Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Install the LightRAG library from its GitHub repository using pip. This may require resolving version conflicts. ```shell pip install git+https://github.com/HKUDS/LightRAG.git ``` ```shell pip uninstall hnswlib chroma-hnswlib && pip install chroma-hnswlib ``` -------------------------------- ### Setup Environment with uv Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Recommended method for setting up the Python environment using 'uv'. This command synchronizes dependencies for Python 3.10 and activates the virtual environment. ```shell uv sync --python 3.10 source .venv/bin/activate ``` -------------------------------- ### Install PaddlePaddle for CPU Source: https://github.com/cinnamon/kotaemon/blob/main/docs/integrations/paddle_ocr.md Installs the CPU version of PaddlePaddle. Ensure your system meets the requirements. ```bash uv pip install paddlepaddle==3.3.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ ``` -------------------------------- ### Install Kotaemon Package Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Install the Kotaemon package directly from its GitHub repository using pip. ```shell pip install kotaemon@git+ssh://git@github.com/Cinnamon/kotaemon.git ``` -------------------------------- ### Run llama-cpp-python OpenAI Server Source: https://github.com/cinnamon/kotaemon/blob/main/docs/local_model.md Start the llama-cpp-python server with a specified local GGUF model. Replace `` with the actual path to your model file. ```bash LOCAL_MODEL= python scripts/serve_local.py ``` -------------------------------- ### Install PaddlePaddle for GPU Source: https://github.com/cinnamon/kotaemon/blob/main/docs/integrations/paddle_ocr.md Installs the GPU version of PaddlePaddle. Requires a compatible GPU driver version. ```bash uv pip install paddlepaddle-gpu==3.3.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu130/ ``` -------------------------------- ### Install development dependencies Source: https://github.com/cinnamon/kotaemon/blob/main/CONTRIBUTING.md Install the necessary dependencies for development using pip. This command installs the Kotaemon library in editable mode with development extras. ```sh pip install -e "libs/kotaemon[dev]" ``` -------------------------------- ### Setup Environment with conda Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Alternative method for setting up the Python environment using 'conda'. It creates a new environment named 'kotaemon' with Python 3.10 and installs the project dependencies. ```shell conda create -n kotaemon python=3.10 conda activate kotaemon pip install -e "libs/kotaemon[all]" pip install -e "libs/ktem" ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Install the Kotaemon package in editable mode along with its development dependencies. ```shell pip install -e ".[dev]" ``` -------------------------------- ### Install PaddleOCR Doc Parser Extras Source: https://github.com/cinnamon/kotaemon/blob/main/docs/integrations/paddle_ocr.md Installs the PaddleOCR specific extras for the Kotaemon library. This command should be run from the root of the Kotaemon project. ```bash uv pip install -e "libs/kotaemon[paddleocr]" ``` -------------------------------- ### Install Dependencies with Conda Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/contributing.md Create and activate a conda environment with Python 3.10 and install project dependencies using pip. ```shell conda create -n kotaemon python=3.10 conda activate kotaemon # install dependencies cd libs/kotaemon pip install -e ".[all]" ``` -------------------------------- ### Pull Ollama Models Source: https://github.com/cinnamon/kotaemon/blob/main/docs/local_model.md Use these commands to download LLM and embedding models via Ollama. Ensure Ollama is installed and running. ```bash ollama pull llama3.1:8b ollama pull nomic-embed-text ``` -------------------------------- ### Activate Pre-installed Conda Environment Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/contributing.md Activate a pre-existing conda environment located at a specified installation directory. ```shell conda activate install_dir/env ``` -------------------------------- ### Conventional Commit Message Example Source: https://github.com/cinnamon/kotaemon/blob/main/CONTRIBUTING.md An example of a commit message following the Conventional Commits specification, used for documenting API changes. ```sh docs(api): update api doc ``` -------------------------------- ### Customize File Extractor in Indexing Pipeline Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/index/file.md Supply overriding file extractors based on file extension. Example shows mapping PDF and Excel files to specific readers. ```python FILE_INDEX_PIPELINE_FILE_EXTRACTORS = { ".pdf": "path.to.PDFReader", ".xlsx": "path.to.ExcelReader" } ``` -------------------------------- ### Set Text Segment Chunk Size in Indexing Pipeline Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/index/file.md Configure the expected number of characters for each text segment during indexing. Example sets chunk size to 1024 characters. ```python FILE_INDEX_PIPELINE_SPLITTER_CHUNK_SIZE = 1024 ``` -------------------------------- ### Set Text Segment Chunk Overlap in Indexing Pipeline Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/index/file.md Define the expected overlap in characters between consecutive text segments. Example sets overlap to 256 characters. ```python FILE_INDEX_PIPELINE_SPLITTER_CHUNK_OVERLAP = 256 ``` -------------------------------- ### Define User Settings and Info for Pipeline Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Implement 'get_user_settings' and 'get_info' class methods to allow user customization and provide pipeline metadata. 'get_user_settings' returns a dictionary defining configurable options, and 'get_info' returns essential pipeline identification details. ```python class SoSimple(BaseComponent): ... # as above @classmethod def get_user_settings(cls) -> dict: """The settings to the user""" return { "setting_1": { "name": "Human-friendly name", "value": "Default value", "choices": [("Human-friendly Choice 1", "choice1-id"), ("HFC 2", "choice2-id")], # optional "component": "Which Gradio UI component to render, can be: text, number, checkbox, dropdown, radio, checkboxgroup" }, "setting_2": { # follow the same rule as above } } @classmethod def get_info(cls) -> dict: """Pipeline information for bookkeeping purpose""" return { "id": "a unique id to differentiate this pipeline from other pipeline", "name": "Human-friendly name of the pipeline", "description": "Can be a short description of this pipeline" } ``` -------------------------------- ### Configure WSL Automount Options Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Add automount options to /etc/wsl.conf in WSL to enable all permissions for the user owner. ```shell [automount] options = "metadata,umask=022,fmask=011" ``` -------------------------------- ### Configure Document and Vector Stores Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Set your preferred document store and vector store. Full-text search and vector-based search capabilities can be configured here. ```python # setup your preferred document store (with full-text search capabilities) KH_DOCSTORE=(Elasticsearch | LanceDB | SimpleFileDocumentStore) # setup your preferred vectorstore (for vector-based search) KH_VECTORSTORE=(ChromaDB | LanceDB | InMemory | Milvus | Qdrant) ``` -------------------------------- ### Instantiate and Use a Kotaemon Component Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/create-a-component.md Instantiate a component by providing necessary parameters and nodes, then call the component instance with input data to execute its run method. ```python llm = LCAzureChatOpenAI(endpoint="some-endpont") extractor = RegexExtractor(pattern=["yes", "Yes"]) component = FancyPipeline( param1="Hello" param3=1.5 node1=llm, node2=llm, node3=extractor ) component("goodbye") ``` -------------------------------- ### Construct Pipeline Object with Settings Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Implement the 'get_pipeline' class method to instantiate the pipeline object using provided user settings. This method should return the fully configured pipeline instance. ```python class SoSimple(BaseComponent): ... # as above @classmethod def get_pipeline(self, setting): obj = cls(arg1=setting["reasoning.id.setting1"]) return obj ``` -------------------------------- ### Stream LLM Output to UI Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Implement streaming output by making the `run` function async and reporting output via `self.report_output`. The argument to `self.report_output` is a dictionary that can contain 'output' and/or 'evidence' keys for streaming to chat and information panels respectively. ```python async def run(self, question: str, history: list, **kwargs) -> Document: for char in "This is a long messages": self.report_output({"output": text.text}) ``` -------------------------------- ### Configure Ollama OpenAI Compatible Server Source: https://github.com/cinnamon/kotaemon/blob/main/docs/local_model.md Set these parameters in the Resources tab to connect to an Ollama server. Replace `localhost` with `host.docker.internal` if using Docker. ```yaml api_key: ollama base_url: http://localhost:11434/v1/ model: gemma2:2b (for llm) | nomic-embed-text (for embedding) ``` -------------------------------- ### Enable Local Models via .env Source: https://github.com/cinnamon/kotaemon/blob/main/libs/ktem/ktem/assets/md/usage.md Specify the full path to a local model file in the .env file to enable its use. ```shell LOCAL_MODEL= ``` -------------------------------- ### Configure llama-cpp-python Server Source: https://github.com/cinnamon/kotaemon/blob/main/docs/local_model.md Set these parameters in the Resources tab to connect to the llama-cpp-python server. The model name should match the loaded model. ```yaml api_key: dummy base_url: http://localhost:8000/v1/ model: model_name ``` -------------------------------- ### Run Kotaemon with Docker (Lite Version) Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Use this command to run the lite version of the Kotaemon Docker image, which has a smaller footprint and is suitable for most users. Change the image name to 'main-lite'. ```shell # change image name to docker run <...> ghcr.io/cinnamon/kotaemon:main-lite ``` -------------------------------- ### Run Kotaemon with Docker (Full Version) Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Use this command to run the full version of the Kotaemon Docker image, which includes extra packages for broader file type support. It maps local data and exposes the Gradio server port. ```shell docker run \ -e GRADIO_SERVER_NAME=0.0.0.0 \ -e GRADIO_SERVER_PORT=7860 \ -v ./ktem_app_data:/app/ktem_app_data \ -p 7860:7860 -it --rm \ ghcr.io/cinnamon/kotaemon:main-full ``` -------------------------------- ### Stage and commit changes Source: https://github.com/cinnamon/kotaemon/blob/main/CONTRIBUTING.md Add your modified files to the staging area and commit them with a clear, descriptive message. Then, push your changes to your forked repository. ```sh git add your_changes.py git commit -m "clear message described your changes." git push -u origin descriptive-name-for-your-changes ``` -------------------------------- ### Define Outputs for UI Display Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md Configure outputs to be displayed in the UI. Specify the UI component, the pipeline step, and the JSONPath to retrieve the information. ```yaml outputs: - component: step: item: - ... # similar to above ``` -------------------------------- ### Run all pre-commit checks Source: https://github.com/cinnamon/kotaemon/blob/main/CONTRIBUTING.md Execute all pre-commit hooks to check coding style across all files before committing. This ensures consistency with the project's coding standards. ```sh pre-commit run --all-files ``` -------------------------------- ### Configure oobabooga OpenAI Compatible Server Source: https://github.com/cinnamon/kotaemon/blob/main/docs/local_model.md Set these parameters in the Resources tab to connect to the oobabooga/text-generation-webui server. The model can be any loaded model. ```yaml api_key: dummy base_url: http://localhost:5000/v1/ model: any ``` -------------------------------- ### Register Pipelines in flowsettings.py Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Declare reasoning and indexing pipelines in flowsettings.py to make them discoverable by the application. KH_REASONING accepts a list of pipelines, while KH_INDEX accepts a single pipeline. ```python KH_REASONING = [""] KH_INDEX = "" ``` -------------------------------- ### Configure OpenAI API via .env Source: https://github.com/cinnamon/kotaemon/blob/main/libs/ktem/ktem/assets/md/usage.md Set environment variables to enable access to OpenAI's models. Default parameters are provided for most users. ```shell OPENAI_API_BASE=https://api.openai.com/v1 OPENAI_API_KEY= OPENAI_CHAT_MODEL=gpt-3.5-turbo OPENAI_EMBEDDINGS_MODEL=text-embedding-ada-002 ``` -------------------------------- ### Clone Kotaemon Repository Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/contributing.md Clone the Kotaemon repository and navigate into the project directory. ```shell git clone git@github.com:Cinnamon/kotaemon.git cd kotaemon ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Set up a new conda environment named 'kotaemon' with Python 3.10 and activate it. ```shell conda create -n kotaemon python=3.10 conda activate kotaemon ``` -------------------------------- ### Configure User Settings for LLM Selection Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Define user settings to allow selection of LLMs, such as for citation, using a dropdown component. This involves retrieving LLM options via `llms.options()` and setting the default value. ```python @classmethod def get_user_settings(cls) -> dict: from ktem.llms.manager import llms return { "citation_llm": { "name": "LLM for citation", "value": llms.get_default(), "component: "dropdown", "choices": list(llms.options().keys()), }, ... ``` -------------------------------- ### Access Application Database Models Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Import models such as `Source`, `Index`, `Conversation`, and `User` from `ktem.db.models` to access the user's application database. ```python # get the database that contains the source files from ktem.db.models import Source, Index, Conversation, User ``` -------------------------------- ### Run Prompt Engineering UI Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md Execute the prompt engineering UI by running the kotaemon command with a path to the configuration file. This command spins up the interactive UI. ```shell $ kotaemon promptui run ``` -------------------------------- ### Run Docker with Specific Platform (Linux ARM64) Source: https://github.com/cinnamon/kotaemon/blob/main/README.md This command demonstrates how to run the Kotaemon Docker container, specifically targeting the 'linux/arm64' platform, which is useful for newer Mac devices. It includes standard port and volume mappings. ```shell # To run docker with platform linux/arm64 docker run \ -e GRADIO_SERVER_NAME=0.0.0.0 \ -e GRADIO_SERVER_PORT=7860 \ -v ./ktem_app_data:/app/ktem_app_data \ -p 7860:7860 -it --rm \ --platform linux/arm64 \ ghcr.io/cinnamon/kotaemon:main-lite ``` -------------------------------- ### Declare User Settings Dictionary Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/settings/user-settings.md Define a dictionary of user settings with their names, default values, UI components, and optional choices. This structure is used by ktem to render settings in the UI. ```python settings = { "topk": { "name": "Top-k chunks", "value": 10, "component": "number", }, "lang": { "name": "Languages", "value": "en", "component": "dropdown", "choices": [("en", "English"), ("cn", "Chinese")], } } ``` -------------------------------- ### Configure Azure OpenAI API via .env Source: https://github.com/cinnamon/kotaemon/blob/main/libs/ktem/ktem/assets/md/usage.md Provide Azure endpoint and API key for OpenAI models hosted on Azure. Deployment names for chat and embedding models may be required. ```shell AZURE_OPENAI_ENDPOINT= AZURE_OPENAI_API_KEY= OPENAI_API_VERSION=2024-02-15-preview AZURE_OPENAI_CHAT_DEPLOYMENT=gpt-35-turbo AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT=text-embedding-ada-002 ``` -------------------------------- ### Enable Multimodal QA and Reasoning Pipelines Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Enable or disable multimodal QA and specify the reasoning pipelines to use. Supports various pipelines including simple QA, decomposed QA, and agent-based pipelines. ```python # Enable / disable multimodal QA KH_REASONINGS_USE_MULTIMODAL=True # Setup your new reasoning pipeline or modify existing one. KH_REASONINGS = [ "ktem.reasoning.simple.FullQAPipeline", "ktem.reasoning.simple.FullDecomposeQAPipeline", "ktem.reasoning.react.ReactAgentPipeline", "ktem.reasoning.rewoo.RewooAgentPipeline", ] ``` -------------------------------- ### Configure VLM Endpoint for Figure Captioning Source: https://github.com/cinnamon/kotaemon/blob/main/docs/integrations/docling.md Set the KH_VLM_ENDPOINT environment variable to enable Docling's figure captioning feature. If not set, figure captions will be skipped. ```bash KH_VLM_ENDPOINT=http://your-vlm-endpoint ``` -------------------------------- ### Run Tests with Pytest Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/contributing.md Execute the test suite using pytest to verify the project's functionality. ```shell pytest tests ``` -------------------------------- ### Input and Params Schema for UI Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md Defines the schema for the 'inputs' and 'params' sections within the UI configuration file. It specifies the UI component to use and optional parameters for each input variable. ```yaml inputs: : component: params: # this section is optional) value: : ... # similar to above params: : ... # similar to those in the inputs ``` -------------------------------- ### Prompt Engineering UI Config Schema Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md The exported configuration file for the prompt engineering UI follows this schema. It defines parameters, inputs, outputs, and logs for pipeline execution and UI display. ```yaml : params: ... (Detail param information to initiate a pipeline. This corresponds to the pipeline init parameters.) inputs: ... (Detail the input of the pipeline e.g. a text prompt. This corresponds to the params of `run(...)` method.) outputs: ... (Detail the output of the pipeline e.g. prediction, accuracy... This is the output information we wish to see in the UI.) logs: ... (Detail what information should show up in the log.) ``` -------------------------------- ### Run Kotaemon with Docker (Full Version with Ollama) Source: https://github.com/cinnamon/kotaemon/blob/main/README.md This command runs the full Docker image with bundled Ollama for local or private RAG capabilities. Ensure you change the image name to 'main-ollama'. ```shell # change image name to docker run <...> ghcr.io/cinnamon/kotaemon:main-ollama ``` -------------------------------- ### Configure Paddle Device Source: https://github.com/cinnamon/kotaemon/blob/main/docs/integrations/paddle_ocr.md Sets the PaddlePaddle execution device using an environment variable. This can be set to 'cpu' or a specific GPU like 'gpu:0'. ```bash PADDLE_DEVICE=gpu # cpu, gpu:0 ``` -------------------------------- ### Register Custom Indexing Pipeline Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/index/file.md Register your custom indexing pipeline by providing its Python path in flowsettings.py. ```python FILE_INDEX_PIPELINE = "" ``` -------------------------------- ### Configure Log Retrieval Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md Define logs by specifying sheet names and how to retrieve input and output information from pipeline steps. This is useful for inspecting data. ```yaml logs: : inputs: - name: step: variable: - ... outputs: - name: step: item: ``` -------------------------------- ### Export Pipeline to Config Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md Use this command to export a pipeline's configuration to a YAML file. This file can then be customized and used to run the prompt engineering UI. Ensure the module path and output file path are correctly specified. ```shell $ kotaemon promptui export --output ``` -------------------------------- ### Run unit tests Source: https://github.com/cinnamon/kotaemon/blob/main/CONTRIBUTING.md Execute the unit tests for the Kotaemon library. Ensure all tests pass after making changes to verify code correctness. ```sh pytest libs/kotaemon/tests/ ``` -------------------------------- ### Create a new Git branch Source: https://github.com/cinnamon/kotaemon/blob/main/CONTRIBUTING.md Use this command to create a new branch for your changes. Ensure the branch name is descriptive. ```sh git checkout -b descriptive-name-for-your-changes ``` -------------------------------- ### Supported UI Components Mapping Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md This dictionary maps string identifiers to their corresponding Gradio UI components. Use these identifiers in the configuration file to specify the type of input field for pipeline parameters. ```python COMPONENTS_CLASS = { "text": gr.components.Textbox, "checkbox": gr.components.CheckboxGroup, "dropdown": gr.components.Dropdown, "file": gr.components.File, "image": gr.components.Image, "number": gr.components.Number, "radio": gr.components.Radio, "slider": gr.components.Slider, } ``` -------------------------------- ### Define a Kotaemon Component Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/create-a-component.md Create a class that subclasses BaseComponent, declares init parameters and nodes with type annotations, and implements the run method for processing logic. ```python from kotaemon.base import BaseComponent from kotaemon.llms import LCAzureChatOpenAI from kotaemon.parsers import RegexExtractor class FancyPipeline(BaseComponent): param1: str = "This is param1" param2: int = 10 param3: float node1: BaseComponent # this is a node because of BaseComponent type annotation node2: LCAzureChatOpenAI # this is also a node because LCAzureChatOpenAI subclasses BaseComponent node3: RegexExtractor # this is also a node bceause RegexExtractor subclasses BaseComponent def run(self, some_text: str): prompt = (self.param1 + some_text) * int(self.param2 + self.param3) llm_pred = self.node2(prompt).text matches = self.node3(llm_pred) return matches ``` -------------------------------- ### Citation for Kotaemon Project Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Use this BibTeX entry to cite the Kotaemon project in academic work. Ensure the URL is current. ```BibTeX @misc{kotaemon2024, title = {Kotaemon - An open-source RAG-based tool for chatting with any content.}, author = {The Kotaemon Team}, year = {2024}, howpublished = {\url{https://github.com/Cinnamon/kotaemon}}, } ``` -------------------------------- ### Registering a Custom Retriever Pipeline Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/index/file.md Add the path to your custom retrieval pipeline class to this list in flowsettings.py to register it. ```python FILE_INDEXING_RETRIEVER_PIPELIENS = ["path.to.retrieval.pipelie"] ``` -------------------------------- ### Reasoning Pipeline Run Signature Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Defines the 'run' method signature for a reasoning pipeline. It accepts a user question and chat history. ```python def run(self, question: str, history: list, **kwargs) -> Document: """Answer the question Args: question: the user input history: the chat history [(user_msg1, bot_msg1), (user_msg2, bot_msg2)...] Returns: kotaemon.base.Document: the final answer """ ``` -------------------------------- ### Define a Simple Pipeline Class Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Subclass BaseComponent to define a new pipeline. Include declared arguments and the core logic within the 'run' method. ```python from kotaemon.base import BaseComponent class SoSimple(BaseComponent): arg1: int arg2: str def run(self, arg3: str): return self.arg1 * self.arg2 + arg3 ``` -------------------------------- ### Pull Models with Ollama Source: https://github.com/cinnamon/kotaemon/blob/main/README.md Download models using Ollama. Ensure you pull the desired chat and embedding models before configuring them in the application. ```shell ollama pull llama3.1:8b ollama pull nomic-embed-text ``` -------------------------------- ### Define CMD Aliases for WSL Git-Secret Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Set up command-line aliases in Windows CMD to easily invoke git-secret commands through WSL. ```bat @echo off :: Commands DOSKEY ls=dir /B $* DOSKEY ll=dir /a $* DOSKEY git-secret=wsl git-secret $* DOSKEY gs=wsl git-secret $* ``` -------------------------------- ### Access Default LLM and Embeddings Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Access the default LLM and embedding models provided by the application using the `llms` and `embeddings` managers. Ensure necessary imports from `ktem.embeddings.manager` and `ktem.llms.manager`. ```python from ktem.embeddings.manager import embeddings from ktem.llms.manager import llms llm = llms.get_default() embedding_model = embeddings.get_default() ``` -------------------------------- ### Indexing Pipeline Run Signature Source: https://github.com/cinnamon/kotaemon/blob/main/docs/pages/app/customize-flows.md Defines the 'run' method signature for an indexing pipeline. It accepts file paths and an optional reindex flag. ```python def run( self, file_paths: str | Path | list[str | Path], reindex: bool = False, **kwargs, ): """Index files to intermediate representation (e.g. vector, database...) Args: file_paths: the list of paths to files reindex: if True, files in `file_paths` that already exists in database should be reindex. """ ``` -------------------------------- ### Reveal Decrypted File Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Decrypt and reveal a secret file, saving the decrypted content to a file with the same name. ```shell git-secret reveal [filename] ``` -------------------------------- ### Ignore UI Parameters in Config Generation Source: https://github.com/cinnamon/kotaemon/blob/main/docs/development/utilities.md Annotate parameters with `ignore_ui=True` in your pipeline class to prevent them from being included in the exported configuration file. This allows developers to control which parameters are exposed to the UI. ```python class Pipeline(BaseComponent): param1: str = Param(default="hello") param2: str = Param(default="goodbye", ignore_ui=True) ``` -------------------------------- ### Decrypt Secret File Content Source: https://github.com/cinnamon/kotaemon/blob/main/libs/kotaemon/README.md Display the decrypted content of a secret file to standard output using git-secret. ```shell git-secret cat [filename] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.