[
  {
    "path": ".gitattributes",
    "content": "* text=auto\n*.sh      eol=lf\n*.yml     text"
  },
  {
    "path": ".github/workflows/on-push.yml",
    "content": "name: Build Docker images on master push\n\non:\n  push:\n    tags:\n      - \"*\"\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        service:\n          - api\n          - ui\n    env:\n      SERVICE_DIR: ./${{ matrix.service }}\n      IMAGE_NAME: ghcr.io/${{ github.repository }}-${{ matrix.service }}\n    steps:\n      - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3\n      - run: docker login --username \"${{ github.actor }}\" --password ${{ secrets.GITHUB_TOKEN }} ghcr.io\n      - run: docker buildx create --use\n      - run: docker buildx build --platform linux/amd64,linux/arm64 -f ${SERVICE_DIR}/Dockerfile --tag $IMAGE_NAME:${{ github.ref_name }} --push ${SERVICE_DIR}\n      - run: docker buildx build --platform linux/amd64,linux/arm64 -f ${SERVICE_DIR}/Dockerfile --tag $IMAGE_NAME:latest --push ${SERVICE_DIR}\n"
  },
  {
    "path": ".gitignore",
    "content": "**/.DS_Store\nmodels/*.bin\nmodels/*.gguf\n**/.todo"
  },
  {
    "path": "LICENSE.md",
    "content": "MIT License\n\nCopyright (c) 2023 Umbrel, Inc.\nCopyright (c) 2023 Mckay Wrigley\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n  <a href=\"https://apps.umbrel.com/app/llama-gpt\">\n    <img width=\"150\" height=\"150\" src=\"https://i.imgur.com/LI59cui.png\" alt=\"LlamaGPT\" width=\"200\" />\n  </a>\n</p>\n<p align=\"center\">\n  <h1 align=\"center\">LlamaGPT</h1>\n  <p align=\"center\">\n    A self-hosted, offline, ChatGPT-like chatbot, powered by Llama 2. 100% private, with no data leaving your device.\n    <br/>\n    <strong>New: Support for Code Llama models and Nvidia GPUs.</strong>\n    <br />\n    <br />\n    <a href=\"https://umbrel.com\"><strong>umbrel.com (we're hiring) »</strong></a>\n    <br />\n    <br />\n    <a href=\"https://twitter.com/umbrel\">\n      <img src=\"https://img.shields.io/twitter/follow/umbrel?style=social\" />\n    </a>\n    <a href=\"https://t.me/getumbrel\">\n      <img src=\"https://img.shields.io/badge/community-chat-%235351FB\">\n    </a>\n    <a href=\"https://reddit.com/r/getumbrel\">\n      <img src=\"https://img.shields.io/reddit/subreddit-subscribers/getumbrel?style=social\">\n    </a>\n    <a href=\"https://community.umbrel.com\">\n      <img src=\"https://img.shields.io/badge/community-forum-%235351FB\">\n    </a>\n  </p>\n</p>\n<p align=\"center\">\n  <a href=\"https://umbrel.com/#start\">\n    <img src=\"https://i.imgur.com/sj5vqEG.jpg\" width=\"100%\" />\n  </a>\n</p>\n\n## Contents\n\n1. [Demo](#demo)\n2. [Supported Models](#supported-models)\n3. [How to install](#how-to-install)\n   - [On umbrelOS home server](#install-llamagpt-on-your-umbrelos-home-server)\n   - [On M1/M2 Mac](#install-llamagpt-on-m1m2-mac)\n   - [Anywhere else with Docker](#install-llamagpt-anywhere-else-with-docker)\n   - [Kubernetes](#install-llamagpt-with-kubernetes)\n4. [OpenAI-compatible API](#openai-compatible-api)\n5. [Benchmarks](#benchmarks)\n6. [Roadmap and contributing](#roadmap-and-contributing)\n7. [Acknowledgements](#acknowledgements)\n\n## Demo\n\nhttps://github.com/getumbrel/llama-gpt/assets/10330103/5d1a76b8-ed03-4a51-90bd-12ebfaf1e6cd\n\n## Supported models\n\nCurrently, LlamaGPT supports the following models. Support for running custom models is on the roadmap.\n\n| Model name                               | Model size | Model download size | Memory required |\n| ---------------------------------------- | ---------- | ------------------- | --------------- |\n| Nous Hermes Llama 2 7B Chat (GGML q4_0)  | 7B         | 3.79GB              | 6.29GB          |\n| Nous Hermes Llama 2 13B Chat (GGML q4_0) | 13B        | 7.32GB              | 9.82GB          |\n| Nous Hermes Llama 2 70B Chat (GGML q4_0) | 70B        | 38.87GB             | 41.37GB         |\n| Code Llama 7B Chat (GGUF Q4_K_M)         | 7B         | 4.24GB              | 6.74GB          |\n| Code Llama 13B Chat (GGUF Q4_K_M)        | 13B        | 8.06GB              | 10.56GB         |\n| Phind Code Llama 34B Chat (GGUF Q4_K_M)  | 34B        | 20.22GB             | 22.72GB         |\n\n## How to install\n\n### Install LlamaGPT on your umbrelOS home server\n\nRunning LlamaGPT on an [umbrelOS](https://umbrel.com) home server is one click. Simply install it from the [Umbrel App Store](https://apps.umbrel.com/app/llama-gpt).\n\n[![LlamaGPT on Umbrel App Store](https://apps.umbrel.com/app/llama-gpt/badge-light.svg)](https://apps.umbrel.com/app/llama-gpt)\n\n### Install LlamaGPT on M1/M2 Mac\n\nMake sure your have Docker and Xcode installed.\n\nThen, clone this repo and `cd` into it:\n\n```\ngit clone https://github.com/getumbrel/llama-gpt.git\ncd llama-gpt\n```\n\nRun LlamaGPT with the following command:\n\n```\n./run-mac.sh --model 7b\n```\n\nYou can access LlamaGPT at http://localhost:3000.\n\n> To run 13B or 70B chat models, replace `7b` with `13b` or `70b` respectively.\n> To run 7B, 13B or 34B Code Llama models, replace `7b` with `code-7b`, `code-13b` or `code-34b` respectively.\n\nTo stop LlamaGPT, do `Ctrl + C` in Terminal.\n\n### Install LlamaGPT anywhere else with Docker\n\nYou can run LlamaGPT on any x86 or arm64 system. Make sure you have Docker installed.\n\nThen, clone this repo and `cd` into it:\n\n```\ngit clone https://github.com/getumbrel/llama-gpt.git\ncd llama-gpt\n```\n\nRun LlamaGPT with the following command:\n\n```\n./run.sh --model 7b\n```\n\nOr if you have an Nvidia GPU, you can run LlamaGPT with CUDA support using the `--with-cuda` flag, like:\n\n```\n./run.sh --model 7b --with-cuda\n```\n\nYou can access LlamaGPT at `http://localhost:3000`.\n\n> To run 13B or 70B chat models, replace `7b` with `13b` or `70b` respectively.\n> To run Code Llama 7B, 13B or 34B models, replace `7b` with `code-7b`, `code-13b` or `code-34b` respectively.\n\nTo stop LlamaGPT, do `Ctrl + C` in Terminal.\n\n> Note: On the first run, it may take a while for the model to be downloaded to the `/models` directory. You may also see lots of output like this for a few minutes, which is normal:\n>\n> ```\n> llama-gpt-llama-gpt-ui-1       | [INFO  wait] Host [llama-gpt-api-13b:8000] not yet available...\n> ```\n>\n> After the model has been automatically downloaded and loaded, and the API server is running, you'll see an output like:\n>\n> ```\n> llama-gpt-ui_1   | ready - started server on 0.0.0.0:3000, url: http://localhost:3000\n> ```\n>\n> You can then access LlamaGPT at http://localhost:3000.\n\n---\n\n### Install LlamaGPT with Kubernetes\n\nFirst, make sure you have a running Kubernetes cluster and `kubectl` is configured to interact with it.\n\nThen, clone this repo and `cd` into it.\n\nTo deploy to Kubernetes first create a namespace:\n\n```bash\nkubectl create ns llama\n```\n\nThen apply the manifests under the `/deploy/kubernetes` directory with\n\n```bash\nkubectl apply -k deploy/kubernetes/. -n llama\n```\n\nExpose your service however you would normally do that.\n\n## OpenAI compatible API\n\nThanks to llama-cpp-python, a drop-in replacement for OpenAI API is available at `http://localhost:3001`. Open http://localhost:3001/docs to see the API documentation.\n\n## Benchmarks\n\nWe've tested LlamaGPT models on the following hardware with the default system prompt, and user prompt: \"How does the universe expand?\" at temperature 0 to guarantee deterministic results. Generation speed is averaged over the first 10 generations.\n\nFeel free to add your own benchmarks to this table by opening a pull request.\n\n#### Nous Hermes Llama 2 7B Chat (GGML q4_0)\n\n| Device                              | Generation speed |\n| ----------------------------------- | ---------------- |\n| M1 Max MacBook Pro (64GB RAM)       | 54 tokens/sec    |\n| GCP c2-standard-16 vCPU (64 GB RAM) | 16.7 tokens/sec  |\n| Ryzen 5700G 4.4GHz 4c (16 GB RAM)   | 11.50 tokens/sec |\n| GCP c2-standard-4 vCPU (16 GB RAM)  | 4.3 tokens/sec   |\n| Umbrel Home (16GB RAM)              | 2.7 tokens/sec   |\n| Raspberry Pi 4 (8GB RAM)            | 0.9 tokens/sec   |\n\n#### Nous Hermes Llama 2 13B Chat (GGML q4_0)\n\n| Device                              | Generation speed |\n| ----------------------------------- | ---------------- |\n| M1 Max MacBook Pro (64GB RAM)       | 20 tokens/sec    |\n| GCP c2-standard-16 vCPU (64 GB RAM) | 8.6 tokens/sec   |\n| GCP c2-standard-4 vCPU (16 GB RAM)  | 2.2 tokens/sec   |\n| Umbrel Home (16GB RAM)              | 1.5 tokens/sec   |\n\n#### Nous Hermes Llama 2 70B Chat (GGML q4_0)\n\n| Device                              | Generation speed |\n| ----------------------------------- | ---------------- |\n| M1 Max MacBook Pro (64GB RAM)       | 4.8 tokens/sec   |\n| GCP e2-standard-16 vCPU (64 GB RAM) | 1.75 tokens/sec  |\n| GCP c2-standard-16 vCPU (64 GB RAM) | 1.62 tokens/sec  |\n\n#### Code Llama 7B Chat (GGUF Q4_K_M)\n\n| Device                        | Generation speed |\n| ----------------------------- | ---------------- |\n| M1 Max MacBook Pro (64GB RAM) | 41 tokens/sec    |\n\n#### Code Llama 13B Chat (GGUF Q4_K_M)\n\n| Device                        | Generation speed |\n| ----------------------------- | ---------------- |\n| M1 Max MacBook Pro (64GB RAM) | 25 tokens/sec    |\n\n#### Phind Code Llama 34B Chat (GGUF Q4_K_M)\n\n| Device                        | Generation speed |\n| ----------------------------- | ---------------- |\n| M1 Max MacBook Pro (64GB RAM) | 10.26 tokens/sec |\n\n## Roadmap and contributing\n\nWe're looking to add more features to LlamaGPT. You can see the roadmap [here](https://github.com/getumbrel/llama-gpt/issues/8#issuecomment-1681321145). The highest priorities are:\n\n- [x] Moving the model out of the Docker image and into a separate volume.\n- [x] Add Metal support for M1/M2 Macs.\n- [x] Add support for Code Llama models.\n- [x] Add CUDA support for NVIDIA GPUs.\n- [ ] Add ability to load custom models.\n- [ ] Allow users to switch between models.\n\nIf you're a developer who'd like to help with any of these, please open an issue to discuss the best way to tackle the challenge. If you're looking to help but not sure where to begin, check out [these issues](https://github.com/getumbrel/llama-gpt/labels/good%20first%20issue) that have specifically been marked as being friendly to new contributors.\n\n## Acknowledgements\n\nA massive thank you to the following developers and teams for making LlamaGPT possible:\n\n- [Mckay Wrigley](https://github.com/mckaywrigley) for building [Chatbot UI](https://github.com/mckaywrigley).\n- [Georgi Gerganov](https://github.com/ggerganov) for implementing [llama.cpp](https://github.com/ggerganov/llama.cpp).\n- [Andrei](https://github.com/abetlen) for building the [Python bindings for llama.cpp](https://github.com/abetlen/llama-cpp-python).\n- [NousResearch](https://nousresearch.com) for [fine-tuning the Llama 2 7B and 13B models](https://huggingface.co/NousResearch).\n- [Phind](https://www.phind.com/) for [fine-tuning the Code Llama 34B model](https://www.phind.com/blog/code-llama-beats-gpt4).\n- [Tom Jobbins](https://huggingface.co/TheBloke) for [quantizing the Llama 2 models](https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML).\n- [Meta](https://ai.meta.com/llama) for releasing Llama 2 and Code Llama under a permissive license.\n\n---\n\n[![License](https://img.shields.io/github/license/getumbrel/llama-gpt?color=%235351FB)](https://github.com/getumbrel/llama-gpt/blob/master/LICENSE.md)\n\n[umbrel.com](https://umbrel.com)\n"
  },
  {
    "path": "api/run.sh",
    "content": "#!/bin/bash\n\n # Check if the MODEL environment variable is set\n if [ -z \"$MODEL\" ]\n then\n     echo \"Please set the MODEL_FILE environment variable\"\n     exit 1\n fi\n\n # Check if the MODEL_DOWNLOAD_URL environment variable is set\n if [ -z \"$MODEL_DOWNLOAD_URL\" ]\n then\n     echo \"Please set the MODEL_DOWNLOAD_URL environment variable\"\n     exit 1\n fi\n\n # Check if the model file exists\n if [ ! -f $MODEL ]; then\n     echo \"Model file not found. Downloading...\"\n     # Check if curl is installed\n     if ! [ -x \"$(command -v curl)\" ]; then\n         echo \"curl is not installed. Installing...\"\n         apt-get update --yes --quiet\n         apt-get install --yes --quiet curl\n     fi\n     # Download the model file\n     curl -L -o $MODEL $MODEL_DOWNLOAD_URL\n     if [ $? -ne 0 ]; then\n         echo \"Download failed. Trying with TLS 1.2...\"\n         curl -L --tlsv1.2 -o $MODEL $MODEL_DOWNLOAD_URL\n     fi\n else\n     echo \"$MODEL model found.\"\n fi\n\n# Build the project\nmake build\n\n# Get the number of available CPU threads\nn_threads=$(grep -c ^processor /proc/cpuinfo)\n\n# Define context window\nn_ctx=4096\n\n# Offload everything to CPU\nn_gpu_layers=0\n\n# Define batch size based on total RAM\ntotal_ram=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')\nn_batch=2096\nif [ $total_ram -lt 8000000 ]; then\n    n_batch=1024\nfi\n\n# Display configuration information\necho \"Initializing server with:\"\necho \"Batch size: $n_batch\"\necho \"Number of CPU threads: $n_threads\"\necho \"Number of GPU layers: $n_gpu_layers\"\necho \"Context window: $n_ctx\"\n\n# Run the server\nexec python3 -m llama_cpp.server --n_ctx $n_ctx --n_threads $n_threads --n_gpu_layers $n_gpu_layers --n_batch $n_batch\n"
  },
  {
    "path": "cuda/ggml.Dockerfile",
    "content": "ARG CUDA_IMAGE=\"12.1.1-devel-ubuntu22.04\"\nFROM nvidia/cuda:${CUDA_IMAGE}\n\n# We need to set the host to 0.0.0.0 to allow outside access\nENV HOST 0.0.0.0\n\nRUN apt-get update && apt-get upgrade -y \\\n    && apt-get install -y git build-essential \\\n    python3 python3-pip gcc wget \\\n    ocl-icd-opencl-dev opencl-headers clinfo \\\n    libclblast-dev libopenblas-dev \\\n    && mkdir -p /etc/OpenCL/vendors && echo \"libnvidia-opencl.so.1\" > /etc/OpenCL/vendors/nvidia.icd\n\nCOPY . .\n\n# setting build related env vars\nENV CUDA_DOCKER_ARCH=all\nENV LLAMA_CUBLAS=1\n\n# Install depencencies\nRUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings\n\n# Install llama-cpp-python 0.1.78 which has GGML support (build with cuda)\nRUN CMAKE_ARGS=\"-DLLAMA_CUBLAS=on\" FORCE_CMAKE=1 pip install llama-cpp-python==0.1.78\n\n# Run the server\nCMD python3 -m llama_cpp.server\n"
  },
  {
    "path": "cuda/gguf.Dockerfile",
    "content": "ARG CUDA_IMAGE=\"12.1.1-devel-ubuntu22.04\"\nFROM nvidia/cuda:${CUDA_IMAGE}\n\n# We need to set the host to 0.0.0.0 to allow outside access\nENV HOST 0.0.0.0\n\nRUN apt-get update && apt-get upgrade -y \\\n    && apt-get install -y git build-essential \\\n    python3 python3-pip gcc wget \\\n    ocl-icd-opencl-dev opencl-headers clinfo \\\n    libclblast-dev libopenblas-dev \\\n    && mkdir -p /etc/OpenCL/vendors && echo \"libnvidia-opencl.so.1\" > /etc/OpenCL/vendors/nvidia.icd\n\nCOPY . .\n\n# setting build related env vars\nENV CUDA_DOCKER_ARCH=all\nENV LLAMA_CUBLAS=1\n\n# Install depencencies\nRUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings\n\n# Install llama-cpp-python 0.1.80 which has GGUF support (build with cuda)\nRUN CMAKE_ARGS=\"-DLLAMA_CUBLAS=on\" FORCE_CMAKE=1 pip install llama-cpp-python==0.1.80\n\n# Run the server\nCMD python3 -m llama_cpp.server\n"
  },
  {
    "path": "cuda/run.sh",
    "content": "#!/bin/bash\n\n # Check if the MODEL environment variable is set\n if [ -z \"$MODEL\" ]\n then\n     echo \"Please set the MODEL_FILE environment variable\"\n     exit 1\n fi\n\n # Check if the MODEL_DOWNLOAD_URL environment variable is set\n if [ -z \"$MODEL_DOWNLOAD_URL\" ]\n then\n     echo \"Please set the MODEL_DOWNLOAD_URL environment variable\"\n     exit 1\n fi\n\n # Check if the model file exists\n if [ ! -f $MODEL ]; then\n     echo \"Model file not found. Downloading...\"\n     # Check if curl is installed\n     if ! [ -x \"$(command -v curl)\" ]; then\n         echo \"curl is not installed. Installing...\"\n         apt-get update --yes --quiet\n         apt-get install --yes --quiet curl\n     fi\n     # Download the model file\n     curl -L -o $MODEL $MODEL_DOWNLOAD_URL\n     if [ $? -ne 0 ]; then\n         echo \"Download failed. Trying with TLS 1.2...\"\n         curl -L --tlsv1.2 -o $MODEL $MODEL_DOWNLOAD_URL\n     fi\n else\n     echo \"$MODEL model found.\"\n fi\n\n# Build the project\nmake build\n\n# Get the number of available CPU threads\nn_threads=$(grep -c ^processor /proc/cpuinfo)\n\n# Define context window\nn_ctx=4096\n\n# Offload layers to GPU\nn_gpu_layers=10\n\n# Define batch size based on total RAM\ntotal_ram=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')\nn_batch=2096\nif [ $total_ram -lt 8000000 ]; then\n    n_batch=1024\nfi\n\n# Display configuration information\necho \"Initializing server with:\"\necho \"Batch size: $n_batch\"\necho \"Number of CPU threads: $n_threads\"\necho \"Number of GPU layers: $n_gpu_layers\"\necho \"Context window: $n_ctx\"\n\n# Run the server\nexec python3 -m llama_cpp.server --n_ctx $n_ctx --n_threads $n_threads --n_gpu_layers $n_gpu_layers --n_batch $n_batch\n"
  },
  {
    "path": "deploy/kubernetes/kustomization.yaml",
    "content": "apiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\n\nresources:\n- llama-gpt-api-deployment.yaml\n- llama-gpt-api-service.yaml\n- llama-gpt-ui-deployment.yaml\n- llama-gpt-ui-service.yaml\n\n# patches:\n# - \n\nconfigMapGenerator:\n- name: llama-gpt\n  literals:\n  - DEFAULT_MODEL=\"/models/llama-2-7b-chat.bin\"\n  - OPENAI_API_HOST=\"http://llama-gpt-api:8000\"\n  - OPENAI_API_KEY=\"sk-XXXXXXXXXXXXXXXXXXXX\"\n  - WAIT_HOSTS=\"llama-gpt-api:8000\"\n  - WAIT_TIMEOUT=\"600\""
  },
  {
    "path": "deploy/kubernetes/llama-gpt-api-deployment.yaml",
    "content": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  labels:\n    service: llama-gpt-api\n  name: llama-gpt-api\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      service: llama-gpt-api\n  template:\n    metadata:\n      labels:\n        service: llama-gpt-api\n    spec:\n      containers:\n        - name: llama-gpt-api\n          image: ghcr.io/getumbrel/llama-gpt-api:1.0.1\n          env:\n            - name: MODEL\n              valueFrom: \n                configMapKeyRef:\n                  name: llama-gpt\n                  key: DEFAULT_MODEL\n          resources:\n            requests:\n              memory: 5Gi\n      restartPolicy: Always"
  },
  {
    "path": "deploy/kubernetes/llama-gpt-api-service.yaml",
    "content": "apiVersion: v1\nkind: Service\nmetadata:\n  labels:\n    service: llama-gpt-api\n  name: llama-gpt-api\nspec:\n  ports:\n    - name: api\n      port: 8000\n      targetPort: 8000\n  selector:\n    service: llama-gpt-api\nstatus:\n  loadBalancer: {}\n"
  },
  {
    "path": "deploy/kubernetes/llama-gpt-ui-deployment.yaml",
    "content": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  labels:\n    service: llama-gpt-ui\n  name: llama-gpt-ui\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      service: llama-gpt-ui\n  template:\n    metadata:\n      labels:\n        service: llama-gpt-ui\n    spec:\n      containers:\n        - name: llama-gpt-ui\n          image: ghcr.io/getumbrel/llama-gpt-ui:latest\n          envFrom:\n          - configMapRef:\n              name: llama-gpt\n          ports:\n            - containerPort: 3000\n          resources: {}\n      restartPolicy: Always"
  },
  {
    "path": "deploy/kubernetes/llama-gpt-ui-service.yaml",
    "content": "apiVersion: v1\nkind: Service\nmetadata:\n  labels:\n    service: llama-gpt-ui\n  name: llama-gpt-ui\nspec:\n  ports:\n    - name: ui\n      port: 3000\n      targetPort: 3000\n  selector:\n    service: llama-gpt-ui\n  type: ClusterIP\nstatus:\n  loadBalancer: {}\n"
  },
  {
    "path": "docker-compose-cuda-ggml.yml",
    "content": "version: '3.6'\n\nservices:\n  llama-gpt-api-cuda-ggml:\n    build:\n      context: ./cuda\n      dockerfile: ggml.Dockerfile\n    restart: on-failure\n    volumes:\n      - './models:/models'\n      - './cuda:/cuda'\n    ports:\n      - 3001:8000\n    environment:\n      MODEL: '/models/${MODEL_NAME:-llama-2-7b-chat.bin}'\n      MODEL_DOWNLOAD_URL: '${MODEL_DOWNLOAD_URL:-https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML/resolve/main/nous-hermes-llama-2-7b.ggmlv3.q4_0.bin}'\n      N_GQA: '${N_GQA:-1}'\n      USE_MLOCK: 1\n    cap_add:\n      - IPC_LOCK\n      - SYS_RESOURCE\n    command: '/bin/sh /cuda/run.sh'\n    deploy:\n      resources:\n        reservations:\n          devices:\n            - driver: nvidia\n              count: 1\n              capabilities: [gpu]\n\n  llama-gpt-ui:\n    # TODO: Use this image instead of building from source after the next release\n    # image: 'ghcr.io/getumbrel/llama-gpt-ui:latest'\n    build:\n      context: ./ui\n      dockerfile: Dockerfile\n    ports:\n      - 3000:3000\n    restart: on-failure\n    environment:\n      - 'OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX'\n      - 'OPENAI_API_HOST=http://llama-gpt-api-cuda-ggml:8000'\n      - 'DEFAULT_MODEL=/models/${MODEL_NAME:-llama-2-7b-chat.bin}'\n      - 'NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT=${DEFAULT_SYSTEM_PROMPT:-\"You are a helpful and friendly AI assistant. Respond very concisely.\"}'\n      - 'WAIT_HOSTS=llama-gpt-api-cuda-ggml:8000'\n      - 'WAIT_TIMEOUT=${WAIT_TIMEOUT:-3600}'\n"
  },
  {
    "path": "docker-compose-cuda-gguf.yml",
    "content": "version: '3.6'\n\nservices:\n  llama-gpt-api-cuda-gguf:\n    build:\n      context: ./cuda\n      dockerfile: gguf.Dockerfile\n    restart: on-failure\n    volumes:\n      - './models:/models'\n      - './cuda:/cuda'\n    ports:\n      - 3001:8000\n    environment:\n      MODEL: '/models/${MODEL_NAME:-code-llama-2-7b-chat.gguf}'\n      MODEL_DOWNLOAD_URL: '${MODEL_DOWNLOAD_URL:-https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF/resolve/main/codellama-7b-instruct.Q4_K_M.gguf}'\n      N_GQA: '${N_GQA:-1}'\n      USE_MLOCK: 1\n    cap_add:\n      - IPC_LOCK\n      - SYS_RESOURCE\n    command: '/bin/sh /cuda/run.sh'\n    deploy:\n      resources:\n        reservations:\n          devices:\n            - driver: nvidia\n              count: 1\n              capabilities: [gpu]\n\n  llama-gpt-ui:\n    # TODO: Use this image instead of building from source after the next release\n    # image: 'ghcr.io/getumbrel/llama-gpt-ui:latest'\n    build:\n      context: ./ui\n      dockerfile: Dockerfile\n    ports:\n      - 3000:3000\n    restart: on-failure\n    environment:\n      - 'OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX'\n      - 'OPENAI_API_HOST=http://llama-gpt-api-cuda-gguf:8000'\n      - 'DEFAULT_MODEL=/models/${MODEL_NAME:-code-llama-2-7b-chat.gguf}'\n      - 'NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT=${DEFAULT_SYSTEM_PROMPT:-\"You are a helpful and friendly AI assistant. Respond very concisely.\"}'\n      - 'WAIT_HOSTS=llama-gpt-api-cuda-gguf:8000'\n      - 'WAIT_TIMEOUT=${WAIT_TIMEOUT:-3600}'\n"
  },
  {
    "path": "docker-compose-gguf.yml",
    "content": "version: '3.6'\n\nservices:\n  llama-gpt-api:\n    # Pin to llama-cpp-python 0.1.80 with GGUF support\n    image: ghcr.io/abetlen/llama-cpp-python:latest@sha256:de0fd227f348b5e43d4b5b7300f1344e712c14132914d1332182e9ecfde502b2\n    restart: on-failure\n    volumes:\n      - './models:/models'\n      - './api:/api'\n    ports:\n      - 3001:8000\n    environment:\n      MODEL: '/models/${MODEL_NAME:-code-llama-2-7b-chat.gguf}'\n      MODEL_DOWNLOAD_URL: '${MODEL_DOWNLOAD_URL:-https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF/resolve/main/codellama-7b-instruct.Q4_K_M.gguf}'\n      N_GQA: '${N_GQA:-1}'\n      USE_MLOCK: 1\n    cap_add:\n      - IPC_LOCK\n    command: '/bin/sh /api/run.sh'\n\n  llama-gpt-ui:\n    # TODO: Use this image instead of building from source after the next release\n    # image: 'ghcr.io/getumbrel/llama-gpt-ui:latest'\n    build:\n      context: ./ui\n      dockerfile: Dockerfile\n    ports:\n      - 3000:3000\n    restart: on-failure\n    environment:\n      - 'OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX'\n      - 'OPENAI_API_HOST=http://llama-gpt-api:8000'\n      - 'DEFAULT_MODEL=/models/${MODEL_NAME:-llama-2-7b-chat.bin}'\n      - 'NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT=${DEFAULT_SYSTEM_PROMPT:-\"You are a helpful and friendly AI assistant. Respond very concisely.\"}'\n      - 'WAIT_HOSTS=llama-gpt-api:8000'\n      - 'WAIT_TIMEOUT=${WAIT_TIMEOUT:-3600}'\n"
  },
  {
    "path": "docker-compose-mac.yml",
    "content": "version: '3.6'\n\nservices:\n  llama-gpt-ui-mac:\n    build:\n      context: ./ui\n      dockerfile: no-wait.Dockerfile\n    ports:\n      - 3000:3000\n    restart: on-failure\n    environment:\n      - 'OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX'\n      - 'OPENAI_API_HOST=http://host.docker.internal:3001'\n      - 'DEFAULT_MODEL=$MODEL'\n      - 'NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT=${DEFAULT_SYSTEM_PROMPT:-\"You are a helpful and friendly AI assistant. Respond very concisely and use markdown if responding with code.\"}'\n"
  },
  {
    "path": "docker-compose.yml",
    "content": "version: '3.6'\n\nservices:\n  llama-gpt-api:\n    # Pin the image to llama-cpp-python 0.1.78 to avoid ggml => gguf breaking changes\n    image: ghcr.io/abetlen/llama-cpp-python:latest@sha256:b6d21ff8c4d9baad65e1fa741a0f8c898d68735fff3f3cd777e3f0c6a1839dd4\n    restart: on-failure\n    volumes:\n      - './models:/models'\n      - './api:/api'\n    ports:\n      - 3001:8000\n    environment:\n      MODEL: '/models/${MODEL_NAME:-llama-2-7b-chat.bin}'\n      MODEL_DOWNLOAD_URL: '${MODEL_DOWNLOAD_URL:-https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML/resolve/main/nous-hermes-llama-2-7b.ggmlv3.q4_0.bin}'\n      N_GQA: '${N_GQA:-1}'\n      USE_MLOCK: 1\n    cap_add:\n      - IPC_LOCK\n    command: '/bin/sh /api/run.sh'\n\n  llama-gpt-ui:\n    # TODO: Use this image instead of building from source after the next release\n    # image: 'ghcr.io/getumbrel/llama-gpt-ui:latest'\n    build:\n      context: ./ui\n      dockerfile: Dockerfile\n    ports:\n      - 3000:3000\n    restart: on-failure\n    environment:\n      - 'OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX'\n      - 'OPENAI_API_HOST=http://llama-gpt-api:8000'\n      - 'DEFAULT_MODEL=/models/${MODEL_NAME:-llama-2-7b-chat.bin}'\n      - 'NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT=${DEFAULT_SYSTEM_PROMPT:-\"You are a helpful and friendly AI assistant. Respond very concisely.\"}'\n      - 'WAIT_HOSTS=llama-gpt-api:8000'\n      - 'WAIT_TIMEOUT=${WAIT_TIMEOUT:-3600}'\n"
  },
  {
    "path": "models/.gitkeep",
    "content": ""
  },
  {
    "path": "run-mac.sh",
    "content": "#!/bin/bash\nset -e\n\n# Define a function to refresh the source of .zshrc or .bashrc\nsource_shell_rc() {\n    # Source .zshrc or .bashrc\n    if [ -f ~/.zshrc ]; then\n        source ~/.zshrc\n    elif [ -f ~/.bashrc ]; then\n        source ~/.bashrc\n    else\n        echo \"No .bashrc or .zshrc file found.\"\n    fi\n}\n\n# Define a function to install conda with Miniforge3\ninstall_conda() {\n    # Download Miniforge3\n    curl -L -o /tmp/Miniforge3.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh\n    bash /tmp/Miniforge3.sh\n    source_shell_rc\n}\n\n# Define a function to install a specific version of llama-cpp-python\ninstall_llama_cpp_python() {\n    local model_type=$1\n    local version=$2\n    local installed_version=$(pip3 show llama-cpp-python | grep -i version | awk '{print $2}')\n\n    if [[ \"$installed_version\" != \"$version\" ]]; then\n        echo \"llama-cpp-python version is not $version. Installing $version version for $model_type support...\"\n        pip3 uninstall llama-cpp-python -y\n        CMAKE_ARGS=\"-DLLAMA_METAL=on\" FORCE_CMAKE=1 pip3 install llama-cpp-python==$version --no-cache-dir\n        pip3 install 'llama-cpp-python[server]'\n    else\n        echo \"llama-cpp-python version is $version.\"\n    fi\n}\n\nsource_shell_rc\n\n# Check if the platform is MacOS and the architecture is arm64\nif [[ \"$(uname)\" != \"Darwin\" ]] || [[ \"$(uname -m)\" != \"arm64\" ]]; then\n    echo \"This script is intended to be run on MacOS with M1/M2 chips. Exiting...\"\n    exit 1\nfi\n\n# Check if Docker is installed\nif ! command -v docker &> /dev/null; then\n    echo \"Docker is not installed. Exiting...\"\n    exit 1\nfi\n\n# Check if python3 is installed\nif ! command -v python3 &> /dev/null; then\n    echo \"Python3 is not installed. Exiting...\"\n    exit 1\nfi\n\n# Check if Xcode is installed\nxcode_path=$(xcode-select -p 2>/dev/null)\nif [ -z \"$xcode_path\" ]; then\n    echo \"Xcode is not installed. Installing (this may take a long time)...\"\n    xcode-select --install\nelse\n    echo \"Xcode is installed at $xcode_path\"\nfi\n\n# Check if conda is installed\nif ! command -v conda &> /dev/null; then\n    echo \"Conda is not installed. Installing Miniforge3 which includes conda...\"\n    install_conda\nelse\n    echo \"Conda is installed.\"\n    # TODO: Check if the conda version for MacOS that supports Metal GPU is installed\n    # conda_version=$(conda --version)\n    # if [[ $conda_version != *\"Miniforge3\"* ]]; then\n    #     echo \"Conda version that supports Metal GPU is not installed. Installing...\"\n    #     install_conda\n    # else\n    #     echo \"Conda version that supports M1/M2 is installed.\"\n    # fi\nfi\n\n\n# Check if the conda environment 'llama-gpt' exists\nif conda env list | grep -q 'llama-gpt'; then\n    echo \"Conda environment 'llama-gpt' already exists.\"\nelse\n    echo \"Creating a conda environment called 'llama-gpt'...\"\n    conda create -n llama-gpt python=$(python3 --version | cut -d ' ' -f 2)\nfi\n\n# Check if the conda environment 'llama-gpt' is active\nif [[ \"$(conda info --envs | grep '*' | awk '{print $1}')\" != \"llama-gpt\" ]]; then\n    echo \"Activating the conda environment 'llama-gpt'...\"\n    conda activate llama-gpt\nelse\n    echo \"Conda environment 'llama-gpt' is already active.\"\nfi\n\n# Parse command line arguments for --model\nwhile [[ \"$#\" -gt 0 ]]; do\n    case $1 in\n        --model) MODEL=\"$2\"; shift ;;\n        *) echo \"Unknown parameter passed: $1\"; exit 1 ;;\n    esac\n    shift\ndone\n\n# If no model is passed, default to 7b model\nif [[ -z \"$MODEL\" ]]; then\n    echo \"No model value provided. Defaulting to 7b. If you want to change the model, exit the script and use --model to provide the model value.\"\n    echo \"Supported models are 7b, 13b, 70b, code-7b, code-13b, code-34b.\"\n    MODEL=\"7b\"\nfi\n\n# Get the number of available CPU cores and subtract 2\nn_threads=$(($(sysctl -n hw.logicalcpu) - 2))\n\n# Define context window\nn_ctx=4096\n\n# Define batch size\nn_batch=2096\n\n# Define number of GPU layers\nn_gpu_layers=1\n\n# Define grouping factor\nN_GQA=1\n\nmodel_type=\"gguf\"\n\n# Set values for MODEL and MODEL_DOWNLOAD_URL based on the model passed\ncase $MODEL in\n    7b) \n        MODEL=\"./models/llama-2-7b-chat.bin\"\n        MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML/resolve/main/nous-hermes-llama-2-7b.ggmlv3.q4_0.bin\"\n        model_type=\"ggml\"\n        ;;\n    13b) \n        MODEL=\"./models/llama-2-13b-chat.bin\"\n        MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Nous-Hermes-Llama2-GGML/resolve/main/nous-hermes-llama2-13b.ggmlv3.q4_0.bin\"\n        model_type=\"ggml\"\n        n_gpu_layers=2\n        ;;\n    70b) \n        MODEL=\"./models/llama-2-70b-chat.bin\"\n        MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Llama-2-70B-Chat-GGML/resolve/main/llama-2-70b-chat.ggmlv3.q4_0.bin\"\n        model_type=\"ggml\"\n        n_gpu_layers=3\n        # Llama 2 70B's grouping factor is 8 compared to 7B and 13B's 1.\n        N_GQA=8\n        ;;\n    code-7b)\n        MODEL=\"./models/code-llama-7b-chat.gguf\"\n        MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF/resolve/main/codellama-7b-instruct.Q4_K_M.gguf\"\n        DEFAULT_SYSTEM_PROMPT=\"You are a helpful coding assistant. Use markdown when responding with code.\"\n        n_gpu_layers=1\n        n_ctx=8192\n        ;;\n    code-13b)\n        MODEL=\"./models/code-llama-13b-chat.gguf\"\n        MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/CodeLlama-13B-Instruct-GGUF/resolve/main/codellama-13b-instruct.Q4_K_M.gguf\"\n        DEFAULT_SYSTEM_PROMPT=\"You are a helpful coding assistant. Use markdown when responding with code.\"\n        n_gpu_layers=2\n        n_ctx=8192\n        ;;\n    code-34b)\n        MODEL=\"./models/code-llama-34b-chat.gguf\"\n        MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GGUF/resolve/main/phind-codellama-34b-v1.Q4_K_M.gguf\"\n        DEFAULT_SYSTEM_PROMPT=\"You are a helpful coding assistant. Use markdown when responding with code.\"\n        n_gpu_layers=3\n        n_ctx=8192\n        # Code Llama 34B's grouping factor is 8 compared to 7B and 13B's 1.\n        N_GQA=8\n        ;;\n    *) \n        echo \"Invalid model passed: $MODEL\"; exit 1 \n        ;;\nesac\n\n# Check if llama-cpp-python is already installed\nllama_cpp_python_installed=$(pip3 list | grep -q llama-cpp-python && echo \"installed\" || echo \"not installed\")\nif [[ \"$llama_cpp_python_installed\" == \"not installed\" ]]; then\n    echo \"llama-cpp-python is not installed. Installing...\"\n    if [[ \"$model_type\" == \"ggml\" ]]; then\n        install_llama_cpp_python \"GGML\" \"0.1.78\"\n    else\n        install_llama_cpp_python \"GGUF\" \"0.1.80\"\n    fi\nelse\n    echo \"llama-cpp-python is installed.\"\n    if [[ \"$model_type\" == \"ggml\" ]]; then\n        install_llama_cpp_python \"GGML\" \"0.1.78\"\n    else\n        install_llama_cpp_python \"GGUF\" \"0.1.80\"\n    fi\nfi\n\n\n# Check if the model file exists\nif [ ! -f $MODEL ]; then\n    echo \"Model file not found. Downloading...\"\n    # Download the model file with a custom progress bar showing percentage, download speed, downloaded, total size, and estimated time remaining\n    curl -L -o $MODEL $MODEL_DOWNLOAD_URL\n    if [ $? -ne 0 ]; then\n        echo \"Download failed. Trying with TLS 1.2...\"\n        curl -L --tlsv1.2 -o $MODEL $MODEL_DOWNLOAD_URL\n    fi\nelse\n    echo \"$MODEL model found.\"\nfi\n\n# Display configuration information\necho \"Initializing server with:\"\necho \"Batch size: $n_batch\"\necho \"Number of CPU threads: $n_threads\"\necho \"Number of GPU layers: $n_gpu_layers\"\necho \"Context window: $n_ctx\"\necho \"GQA: $n_gqa\"\n\n# Export environment variables\nexport MODEL\nexport N_GQA\nexport DEFAULT_SYSTEM_PROMPT\n\n# Run docker-compose with the macOS yml file\ndocker compose -f ./docker-compose-mac.yml up --remove-orphans --build &\n\n# Run the server\npython3 -m llama_cpp.server --n_ctx $n_ctx --n_threads $n_threads --n_gpu_layers $n_gpu_layers --n_batch $n_batch --model $MODEL --port 3001 &\n\n# Define a function to stop docker-compose and the python3 command\nstop_commands() {\n    echo \"Stopping docker-compose...\"\n    docker compose -f ./docker-compose-mac.yml down\n    echo \"Stopping python server...\"\n    pkill -f \"python3 -m llama_cpp.server\"\n    echo \"Deactivating conda environment...\"\n    conda deactivate\n    echo \"All processes stopped.\"\n}\n\n# Set a trap to catch SIGINT and stop the commands\ntrap stop_commands SIGINT\n\n# Wait for both commands to finish\nwait $DOCKER_COMPOSE_PID\nwait $PYTHON_PID\n\n\n"
  },
  {
    "path": "run.sh",
    "content": "#!/bin/bash\n\n# Check if docker compose is installed\nif ! command -v docker &> /dev/null\nthen\n    echo \"Docker could not be found. Please install Docker and try again.\"\n    exit\nfi\n\n# Parse command line arguments for model value and check for --with-cuda flag\nwith_cuda=0\nwhile [[ \"$#\" -gt 0 ]]; do\n    case $1 in\n        --model) model=\"$2\"; shift ;;\n        --with-cuda) with_cuda=1 ;;\n        *) echo \"Unknown parameter passed: $1\"; exit 1 ;;\n    esac\n    shift\ndone\n\n# Check if model value is provided\nif [ -z \"$model\" ]\nthen\n    echo \"No model value provided. Defaulting to 7b. If you want to change the model, exit the script and use --model to provide the model value.\"\n    echo \"Supported models are 7b, 13b, 70b, code-7b, code-13b, code-34b.\"\n    model=\"7b\"\nfi\n\nmodel_type=\"gguf\"\n\n# Export the model value as an environment variable\ncase $model in\n    7b)\n        export MODEL_NAME=\"llama-2-7b-chat.bin\"\n        export MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML/resolve/main/nous-hermes-llama-2-7b.ggmlv3.q4_0.bin\"\n        export WAIT_TIMEOUT=3600\n        export N_GQA=1\n        model_type=\"ggml\"\n        ;;\n    13b)\n        export MODEL_NAME=\"llama-2-13b-chat.bin\"\n        export MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Nous-Hermes-Llama2-GGML/resolve/main/nous-hermes-llama2-13b.ggmlv3.q4_0.bin\"\n        export WAIT_TIMEOUT=10800\n        export N_GQA=1\n        model_type=\"ggml\"\n        ;;\n    70b)\n        export MODEL_NAME=\"llama-2-70b-chat.bin\"\n        export MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Nous-Hermes-Llama2-70B-GGML/resolve/main/nous-hermes-llama2-70b.ggmlv3.Q4_0.bin\"\n        export WAIT_TIMEOUT=21600\n        # Llama 2 70B's grouping factor is 8 compared to 7B and 13B's 1. Currently,\n        # it's not possible to change this using --n_gqa with llama-cpp-python in\n        # run.sh, so we expose it as an environment variable.\n        # See: https://github.com/abetlen/llama-cpp-python/issues/528\n        # and: https://github.com/facebookresearch/llama/issues/407\n        export N_GQA=8\n        model_type=\"ggml\"\n        ;;\n    code-7b)\n        export MODEL_NAME=\"code-llama-7b-chat.gguf\"\n        export MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF/resolve/main/codellama-7b-instruct.Q4_K_M.gguf\"\n        export WAIT_TIMEOUT=3600\n        export DEFAULT_SYSTEM_PROMPT=\"You are a helpful coding assistant. Use markdown when responding with code.\"\n        export N_GQA=1\n        ;;\n    code-13b)\n        export MODEL_NAME=\"code-llama-13b-chat.gguf\"\n        export MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/CodeLlama-13B-Instruct-GGUF/resolve/main/codellama-13b-instruct.Q4_K_M.gguf\"\n        export DEFAULT_SYSTEM_PROMPT=\"You are a helpful coding assistant. Use markdown when responding with code.\"\n        export WAIT_TIMEOUT=10800\n        export N_GQA=1\n        ;;\n    code-34b)\n        export MODEL_NAME=\"code-llama-34b-chat.gguf\"\n        export MODEL_DOWNLOAD_URL=\"https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GGUF/resolve/main/phind-codellama-34b-v1.Q4_K_M.gguf\"\n        export DEFAULT_SYSTEM_PROMPT=\"You are a helpful coding assistant. Use markdown when responding with code.\"\n        export WAIT_TIMEOUT=21600\n        # Code Llama 34B's grouping factor is 8 compared to 7B and 13B's 1. Currently,\n        # it's not possible to change this using --n_gqa with llama-cpp-python in\n        # run.sh, so we expose it as an environment variable.\n        # See: https://github.com/abetlen/llama-cpp-python/issues/528\n        export N_GQA=8\n        ;;\n    *)\n        echo \"Invalid model value provided. Supported models are 7b, 13b, 70b, code-7b, code-13b, code-34b.\"\n        exit 1\n        ;;\nesac\n\n# Run docker compose with docker-compose-ggml.yml or docker-compose-gguf.yml\n\nif [ \"$with_cuda\" -eq 1 ]\nthen\n    if [ \"$model_type\" = \"ggml\" ]\n    then\n        docker compose -f docker-compose-cuda-ggml.yml up --build\n    else\n        docker compose -f docker-compose-cuda-gguf.yml up --build\n    fi\nelse\n    if [ \"$model_type\" = \"ggml\" ]\n    then\n        docker compose -f docker-compose.yml up --build\n    else\n        docker compose -f docker-compose-gguf.yml up --build\n    fi\nfi\n"
  },
  {
    "path": "ui/.dockerignore",
    "content": ".env\n.env.local\nnode_modules\ntest-results\n"
  },
  {
    "path": "ui/.eslintrc.json",
    "content": "{\n  \"extends\": \"next/core-web-vitals\"\n}\n"
  },
  {
    "path": "ui/.gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n/test-results\n\n# next.js\n/.next/\n/out/\n/dist\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n.pnpm-debug.log*\n\n# local env files\n.env*.local\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\nnext-env.d.ts\n.idea\npnpm-lock.yaml\n"
  },
  {
    "path": "ui/CONTRIBUTING.md",
    "content": "# Contributing Guidelines\n\n**Welcome to Chatbot UI!**\n\nWe appreciate your interest in contributing to our project.\n\nBefore you get started, please read our guidelines for contributing.\n\n## Types of Contributions\n\nWe welcome the following types of contributions:\n\n- Bug fixes\n- New features\n- Documentation improvements\n- Code optimizations\n- Translations\n- Tests\n\n## Getting Started\n\nTo get started, fork the project on GitHub and clone it locally on your machine. Then, create a new branch to work on your changes.\n\n```\ngit clone https://github.com/mckaywrigley/chatbot-ui.git\ncd chatbot-ui\ngit checkout -b my-branch-name\n\n```\n\nBefore submitting your pull request, please make sure your changes pass our automated tests and adhere to our code style guidelines.\n\n## Pull Request Process\n\n1. Fork the project on GitHub.\n2. Clone your forked repository locally on your machine.\n3. Create a new branch from the main branch.\n4. Make your changes on the new branch.\n5. Ensure that your changes adhere to our code style guidelines and pass our automated tests.\n6. Commit your changes and push them to your forked repository.\n7. Submit a pull request to the main branch of the main repository.\n\n## Contact\n\nIf you have any questions or need help getting started, feel free to reach out to me on [Twitter](https://twitter.com/mckaywrigley).\n"
  },
  {
    "path": "ui/Dockerfile",
    "content": "# ---- Base Node ----\nFROM node:19-alpine AS base\nWORKDIR /app\nCOPY package*.json ./\n\n# ---- Dependencies ----\nFROM base AS dependencies\nRUN npm ci\n\n# ---- Build ----\nFROM dependencies AS build\nCOPY . .\nRUN npm run build\n\n# ---- Production ----\nFROM node:19-alpine AS production\nWORKDIR /app\nCOPY --from=dependencies /app/node_modules ./node_modules\nCOPY --from=build /app/.next ./.next\nCOPY --from=build /app/public ./public\nCOPY --from=build /app/package*.json ./\nCOPY --from=build /app/next.config.js ./next.config.js\nCOPY --from=build /app/next-i18next.config.js ./next-i18next.config.js\n\n## Add the wait script to the image\nCOPY --from=ghcr.io/ufoscout/docker-compose-wait:latest /wait /wait\n\n# Expose the port the app will run on\nEXPOSE 3000\n\n# Start the application after the API is ready\nCMD /wait && npm start\n\n"
  },
  {
    "path": "ui/Makefile",
    "content": "include .env\n\n.PHONY: all\n\nbuild:\n\tdocker build -t chatbot-ui .\n\nrun:\n\texport $(cat .env | xargs)\n\tdocker stop chatbot-ui || true && docker rm chatbot-ui || true\n\tdocker run --name chatbot-ui --rm -e OPENAI_API_KEY=${OPENAI_API_KEY} -p 3000:3000 chatbot-ui\n\nlogs:\n\tdocker logs -f chatbot-ui\n\npush:\n\tdocker tag chatbot-ui:latest ${DOCKER_USER}/chatbot-ui:${DOCKER_TAG}\n\tdocker push ${DOCKER_USER}/chatbot-ui:${DOCKER_TAG}"
  },
  {
    "path": "ui/__tests__/utils/app/importExports.test.ts",
    "content": "import { DEFAULT_SYSTEM_PROMPT, DEFAULT_TEMPERATURE } from '@/utils/app/const';\nimport {\n  cleanData,\n  isExportFormatV1,\n  isExportFormatV2,\n  isExportFormatV3,\n  isExportFormatV4,\n  isLatestExportFormat,\n} from '@/utils/app/importExport';\n\nimport { ExportFormatV1, ExportFormatV2, ExportFormatV4 } from '@/types/export';\nimport { OpenAIModelID, OpenAIModels } from '@/types/openai';\n\nimport { describe, expect, it } from 'vitest';\n\ndescribe('Export Format Functions', () => {\n  describe('isExportFormatV1', () => {\n    it('should return true for v1 format', () => {\n      const obj = [{ id: 1 }];\n      expect(isExportFormatV1(obj)).toBe(true);\n    });\n\n    it('should return false for non-v1 formats', () => {\n      const obj = { version: 3, history: [], folders: [] };\n      expect(isExportFormatV1(obj)).toBe(false);\n    });\n  });\n\n  describe('isExportFormatV2', () => {\n    it('should return true for v2 format', () => {\n      const obj = { history: [], folders: [] };\n      expect(isExportFormatV2(obj)).toBe(true);\n    });\n\n    it('should return false for non-v2 formats', () => {\n      const obj = { version: 3, history: [], folders: [] };\n      expect(isExportFormatV2(obj)).toBe(false);\n    });\n  });\n\n  describe('isExportFormatV3', () => {\n    it('should return true for v3 format', () => {\n      const obj = { version: 3, history: [], folders: [] };\n      expect(isExportFormatV3(obj)).toBe(true);\n    });\n\n    it('should return false for non-v3 formats', () => {\n      const obj = { version: 4, history: [], folders: [] };\n      expect(isExportFormatV3(obj)).toBe(false);\n    });\n  });\n\n  describe('isExportFormatV4', () => {\n    it('should return true for v4 format', () => {\n      const obj = { version: 4, history: [], folders: [], prompts: [] };\n      expect(isExportFormatV4(obj)).toBe(true);\n    });\n\n    it('should return false for non-v4 formats', () => {\n      const obj = { version: 5, history: [], folders: [], prompts: [] };\n      expect(isExportFormatV4(obj)).toBe(false);\n    });\n  });\n});\n\ndescribe('cleanData Functions', () => {\n  describe('cleaning v1 data', () => {\n    it('should return the latest format', () => {\n      const data = [\n        {\n          id: 1,\n          name: 'conversation 1',\n          messages: [\n            {\n              role: 'user',\n              content: \"what's up ?\",\n            },\n            {\n              role: 'assistant',\n              content: 'Hi',\n            },\n          ],\n        },\n      ] as ExportFormatV1;\n      const obj = cleanData(data);\n      expect(isLatestExportFormat(obj)).toBe(true);\n      expect(obj).toEqual({\n        version: 4,\n        history: [\n          {\n            id: 1,\n            name: 'conversation 1',\n            messages: [\n              {\n                role: 'user',\n                content: \"what's up ?\",\n              },\n              {\n                role: 'assistant',\n                content: 'Hi',\n              },\n            ],\n            model: OpenAIModels[OpenAIModelID.GPT_3_5],\n            prompt: DEFAULT_SYSTEM_PROMPT,\n            temperature: DEFAULT_TEMPERATURE,\n            folderId: null,\n          },\n        ],\n        folders: [],\n        prompts: [],\n      });\n    });\n  });\n\n  describe('cleaning v2 data', () => {\n    it('should return the latest format', () => {\n      const data = {\n        history: [\n          {\n            id: '1',\n            name: 'conversation 1',\n            messages: [\n              {\n                role: 'user',\n                content: \"what's up ?\",\n              },\n              {\n                role: 'assistant',\n                content: 'Hi',\n              },\n            ],\n          },\n        ],\n        folders: [\n          {\n            id: 1,\n            name: 'folder 1',\n          },\n        ],\n      } as ExportFormatV2;\n      const obj = cleanData(data);\n      expect(isLatestExportFormat(obj)).toBe(true);\n      expect(obj).toEqual({\n        version: 4,\n        history: [\n          {\n            id: '1',\n            name: 'conversation 1',\n            messages: [\n              {\n                role: 'user',\n                content: \"what's up ?\",\n              },\n              {\n                role: 'assistant',\n                content: 'Hi',\n              },\n            ],\n            model: OpenAIModels[OpenAIModelID.GPT_3_5],\n            prompt: DEFAULT_SYSTEM_PROMPT,\n            temperature: DEFAULT_TEMPERATURE,\n            folderId: null,\n          },\n        ],\n        folders: [\n          {\n            id: '1',\n            name: 'folder 1',\n            type: 'chat',\n          },\n        ],\n        prompts: [],\n      });\n    });\n  });\n\n  describe('cleaning v4 data', () => {\n    it('should return the latest format', () => {\n      const data = {\n        version: 4,\n        history: [\n          {\n            id: '1',\n            name: 'conversation 1',\n            messages: [\n              {\n                role: 'user',\n                content: \"what's up ?\",\n              },\n              {\n                role: 'assistant',\n                content: 'Hi',\n              },\n            ],\n            model: OpenAIModels[OpenAIModelID.GPT_3_5],\n            prompt: DEFAULT_SYSTEM_PROMPT,\n            temperature: DEFAULT_TEMPERATURE,\n            folderId: null,\n          },\n        ],\n        folders: [\n          {\n            id: '1',\n            name: 'folder 1',\n            type: 'chat',\n          },\n        ],\n        prompts: [\n          {\n            id: '1',\n            name: 'prompt 1',\n            description: '',\n            content: '',\n            model: OpenAIModels[OpenAIModelID.GPT_3_5],\n            folderId: null,\n          },\n        ],\n      } as ExportFormatV4;\n\n      const obj = cleanData(data);\n      expect(isLatestExportFormat(obj)).toBe(true);\n      expect(obj).toEqual({\n        version: 4,\n        history: [\n          {\n            id: '1',\n            name: 'conversation 1',\n            messages: [\n              {\n                role: 'user',\n                content: \"what's up ?\",\n              },\n              {\n                role: 'assistant',\n                content: 'Hi',\n              },\n            ],\n            model: OpenAIModels[OpenAIModelID.GPT_3_5],\n            prompt: DEFAULT_SYSTEM_PROMPT,\n            temperature: DEFAULT_TEMPERATURE,\n            folderId: null,\n          },\n        ],\n        folders: [\n          {\n            id: '1',\n            name: 'folder 1',\n            type: 'chat',\n          },\n        ],\n        prompts: [\n          {\n            id: '1',\n            name: 'prompt 1',\n            description: '',\n            content: '',\n            model: OpenAIModels[OpenAIModelID.GPT_3_5],\n            folderId: null,\n          },\n        ],\n      });\n    });\n  });\n});\n"
  },
  {
    "path": "ui/components/Buttons/SidebarActionButton/SidebarActionButton.tsx",
    "content": "import { MouseEventHandler, ReactElement } from 'react';\n\ninterface Props {\n  handleClick: MouseEventHandler<HTMLButtonElement>;\n  children: ReactElement;\n}\n\nconst SidebarActionButton = ({ handleClick, children }: Props) => (\n  <button\n    className=\"min-w-[20px] p-1 text-neutral-400 hover:text-neutral-100\"\n    onClick={handleClick}\n  >\n    {children}\n  </button>\n);\n\nexport default SidebarActionButton;\n"
  },
  {
    "path": "ui/components/Buttons/SidebarActionButton/index.ts",
    "content": "export { default } from './SidebarActionButton';\n"
  },
  {
    "path": "ui/components/Chat/Chat.tsx",
    "content": "import { IconClearAll, IconSettings } from '@tabler/icons-react';\nimport {\n  MutableRefObject,\n  memo,\n  useCallback,\n  useContext,\n  useEffect,\n  useRef,\n  useState,\n} from 'react';\nimport toast from 'react-hot-toast';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { getEndpoint } from '@/utils/app/api';\nimport {\n  saveConversation,\n  saveConversations,\n  updateConversation,\n} from '@/utils/app/conversation';\nimport { throttle } from '@/utils/data/throttle';\n\nimport { ChatBody, Conversation, Message } from '@/types/chat';\nimport { Plugin } from '@/types/plugin';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport Spinner from '../Spinner';\nimport { ChatInput } from './ChatInput';\nimport { ChatLoader } from './ChatLoader';\nimport { ErrorMessageDiv } from './ErrorMessageDiv';\nimport { ModelSelect } from './ModelSelect';\nimport { SystemPrompt } from './SystemPrompt';\nimport { TemperatureSlider } from './Temperature';\nimport { MemoizedChatMessage } from './MemoizedChatMessage';\n\ninterface Props {\n  stopConversationRef: MutableRefObject<boolean>;\n}\n\nexport const Chat = memo(({ stopConversationRef }: Props) => {\n  const { t } = useTranslation('chat');\n\n  const {\n    state: {\n      selectedConversation,\n      conversations,\n      models,\n      apiKey,\n      pluginKeys,\n      serverSideApiKeyIsSet,\n      messageIsStreaming,\n      modelError,\n      loading,\n      prompts,\n    },\n    handleUpdateConversation,\n    dispatch: homeDispatch,\n  } = useContext(HomeContext);\n\n  const [currentMessage, setCurrentMessage] = useState<Message>();\n  const [autoScrollEnabled, setAutoScrollEnabled] = useState<boolean>(true);\n  const [showSettings, setShowSettings] = useState<boolean>(false);\n  const [showScrollDownButton, setShowScrollDownButton] =\n    useState<boolean>(false);\n\n  const messagesEndRef = useRef<HTMLDivElement>(null);\n  const chatContainerRef = useRef<HTMLDivElement>(null);\n  const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n  const handleSend = useCallback(\n    async (message: Message, deleteCount = 0, plugin: Plugin | null = null) => {\n      if (selectedConversation) {\n        let updatedConversation: Conversation;\n        if (deleteCount) {\n          const updatedMessages = [...selectedConversation.messages];\n          for (let i = 0; i < deleteCount; i++) {\n            updatedMessages.pop();\n          }\n          updatedConversation = {\n            ...selectedConversation,\n            messages: [...updatedMessages, message],\n          };\n        } else {\n          updatedConversation = {\n            ...selectedConversation,\n            messages: [...selectedConversation.messages, message],\n          };\n        }\n        homeDispatch({\n          field: 'selectedConversation',\n          value: updatedConversation,\n        });\n        homeDispatch({ field: 'loading', value: true });\n        homeDispatch({ field: 'messageIsStreaming', value: true });\n        const chatBody: ChatBody = {\n          model: updatedConversation.model,\n          messages: updatedConversation.messages,\n          key: apiKey,\n          prompt: updatedConversation.prompt,\n          temperature: updatedConversation.temperature,\n        };\n        const endpoint = getEndpoint(plugin);\n        let body;\n        if (!plugin) {\n          body = JSON.stringify(chatBody);\n        } else {\n          body = JSON.stringify({\n            ...chatBody,\n            googleAPIKey: pluginKeys\n              .find((key) => key.pluginId === 'google-search')\n              ?.requiredKeys.find((key) => key.key === 'GOOGLE_API_KEY')?.value,\n            googleCSEId: pluginKeys\n              .find((key) => key.pluginId === 'google-search')\n              ?.requiredKeys.find((key) => key.key === 'GOOGLE_CSE_ID')?.value,\n          });\n        }\n        const controller = new AbortController();\n        const response = await fetch(endpoint, {\n          method: 'POST',\n          headers: {\n            'Content-Type': 'application/json',\n          },\n          signal: controller.signal,\n          body,\n        });\n        if (!response.ok) {\n          homeDispatch({ field: 'loading', value: false });\n          homeDispatch({ field: 'messageIsStreaming', value: false });\n          toast.error(response.statusText);\n          return;\n        }\n        const data = response.body;\n        if (!data) {\n          homeDispatch({ field: 'loading', value: false });\n          homeDispatch({ field: 'messageIsStreaming', value: false });\n          return;\n        }\n        if (!plugin) {\n          if (updatedConversation.messages.length === 1) {\n            const { content } = message;\n            const customName =\n              content.length > 30 ? content.substring(0, 30) + '...' : content;\n            updatedConversation = {\n              ...updatedConversation,\n              name: customName,\n            };\n          }\n          homeDispatch({ field: 'loading', value: false });\n          const reader = data.getReader();\n          const decoder = new TextDecoder();\n          let done = false;\n          let isFirst = true;\n          let text = '';\n          while (!done) {\n            if (stopConversationRef.current === true) {\n              controller.abort();\n              done = true;\n              break;\n            }\n            const { value, done: doneReading } = await reader.read();\n            done = doneReading;\n            const chunkValue = decoder.decode(value);\n            text += chunkValue;\n            if (isFirst) {\n              isFirst = false;\n              const updatedMessages: Message[] = [\n                ...updatedConversation.messages,\n                { role: 'assistant', content: chunkValue },\n              ];\n              updatedConversation = {\n                ...updatedConversation,\n                messages: updatedMessages,\n              };\n              homeDispatch({\n                field: 'selectedConversation',\n                value: updatedConversation,\n              });\n            } else {\n              const updatedMessages: Message[] =\n                updatedConversation.messages.map((message, index) => {\n                  if (index === updatedConversation.messages.length - 1) {\n                    return {\n                      ...message,\n                      content: text,\n                    };\n                  }\n                  return message;\n                });\n              updatedConversation = {\n                ...updatedConversation,\n                messages: updatedMessages,\n              };\n              homeDispatch({\n                field: 'selectedConversation',\n                value: updatedConversation,\n              });\n            }\n          }\n          saveConversation(updatedConversation);\n          const updatedConversations: Conversation[] = conversations.map(\n            (conversation) => {\n              if (conversation.id === selectedConversation.id) {\n                return updatedConversation;\n              }\n              return conversation;\n            },\n          );\n          if (updatedConversations.length === 0) {\n            updatedConversations.push(updatedConversation);\n          }\n          homeDispatch({ field: 'conversations', value: updatedConversations });\n          saveConversations(updatedConversations);\n          homeDispatch({ field: 'messageIsStreaming', value: false });\n        } else {\n          const { answer } = await response.json();\n          const updatedMessages: Message[] = [\n            ...updatedConversation.messages,\n            { role: 'assistant', content: answer },\n          ];\n          updatedConversation = {\n            ...updatedConversation,\n            messages: updatedMessages,\n          };\n          homeDispatch({\n            field: 'selectedConversation',\n            value: updateConversation,\n          });\n          saveConversation(updatedConversation);\n          const updatedConversations: Conversation[] = conversations.map(\n            (conversation) => {\n              if (conversation.id === selectedConversation.id) {\n                return updatedConversation;\n              }\n              return conversation;\n            },\n          );\n          if (updatedConversations.length === 0) {\n            updatedConversations.push(updatedConversation);\n          }\n          homeDispatch({ field: 'conversations', value: updatedConversations });\n          saveConversations(updatedConversations);\n          homeDispatch({ field: 'loading', value: false });\n          homeDispatch({ field: 'messageIsStreaming', value: false });\n        }\n      }\n    },\n    [\n      apiKey,\n      conversations,\n      pluginKeys,\n      selectedConversation,\n      stopConversationRef,\n    ],\n  );\n\n  const scrollToBottom = useCallback(() => {\n    if (autoScrollEnabled) {\n      messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });\n      textareaRef.current?.focus();\n    }\n  }, [autoScrollEnabled]);\n\n  const handleScroll = () => {\n    if (chatContainerRef.current) {\n      const { scrollTop, scrollHeight, clientHeight } =\n        chatContainerRef.current;\n      const bottomTolerance = 30;\n\n      if (scrollTop + clientHeight < scrollHeight - bottomTolerance) {\n        setAutoScrollEnabled(false);\n        setShowScrollDownButton(true);\n      } else {\n        setAutoScrollEnabled(true);\n        setShowScrollDownButton(false);\n      }\n    }\n  };\n\n  const handleScrollDown = () => {\n    chatContainerRef.current?.scrollTo({\n      top: chatContainerRef.current.scrollHeight,\n      behavior: 'smooth',\n    });\n  };\n\n  const handleSettings = () => {\n    setShowSettings(!showSettings);\n  };\n\n  const onClearAll = () => {\n    if (\n      confirm(t<string>('Are you sure you want to clear all messages?')) &&\n      selectedConversation\n    ) {\n      handleUpdateConversation(selectedConversation, {\n        key: 'messages',\n        value: [],\n      });\n    }\n  };\n\n  const scrollDown = () => {\n    if (autoScrollEnabled) {\n      messagesEndRef.current?.scrollIntoView(true);\n    }\n  };\n  const throttledScrollDown = throttle(scrollDown, 250);\n\n  // useEffect(() => {\n  //   console.log('currentMessage', currentMessage);\n  //   if (currentMessage) {\n  //     handleSend(currentMessage);\n  //     homeDispatch({ field: 'currentMessage', value: undefined });\n  //   }\n  // }, [currentMessage]);\n\n  useEffect(() => {\n    throttledScrollDown();\n    selectedConversation &&\n      setCurrentMessage(\n        selectedConversation.messages[selectedConversation.messages.length - 2],\n      );\n  }, [selectedConversation, throttledScrollDown]);\n\n  useEffect(() => {\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        setAutoScrollEnabled(entry.isIntersecting);\n        if (entry.isIntersecting) {\n          textareaRef.current?.focus();\n        }\n      },\n      {\n        root: null,\n        threshold: 0.5,\n      },\n    );\n    const messagesEndElement = messagesEndRef.current;\n    if (messagesEndElement) {\n      observer.observe(messagesEndElement);\n    }\n    return () => {\n      if (messagesEndElement) {\n        observer.unobserve(messagesEndElement);\n      }\n    };\n  }, [messagesEndRef]);\n\n  return (\n    <div className=\"relative flex-1 overflow-hidden bg-white dark:bg-[#100e14]\">\n      {!(apiKey || serverSideApiKeyIsSet) ? (\n        <div className=\"mx-auto flex h-full w-[300px] flex-col justify-center space-y-6 sm:w-[600px]\">\n          <div className=\"text-center text-4xl font-bold text-black dark:text-white\">\n            LlamaGPT\n          </div>\n          <div className=\"text-center text-lg text-black dark:text-white\">\n            <div className=\"mb-8\">LlamaGPT  100% unaffiliated with OpenAI.</div>\n          </div>\n          <div className=\"text-center text-gray-500 dark:text-gray-400\">\n            <div className=\"mb-2\">\n              LlamaGPT allows you to self-host your own LLM.\n            </div>\n          </div>\n        </div>\n      ) : modelError ? (\n        <ErrorMessageDiv error={modelError} />\n      ) : (\n        <>\n          <div\n            className=\"max-h-full overflow-x-hidden\"\n            ref={chatContainerRef}\n            onScroll={handleScroll}\n          >\n            {selectedConversation?.messages.length === 0 ? (\n              <>\n                <div className=\"mx-auto flex flex-col space-y-5 md:space-y-10 px-3 pt-5 md:pt-12 sm:max-w-[600px]\">\n                  <div className=\"text-center text-3xl font-semibold text-gray-800 dark:text-gray-100\">\n                    {models.length === 0 ? (\n                      <div>\n                        <Spinner size=\"16px\" className=\"mx-auto\" />\n                      </div>\n                    ) : (\n                      'LlamaGPT'\n                    )}\n                  </div>\n\n                  {models.length > 0 && (\n                    <div className=\"flex h-full flex-col space-y-4 rounded-lg border border-neutral-600 p-4 dark:border-neutral-700\">\n                      <ModelSelect />\n\n                      <SystemPrompt\n                        conversation={selectedConversation}\n                        prompts={prompts}\n                        onChangePrompt={(prompt) =>\n                          handleUpdateConversation(selectedConversation, {\n                            key: 'prompt',\n                            value: prompt,\n                          })\n                        }\n                      />\n\n                      <TemperatureSlider\n                        label={t('Temperature')}\n                        onChangeTemperature={(temperature) =>\n                          handleUpdateConversation(selectedConversation, {\n                            key: 'temperature',\n                            value: temperature,\n                          })\n                        }\n                      />\n                    </div>\n                  )}\n                </div>\n              </>\n            ) : (\n              <>\n                <div className=\"sticky top-0 z-10 flex justify-center border border-b-neutral-300 bg-neutral-100 py-2 text-sm text-neutral-500 dark:border-none dark:bg-[#161519] dark:text-neutral-200\">\n                  {t('Model')}: {selectedConversation?.model.name} | {t('Temp')}\n                  : {selectedConversation?.temperature} |\n                  <button\n                    className=\"ml-2 cursor-pointer hover:opacity-50\"\n                    onClick={handleSettings}\n                  >\n                    <IconSettings size={18} />\n                  </button>\n                  <button\n                    className=\"ml-2 cursor-pointer hover:opacity-50\"\n                    onClick={onClearAll}\n                  >\n                    <IconClearAll size={18} />\n                  </button>\n                </div>\n                {showSettings && (\n                  <div className=\"flex flex-col space-y-10 md:mx-auto md:max-w-xl md:gap-6 md:py-3 md:pt-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl\">\n                    <div className=\"flex h-full flex-col space-y-4 border-b border-neutral-600 p-4 dark:border-neutral-700 md:rounded-lg md:border\">\n                      <ModelSelect />\n                    </div>\n                  </div>\n                )}\n\n                {selectedConversation?.messages.map((message, index) => (\n                  <MemoizedChatMessage\n                    key={index}\n                    message={message}\n                    messageIndex={index}\n                    onEdit={(editedMessage) => {\n                      setCurrentMessage(editedMessage);\n                      // discard edited message and the ones that come after then resend\n                      handleSend(\n                        editedMessage,\n                        selectedConversation?.messages.length - index,\n                      );\n                    }}\n                  />\n                ))}\n\n                {loading && <ChatLoader />}\n\n                <div\n                  className=\"h-[162px] bg-white dark:bg-transparent\"\n                  ref={messagesEndRef}\n                />\n              </>\n            )}\n          </div>\n\n          <ChatInput\n            stopConversationRef={stopConversationRef}\n            textareaRef={textareaRef}\n            onSend={(message, plugin) => {\n              setCurrentMessage(message);\n              handleSend(message, 0, plugin);\n            }}\n            onScrollDownClick={handleScrollDown}\n            onRegenerate={() => {\n              if (currentMessage) {\n                handleSend(currentMessage, 2, null);\n              }\n            }}\n            showScrollDownButton={showScrollDownButton}\n          />\n        </>\n      )}\n    </div>\n  );\n});\nChat.displayName = 'Chat';\n"
  },
  {
    "path": "ui/components/Chat/ChatInput.tsx",
    "content": "import {\n  IconArrowDown,\n  IconBolt,\n  IconBrandGoogle,\n  IconPlayerStop,\n  IconRepeat,\n  IconSend,\n} from '@tabler/icons-react';\nimport {\n  KeyboardEvent,\n  MutableRefObject,\n  useCallback,\n  useContext,\n  useEffect,\n  useRef,\n  useState,\n} from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { Message } from '@/types/chat';\nimport { Plugin } from '@/types/plugin';\nimport { Prompt } from '@/types/prompt';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport { PluginSelect } from './PluginSelect';\nimport { PromptList } from './PromptList';\nimport { VariableModal } from './VariableModal';\n\ninterface Props {\n  onSend: (message: Message, plugin: Plugin | null) => void;\n  onRegenerate: () => void;\n  onScrollDownClick: () => void;\n  stopConversationRef: MutableRefObject<boolean>;\n  textareaRef: MutableRefObject<HTMLTextAreaElement | null>;\n  showScrollDownButton: boolean;\n}\n\nexport const ChatInput = ({\n  onSend,\n  onRegenerate,\n  onScrollDownClick,\n  stopConversationRef,\n  textareaRef,\n  showScrollDownButton,\n}: Props) => {\n  const { t } = useTranslation('chat');\n\n  const {\n    state: { selectedConversation, messageIsStreaming, prompts },\n\n    dispatch: homeDispatch,\n  } = useContext(HomeContext);\n\n  const [content, setContent] = useState<string>();\n  const [isTyping, setIsTyping] = useState<boolean>(false);\n  const [showPromptList, setShowPromptList] = useState(false);\n  const [activePromptIndex, setActivePromptIndex] = useState(0);\n  const [promptInputValue, setPromptInputValue] = useState('');\n  const [variables, setVariables] = useState<string[]>([]);\n  const [isModalVisible, setIsModalVisible] = useState(false);\n  const [showPluginSelect, setShowPluginSelect] = useState(false);\n  const [plugin, setPlugin] = useState<Plugin | null>(null);\n\n  const promptListRef = useRef<HTMLUListElement | null>(null);\n\n  const filteredPrompts = prompts.filter((prompt) =>\n    prompt.name.toLowerCase().includes(promptInputValue.toLowerCase()),\n  );\n\n  const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n    const value = e.target.value;\n    const maxLength = selectedConversation?.model.maxLength;\n\n    if (maxLength && value.length > maxLength) {\n      alert(\n        t(\n          `Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.`,\n          { maxLength, valueLength: value.length },\n        ),\n      );\n      return;\n    }\n\n    setContent(value);\n    updatePromptListVisibility(value);\n  };\n\n  const handleSend = () => {\n    if (messageIsStreaming) {\n      return;\n    }\n\n    if (!content) {\n      alert(t('Please enter a message'));\n      return;\n    }\n\n    onSend({ role: 'user', content }, plugin);\n    setContent('');\n    setPlugin(null);\n\n    if (window.innerWidth < 640 && textareaRef && textareaRef.current) {\n      textareaRef.current.blur();\n    }\n  };\n\n  const handleStopConversation = () => {\n    stopConversationRef.current = true;\n    setTimeout(() => {\n      stopConversationRef.current = false;\n    }, 1000);\n  };\n\n  const isMobile = () => {\n    const userAgent =\n      typeof window.navigator === 'undefined' ? '' : navigator.userAgent;\n    const mobileRegex =\n      /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i;\n    return mobileRegex.test(userAgent);\n  };\n\n  const handleInitModal = () => {\n    const selectedPrompt = filteredPrompts[activePromptIndex];\n    if (selectedPrompt) {\n      setContent((prevContent) => {\n        const newContent = prevContent?.replace(\n          /\\/\\w*$/,\n          selectedPrompt.content,\n        );\n        return newContent;\n      });\n      handlePromptSelect(selectedPrompt);\n    }\n    setShowPromptList(false);\n  };\n\n  const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n    if (showPromptList) {\n      if (e.key === 'ArrowDown') {\n        e.preventDefault();\n        setActivePromptIndex((prevIndex) =>\n          prevIndex < prompts.length - 1 ? prevIndex + 1 : prevIndex,\n        );\n      } else if (e.key === 'ArrowUp') {\n        e.preventDefault();\n        setActivePromptIndex((prevIndex) =>\n          prevIndex > 0 ? prevIndex - 1 : prevIndex,\n        );\n      } else if (e.key === 'Tab') {\n        e.preventDefault();\n        setActivePromptIndex((prevIndex) =>\n          prevIndex < prompts.length - 1 ? prevIndex + 1 : 0,\n        );\n      } else if (e.key === 'Enter') {\n        e.preventDefault();\n        handleInitModal();\n      } else if (e.key === 'Escape') {\n        e.preventDefault();\n        setShowPromptList(false);\n      } else {\n        setActivePromptIndex(0);\n      }\n    } else if (e.key === 'Enter' && !isTyping && !isMobile() && !e.shiftKey) {\n      e.preventDefault();\n      handleSend();\n    } else if (e.key === '/' && e.metaKey) {\n      e.preventDefault();\n      setShowPluginSelect(!showPluginSelect);\n    }\n  };\n\n  const parseVariables = (content: string) => {\n    const regex = /{{(.*?)}}/g;\n    const foundVariables = [];\n    let match;\n\n    while ((match = regex.exec(content)) !== null) {\n      foundVariables.push(match[1]);\n    }\n\n    return foundVariables;\n  };\n\n  const updatePromptListVisibility = useCallback((text: string) => {\n    const match = text.match(/\\/\\w*$/);\n\n    if (match) {\n      setShowPromptList(true);\n      setPromptInputValue(match[0].slice(1));\n    } else {\n      setShowPromptList(false);\n      setPromptInputValue('');\n    }\n  }, []);\n\n  const handlePromptSelect = (prompt: Prompt) => {\n    const parsedVariables = parseVariables(prompt.content);\n    setVariables(parsedVariables);\n\n    if (parsedVariables.length > 0) {\n      setIsModalVisible(true);\n    } else {\n      setContent((prevContent) => {\n        const updatedContent = prevContent?.replace(/\\/\\w*$/, prompt.content);\n        return updatedContent;\n      });\n      updatePromptListVisibility(prompt.content);\n    }\n  };\n\n  const handleSubmit = (updatedVariables: string[]) => {\n    const newContent = content?.replace(/{{(.*?)}}/g, (match, variable) => {\n      const index = variables.indexOf(variable);\n      return updatedVariables[index];\n    });\n\n    setContent(newContent);\n\n    if (textareaRef && textareaRef.current) {\n      textareaRef.current.focus();\n    }\n  };\n\n  useEffect(() => {\n    if (promptListRef.current) {\n      promptListRef.current.scrollTop = activePromptIndex * 30;\n    }\n  }, [activePromptIndex]);\n\n  useEffect(() => {\n    if (textareaRef && textareaRef.current) {\n      textareaRef.current.style.height = 'inherit';\n      textareaRef.current.style.height = `${textareaRef.current?.scrollHeight}px`;\n      textareaRef.current.style.overflow = `${\n        textareaRef?.current?.scrollHeight > 400 ? 'auto' : 'hidden'\n      }`;\n    }\n  }, [content]);\n\n  useEffect(() => {\n    const handleOutsideClick = (e: MouseEvent) => {\n      if (\n        promptListRef.current &&\n        !promptListRef.current.contains(e.target as Node)\n      ) {\n        setShowPromptList(false);\n      }\n    };\n\n    window.addEventListener('click', handleOutsideClick);\n\n    return () => {\n      window.removeEventListener('click', handleOutsideClick);\n    };\n  }, []);\n\n  return (\n    <div className=\"absolute bottom-0 left-0 w-full border-transparent bg-gradient-to-b from-transparent via-white to-white pt-6 dark:border-white/20 dark:via-[#121322] dark:to-[#0f0a28] md:pt-2\">\n      <div className=\"stretch mx-2 mt-4 flex flex-row gap-3 last:mb-2 md:mx-4 md:mt-[52px] md:last:mb-6 lg:mx-auto lg:max-w-3xl\">\n        {messageIsStreaming && (\n          <button\n            className=\"absolute top-0 left-0 right-0 mx-auto mb-3 flex w-fit items-center gap-3 rounded border border-neutral-600 bg-white py-2 px-4 text-black hover:opacity-50 dark:border-neutral-700 dark:bg-transparent dark:text-white md:mb-0 md:mt-2\"\n            onClick={handleStopConversation}\n          >\n            <IconPlayerStop size={16} /> {t('Stop Generating')}\n          </button>\n        )}\n\n        {!messageIsStreaming &&\n          selectedConversation &&\n          selectedConversation.messages.length > 0 && (\n            <button\n              className=\"absolute top-0 left-0 right-0 mx-auto mb-3 flex w-fit items-center gap-3 rounded border border-neutral-600 bg-white py-2 px-4 text-black hover:opacity-50 dark:border-neutral-700 dark:bg-transparent dark:text-white md:mb-0 md:mt-2\"\n              onClick={onRegenerate}\n            >\n              <IconRepeat size={16} /> {t('Regenerate response')}\n            </button>\n          )}\n\n        <div className=\"relative mx-2 flex w-full flex-grow flex-col rounded-md border border-black/10 bg-white shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:border-gray-900/50 dark:bg-[#27242e] dark:text-white dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] sm:mx-4\">\n          <button\n            className=\"absolute left-2 top-2 rounded-sm p-1 text-neutral-800 opacity-60 hover:bg-neutral-200 hover:text-neutral-900 dark:bg-opacity-50 dark:text-neutral-100 dark:hover:text-neutral-200\"\n            onClick={() => setShowPluginSelect(!showPluginSelect)}\n            onKeyDown={(e) => {}}\n          >\n            {plugin ? <IconBrandGoogle size={20} /> : <IconBolt size={20} />}\n          </button>\n\n          {showPluginSelect && (\n            <div className=\"absolute left-0 bottom-14 rounded bg-white dark:bg-transparent\">\n              <PluginSelect\n                plugin={plugin}\n                onKeyDown={(e: any) => {\n                  if (e.key === 'Escape') {\n                    e.preventDefault();\n                    setShowPluginSelect(false);\n                    textareaRef.current?.focus();\n                  }\n                }}\n                onPluginChange={(plugin: Plugin) => {\n                  setPlugin(plugin);\n                  setShowPluginSelect(false);\n\n                  if (textareaRef && textareaRef.current) {\n                    textareaRef.current.focus();\n                  }\n                }}\n              />\n            </div>\n          )}\n\n          <textarea\n            ref={textareaRef}\n            className=\"m-0 w-full resize-none border-0 bg-transparent p-0 py-2 pr-8 pl-10 text-black dark:bg-transparent dark:text-white md:py-3 md:pl-10\"\n            style={{\n              resize: 'none',\n              bottom: `${textareaRef?.current?.scrollHeight}px`,\n              maxHeight: '400px',\n              overflow: `${\n                textareaRef.current && textareaRef.current.scrollHeight > 400\n                  ? 'auto'\n                  : 'hidden'\n              }`,\n            }}\n            placeholder={\n              t('Type a message or type \"/\" to select a prompt...') || ''\n            }\n            value={content}\n            rows={1}\n            onCompositionStart={() => setIsTyping(true)}\n            onCompositionEnd={() => setIsTyping(false)}\n            onChange={handleChange}\n            onKeyDown={handleKeyDown}\n          />\n\n          <button\n            className=\"absolute right-2 top-2 rounded-sm p-1 text-neutral-800 opacity-60 hover:bg-neutral-200 hover:text-neutral-900 dark:bg-opacity-50 dark:text-neutral-100 dark:hover:text-neutral-200\"\n            onClick={handleSend}\n          >\n            {messageIsStreaming ? (\n              <div className=\"h-4 w-4 animate-spin rounded-full border-t-2 border-neutral-800 opacity-60 dark:border-neutral-100\"></div>\n            ) : (\n              <IconSend size={18} />\n            )}\n          </button>\n\n          {showScrollDownButton && (\n            <div className=\"absolute bottom-12 right-0 lg:bottom-0 lg:-right-10\">\n              <button\n                className=\"flex h-7 w-7 items-center justify-center rounded-full bg-neutral-300 text-gray-800 shadow-md hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-neutral-200\"\n                onClick={onScrollDownClick}\n              >\n                <IconArrowDown size={18} />\n              </button>\n            </div>\n          )}\n\n          {showPromptList && filteredPrompts.length > 0 && (\n            <div className=\"absolute bottom-12 w-full\">\n              <PromptList\n                activePromptIndex={activePromptIndex}\n                prompts={filteredPrompts}\n                onSelect={handleInitModal}\n                onMouseOver={setActivePromptIndex}\n                promptListRef={promptListRef}\n              />\n            </div>\n          )}\n\n          {isModalVisible && (\n            <VariableModal\n              prompt={filteredPrompts[activePromptIndex]}\n              variables={variables}\n              onSubmit={handleSubmit}\n              onClose={() => setIsModalVisible(false)}\n            />\n          )}\n        </div>\n      </div>\n      {/* <div className=\"px-3 pt-2 pb-3 text-center text-[12px] text-black/50 dark:text-white/50 md:px-4 md:pt-3 md:pb-6\">\n        <a\n          href=\"https://github.com/mckaywrigley/chatbot-ui\"\n          target=\"_blank\"\n          rel=\"noreferrer\"\n          className=\"underline\"\n        >\n          ChatBot UI\n        </a>\n        .{' '}\n        {t(\n          \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\",\n        )}\n      </div> */}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/ChatLoader.tsx",
    "content": "import { IconRobot } from '@tabler/icons-react';\nimport { FC } from 'react';\n\ninterface Props { }\n\nexport const ChatLoader: FC<Props> = () => {\n  return (\n    <div\n      className=\"group border-b border-black/10 bg-gray-50 text-gray-800 dark:border-gray-800/50 dark:bg-transparent dark:text-gray-100\"\n      style={{ overflowWrap: 'anywhere' }}\n    >\n      <div className=\"m-auto flex gap-4 p-4 text-base md:max-w-2xl md:gap-6 md:py-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl\">\n        <div className=\"min-w-[40px] items-end\">\n          <IconRobot size={30} />\n        </div>\n        <span className=\"animate-pulse cursor-default mt-1\">▍</span>\n      </div>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/ChatMessage.tsx",
    "content": "import {\n  IconCheck,\n  IconCopy,\n  IconEdit,\n  IconRobot,\n  IconTrash,\n  IconUser,\n} from '@tabler/icons-react';\nimport { FC, memo, useContext, useEffect, useRef, useState } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { updateConversation } from '@/utils/app/conversation';\n\nimport { Message } from '@/types/chat';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport { CodeBlock } from '../Markdown/CodeBlock';\nimport { MemoizedReactMarkdown } from '../Markdown/MemoizedReactMarkdown';\n\nimport rehypeMathjax from 'rehype-mathjax';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\n\nexport interface Props {\n  message: Message;\n  messageIndex: number;\n  onEdit?: (editedMessage: Message) => void\n}\n\nexport const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) => {\n  const { t } = useTranslation('chat');\n\n  const {\n    state: { selectedConversation, conversations, currentMessage, messageIsStreaming },\n    dispatch: homeDispatch,\n  } = useContext(HomeContext);\n\n  const [isEditing, setIsEditing] = useState<boolean>(false);\n  const [isTyping, setIsTyping] = useState<boolean>(false);\n  const [messageContent, setMessageContent] = useState(message.content);\n  const [messagedCopied, setMessageCopied] = useState(false);\n\n  const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n  const toggleEditing = () => {\n    setIsEditing(!isEditing);\n  };\n\n  const handleInputChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n    setMessageContent(event.target.value);\n    if (textareaRef.current) {\n      textareaRef.current.style.height = 'inherit';\n      textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n    }\n  };\n\n  const handleEditMessage = () => {\n    if (message.content != messageContent) {\n      if (selectedConversation && onEdit) {\n        onEdit({ ...message, content: messageContent });\n      }\n    }\n    setIsEditing(false);\n  };\n\n  const handleDeleteMessage = () => {\n    if (!selectedConversation) return;\n\n    const { messages } = selectedConversation;\n    const findIndex = messages.findIndex((elm) => elm === message);\n\n    if (findIndex < 0) return;\n\n    if (\n      findIndex < messages.length - 1 &&\n      messages[findIndex + 1].role === 'assistant'\n    ) {\n      messages.splice(findIndex, 2);\n    } else {\n      messages.splice(findIndex, 1);\n    }\n    const updatedConversation = {\n      ...selectedConversation,\n      messages,\n    };\n\n    const { single, all } = updateConversation(\n      updatedConversation,\n      conversations,\n    );\n    homeDispatch({ field: 'selectedConversation', value: single });\n    homeDispatch({ field: 'conversations', value: all });\n  };\n\n  const handlePressEnter = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n    if (e.key === 'Enter' && !isTyping && !e.shiftKey) {\n      e.preventDefault();\n      handleEditMessage();\n    }\n  };\n\n  const copyOnClick = () => {\n    // fallback to allow copying to clipboard over http\n    const copyToClipboardFallback = (text: string) => {\n      let textArea = document.createElement(\"textarea\");\n      textArea.value = text;\n      textArea.style.position = \"absolute\";\n      textArea.style.opacity = \"0\";\n      document.body.appendChild(textArea);\n      textArea.select();\n      document.execCommand(\"copy\");\n      textArea.remove();\n    };\n  \n    if (navigator.clipboard && window.isSecureContext) {\n      navigator.clipboard.writeText(message.content);\n    } else {\n      copyToClipboardFallback(message.content);\n    }\n  \n    setMessageCopied(true);\n    setTimeout(() => {\n      setMessageCopied(false);\n    }, 2000);\n  };\n  \n\n  useEffect(() => {\n    setMessageContent(message.content);\n  }, [message.content]);\n\n\n  useEffect(() => {\n    if (textareaRef.current) {\n      textareaRef.current.style.height = 'inherit';\n      textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n    }\n  }, [isEditing]);\n\n  return (\n    <div\n      className={`group md:px-4 ${\n        message.role === 'assistant'\n          ? 'border-b border-black/10 bg-gray-50 text-gray-800 dark:border-gray-800/50 dark:bg-transparent dark:text-gray-100'\n          : 'border-b border-black/10 bg-white text-gray-800 dark:border-gray-800/50 dark:bg-transparent dark:text-gray-100'\n      }`}\n      style={{ overflowWrap: 'anywhere' }}\n    >\n      <div className=\"relative m-auto flex p-4 text-base md:max-w-2xl md:gap-6 md:py-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl\">\n        <div className=\"min-w-[40px] text-right font-bold\">\n          {message.role === 'assistant' ? (\n            <IconRobot size={30} />\n          ) : (\n            <IconUser size={30} />\n          )}\n        </div>\n\n        <div className=\"prose mt-[-2px] w-full dark:prose-invert\">\n          {message.role === 'user' ? (\n            <div className=\"flex w-full\">\n              {isEditing ? (\n                <div className=\"flex w-full flex-col\">\n                  <textarea\n                    ref={textareaRef}\n                    className=\"w-full resize-none whitespace-pre-wrap border-none dark:bg-[#1d1c21]\"\n                    value={messageContent}\n                    onChange={handleInputChange}\n                    onKeyDown={handlePressEnter}\n                    onCompositionStart={() => setIsTyping(true)}\n                    onCompositionEnd={() => setIsTyping(false)}\n                    style={{\n                      fontFamily: 'inherit',\n                      fontSize: 'inherit',\n                      lineHeight: 'inherit',\n                      padding: '0',\n                      margin: '0',\n                      overflow: 'hidden',\n                    }}\n                  />\n\n                  <div className=\"mt-10 flex justify-center space-x-4\">\n                    <button\n                      className=\"h-[40px] rounded-md bg-blue-500 px-4 py-1 text-sm font-medium text-white enabled:hover:bg-blue-600 disabled:opacity-50\"\n                      onClick={handleEditMessage}\n                      disabled={messageContent.trim().length <= 0}\n                    >\n                      {t('Save & Submit')}\n                    </button>\n                    <button\n                      className=\"h-[40px] rounded-md border border-neutral-300 px-4 py-1 text-sm font-medium text-neutral-700 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800\"\n                      onClick={() => {\n                        setMessageContent(message.content);\n                        setIsEditing(false);\n                      }}\n                    >\n                      {t('Cancel')}\n                    </button>\n                  </div>\n                </div>\n              ) : (\n                <div className=\"prose whitespace-pre-wrap dark:prose-invert flex-1\">\n                  {message.content}\n                </div>\n              )}\n\n              {!isEditing && (\n                <div className=\"md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start\">\n                  <button\n                    className=\"invisible group-hover:visible focus:visible text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300\"\n                    onClick={toggleEditing}\n                  >\n                    <IconEdit size={20} />\n                  </button>\n                  <button\n                    className=\"invisible group-hover:visible focus:visible text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300\"\n                    onClick={handleDeleteMessage}\n                  >\n                    <IconTrash size={20} />\n                  </button>\n                </div>\n              )}\n            </div>\n          ) : (\n            <div className=\"flex flex-row\">\n              <MemoizedReactMarkdown\n                className=\"prose dark:prose-invert flex-1\"\n                remarkPlugins={[remarkGfm, remarkMath]}\n                rehypePlugins={[rehypeMathjax]}\n                components={{\n                  code({ node, inline, className, children, ...props }) {\n                    if (children.length) {\n                      if (children[0] == '▍') {\n                        return <span className=\"animate-pulse cursor-default mt-1\">▍</span>\n                      }\n\n                      children[0] = (children[0] as string).replace(\"`▍`\", \"▍\")\n                    }\n\n                    const match = /language-(\\w+)/.exec(className || '');\n\n                    return !inline ? (\n                      <CodeBlock\n                        key={Math.random()}\n                        language={(match && match[1]) || ''}\n                        value={String(children).replace(/\\n$/, '')}\n                        {...props}\n                      />\n                    ) : (\n                      <code className={className} {...props}>\n                        {children}\n                      </code>\n                    );\n                  },\n                  table({ children }) {\n                    return (\n                      <table className=\"border-collapse border border-black px-3 py-1 dark:border-white\">\n                        {children}\n                      </table>\n                    );\n                  },\n                  th({ children }) {\n                    return (\n                      <th className=\"break-words border border-black bg-gray-500 px-3 py-1 text-white dark:border-white\">\n                        {children}\n                      </th>\n                    );\n                  },\n                  td({ children }) {\n                    return (\n                      <td className=\"break-words border border-black px-3 py-1 dark:border-white\">\n                        {children}\n                      </td>\n                    );\n                  },\n                }}\n              >\n                {`${message.content}${\n                  messageIsStreaming && messageIndex == (selectedConversation?.messages.length ?? 0) - 1 ? '`▍`' : ''\n                }`}\n              </MemoizedReactMarkdown>\n\n              <div className=\"md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start\">\n                {messagedCopied ? (\n                  <IconCheck\n                    size={20}\n                    className=\"text-green-500 dark:text-green-400\"\n                  />\n                ) : (\n                  <button\n                    className=\"invisible group-hover:visible focus:visible text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300\"\n                    onClick={copyOnClick}\n                  >\n                    <IconCopy size={20} />\n                  </button>\n                )}\n              </div>\n            </div>\n          )}\n        </div>\n      </div>\n    </div>\n  );\n});\nChatMessage.displayName = 'ChatMessage';\n"
  },
  {
    "path": "ui/components/Chat/ErrorMessageDiv.tsx",
    "content": "import { IconCircleX } from '@tabler/icons-react';\nimport { FC } from 'react';\n\nimport { ErrorMessage } from '@/types/error';\n\ninterface Props {\n  error: ErrorMessage;\n}\n\nexport const ErrorMessageDiv: FC<Props> = ({ error }) => {\n  return (\n    <div className=\"mx-6 flex h-full flex-col items-center justify-center text-red-500\">\n      <div className=\"mb-5\">\n        <IconCircleX size={36} />\n      </div>\n      <div className=\"mb-3 text-2xl font-medium\">{error.title}</div>\n      {error.messageLines.map((line, index) => (\n        <div key={index} className=\"text-center\">\n          {' '}\n          {line}{' '}\n        </div>\n      ))}\n      <div className=\"mt-4 text-xs opacity-50 dark:text-red-400\">\n        {error.code ? <i>Code: {error.code}</i> : ''}\n      </div>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/MemoizedChatMessage.tsx",
    "content": "import { FC, memo } from \"react\";\nimport { ChatMessage, Props } from \"./ChatMessage\";\n\nexport const MemoizedChatMessage: FC<Props> = memo(\n    ChatMessage,\n    (prevProps, nextProps) => (\n        prevProps.message.content === nextProps.message.content\n    )\n);\n"
  },
  {
    "path": "ui/components/Chat/ModelSelect.tsx",
    "content": "import { IconExternalLink } from '@tabler/icons-react';\nimport { useContext } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { OpenAIModel } from '@/types/openai';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nexport const ModelSelect = () => {\n  const { t } = useTranslation('chat');\n\n  const {\n    state: { selectedConversation, models, defaultModelId },\n    handleUpdateConversation,\n    dispatch: homeDispatch,\n  } = useContext(HomeContext);\n\n  const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {\n    selectedConversation &&\n      handleUpdateConversation(selectedConversation, {\n        key: 'model',\n        value: models.find(\n          (model) => model.id === e.target.value,\n        ) as OpenAIModel,\n      });\n  };\n\n  return (\n    <div className=\"flex flex-col\">\n      <label className=\"mb-2 text-left text-neutral-700 dark:text-neutral-400\">\n        {t('Model')}\n      </label>\n      <div className=\"w-full rounded-lg border border-neutral-600 bg-transparent pr-2 text-neutral-900 dark:border-neutral-700 dark:text-white\">\n        <select\n          className=\"w-full bg-transparent p-2\"\n          placeholder={t('Select a model') || ''}\n          value={selectedConversation?.model?.id || defaultModelId}\n          onChange={handleChange}\n        >\n          {models.map((model) => (\n            <option\n              key={model.id}\n              value={model.id}\n              className=\"dark:bg-[#1d1c21] dark:text-white\"\n            >\n              {model.id === defaultModelId\n                ? `Default (${model.name})`\n                : model.name}\n            </option>\n          ))}\n        </select>\n      </div>\n      {/* <div className=\"w-full mt-3 text-left text-neutral-700 dark:text-neutral-400 flex items-center\">\n        <a\n          href=\"https://platform.openai.com/account/usage\"\n          target=\"_blank\"\n          className=\"flex items-center\"\n        >\n          <IconExternalLink size={18} className={'inline mr-1'} />\n          {t('View Account Usage')}\n        </a>\n      </div> */}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/PluginSelect.tsx",
    "content": "import { FC, useEffect, useRef } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { Plugin, PluginList } from '@/types/plugin';\n\ninterface Props {\n  plugin: Plugin | null;\n  onPluginChange: (plugin: Plugin) => void;\n  onKeyDown: (e: React.KeyboardEvent<HTMLSelectElement>) => void;\n}\n\nexport const PluginSelect: FC<Props> = ({\n  plugin,\n  onPluginChange,\n  onKeyDown,\n}) => {\n  const { t } = useTranslation('chat');\n\n  const selectRef = useRef<HTMLSelectElement>(null);\n\n  const handleKeyDown = (e: React.KeyboardEvent<HTMLSelectElement>) => {\n    const selectElement = selectRef.current;\n    const optionCount = selectElement?.options.length || 0;\n\n    if (e.key === '/' && e.metaKey) {\n      e.preventDefault();\n      if (selectElement) {\n        selectElement.selectedIndex =\n          (selectElement.selectedIndex + 1) % optionCount;\n        selectElement.dispatchEvent(new Event('change'));\n      }\n    } else if (e.key === '/' && e.shiftKey && e.metaKey) {\n      e.preventDefault();\n      if (selectElement) {\n        selectElement.selectedIndex =\n          (selectElement.selectedIndex - 1 + optionCount) % optionCount;\n        selectElement.dispatchEvent(new Event('change'));\n      }\n    } else if (e.key === 'Enter') {\n      e.preventDefault();\n      if (selectElement) {\n        selectElement.dispatchEvent(new Event('change'));\n      }\n\n      onPluginChange(\n        PluginList.find(\n          (plugin) =>\n            plugin.name === selectElement?.selectedOptions[0].innerText,\n        ) as Plugin,\n      );\n    } else {\n      onKeyDown(e);\n    }\n  };\n\n  useEffect(() => {\n    if (selectRef.current) {\n      selectRef.current.focus();\n    }\n  }, []);\n\n  return (\n    <div className=\"flex flex-col\">\n      <div className=\"mb-1 w-full rounded border border-neutral-600 bg-transparent pr-2 text-neutral-900 dark:border-neutral-700 dark:text-white\">\n        <select\n          ref={selectRef}\n          className=\"w-full cursor-pointer bg-transparent p-2\"\n          placeholder={t('Select a plugin') || ''}\n          value={plugin?.id || ''}\n          onChange={(e) => {\n            onPluginChange(\n              PluginList.find(\n                (plugin) => plugin.id === e.target.value,\n              ) as Plugin,\n            );\n          }}\n          onKeyDown={(e) => {\n            handleKeyDown(e);\n          }}\n        >\n          <option\n            key=\"chatgpt\"\n            value=\"chatgpt\"\n            className=\"dark:bg-[#1d1c21] dark:text-white\"\n          >\n            ChatGPT\n          </option>\n\n          {PluginList.map((plugin) => (\n            <option\n              key={plugin.id}\n              value={plugin.id}\n              className=\"dark:bg-[#1d1c21] dark:text-white\"\n            >\n              {plugin.name}\n            </option>\n          ))}\n        </select>\n      </div>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/PromptList.tsx",
    "content": "import { FC, MutableRefObject } from 'react';\n\nimport { Prompt } from '@/types/prompt';\n\ninterface Props {\n  prompts: Prompt[];\n  activePromptIndex: number;\n  onSelect: () => void;\n  onMouseOver: (index: number) => void;\n  promptListRef: MutableRefObject<HTMLUListElement | null>;\n}\n\nexport const PromptList: FC<Props> = ({\n  prompts,\n  activePromptIndex,\n  onSelect,\n  onMouseOver,\n  promptListRef,\n}) => {\n  return (\n    <ul\n      ref={promptListRef}\n      className=\"z-10 max-h-52 w-full overflow-scroll rounded border border-black/10 bg-white shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:border-neutral-600 dark:bg-[#1d1c21] dark:text-white dark:shadow-[0_0_15px_rgba(0,0,0,0.10)]\"\n    >\n      {prompts.map((prompt, index) => (\n        <li\n          key={prompt.id}\n          className={`${\n            index === activePromptIndex\n              ? 'bg-gray-200 dark:bg-[#161519] dark:text-black'\n              : ''\n          } cursor-pointer px-3 py-2 text-sm text-black dark:text-white`}\n          onClick={(e) => {\n            e.preventDefault();\n            e.stopPropagation();\n            onSelect();\n          }}\n          onMouseEnter={() => onMouseOver(index)}\n        >\n          {prompt.name}\n        </li>\n      ))}\n    </ul>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/Regenerate.tsx",
    "content": "import { IconRefresh } from '@tabler/icons-react';\nimport { FC } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\ninterface Props {\n  onRegenerate: () => void;\n}\n\nexport const Regenerate: FC<Props> = ({ onRegenerate }) => {\n  const { t } = useTranslation('chat');\n  return (\n    <div className=\"fixed bottom-4 left-0 right-0 ml-auto mr-auto w-full px-2 sm:absolute sm:bottom-8 sm:left-[280px] sm:w-1/2 lg:left-[200px]\">\n      <div className=\"mb-4 text-center text-red-500\">\n        {t('Sorry, there was an error.')}\n      </div>\n      <button\n        className=\"flex h-12 gap-2 w-full items-center justify-center rounded-lg border border-b-neutral-300 bg-neutral-100 text-sm font-semibold text-neutral-500 dark:border-none dark:bg-[#232228] dark:text-neutral-200\"\n        onClick={onRegenerate}\n      >\n        <IconRefresh />\n        <div>{t('Regenerate response')}</div>\n      </button>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/SystemPrompt.tsx",
    "content": "import {\n  FC,\n  KeyboardEvent,\n  useCallback,\n  useEffect,\n  useRef,\n  useState,\n} from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { DEFAULT_SYSTEM_PROMPT } from '@/utils/app/const';\n\nimport { Conversation } from '@/types/chat';\nimport { Prompt } from '@/types/prompt';\n\nimport { PromptList } from './PromptList';\nimport { VariableModal } from './VariableModal';\n\ninterface Props {\n  conversation: Conversation;\n  prompts: Prompt[];\n  onChangePrompt: (prompt: string) => void;\n}\n\nexport const SystemPrompt: FC<Props> = ({\n  conversation,\n  prompts,\n  onChangePrompt,\n}) => {\n  const { t } = useTranslation('chat');\n\n  const [value, setValue] = useState<string>('');\n  const [activePromptIndex, setActivePromptIndex] = useState(0);\n  const [showPromptList, setShowPromptList] = useState(false);\n  const [promptInputValue, setPromptInputValue] = useState('');\n  const [variables, setVariables] = useState<string[]>([]);\n  const [isModalVisible, setIsModalVisible] = useState(false);\n\n  const textareaRef = useRef<HTMLTextAreaElement>(null);\n  const promptListRef = useRef<HTMLUListElement | null>(null);\n\n  const filteredPrompts = prompts.filter((prompt) =>\n    prompt.name.toLowerCase().includes(promptInputValue.toLowerCase()),\n  );\n\n  const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n    const value = e.target.value;\n    const maxLength = conversation.model.maxLength;\n\n    if (value.length > maxLength) {\n      alert(\n        t(\n          `Prompt limit is {{maxLength}} characters. You have entered {{valueLength}} characters.`,\n          { maxLength, valueLength: value.length },\n        ),\n      );\n      return;\n    }\n\n    setValue(value);\n    updatePromptListVisibility(value);\n\n    if (value.length > 0) {\n      onChangePrompt(value);\n    }\n  };\n\n  const handleInitModal = () => {\n    const selectedPrompt = filteredPrompts[activePromptIndex];\n    setValue((prevVal) => {\n      const newContent = prevVal?.replace(/\\/\\w*$/, selectedPrompt.content);\n      return newContent;\n    });\n    handlePromptSelect(selectedPrompt);\n    setShowPromptList(false);\n  };\n\n  const parseVariables = (content: string) => {\n    const regex = /{{(.*?)}}/g;\n    const foundVariables = [];\n    let match;\n\n    while ((match = regex.exec(content)) !== null) {\n      foundVariables.push(match[1]);\n    }\n\n    return foundVariables;\n  };\n\n  const updatePromptListVisibility = useCallback((text: string) => {\n    const match = text.match(/\\/\\w*$/);\n\n    if (match) {\n      setShowPromptList(true);\n      setPromptInputValue(match[0].slice(1));\n    } else {\n      setShowPromptList(false);\n      setPromptInputValue('');\n    }\n  }, []);\n\n  const handlePromptSelect = (prompt: Prompt) => {\n    const parsedVariables = parseVariables(prompt.content);\n    setVariables(parsedVariables);\n\n    if (parsedVariables.length > 0) {\n      setIsModalVisible(true);\n    } else {\n      const updatedContent = value?.replace(/\\/\\w*$/, prompt.content);\n\n      setValue(updatedContent);\n      onChangePrompt(updatedContent);\n\n      updatePromptListVisibility(prompt.content);\n    }\n  };\n\n  const handleSubmit = (updatedVariables: string[]) => {\n    const newContent = value?.replace(/{{(.*?)}}/g, (match, variable) => {\n      const index = variables.indexOf(variable);\n      return updatedVariables[index];\n    });\n\n    setValue(newContent);\n    onChangePrompt(newContent);\n\n    if (textareaRef && textareaRef.current) {\n      textareaRef.current.focus();\n    }\n  };\n\n  const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n    if (showPromptList) {\n      if (e.key === 'ArrowDown') {\n        e.preventDefault();\n        setActivePromptIndex((prevIndex) =>\n          prevIndex < prompts.length - 1 ? prevIndex + 1 : prevIndex,\n        );\n      } else if (e.key === 'ArrowUp') {\n        e.preventDefault();\n        setActivePromptIndex((prevIndex) =>\n          prevIndex > 0 ? prevIndex - 1 : prevIndex,\n        );\n      } else if (e.key === 'Tab') {\n        e.preventDefault();\n        setActivePromptIndex((prevIndex) =>\n          prevIndex < prompts.length - 1 ? prevIndex + 1 : 0,\n        );\n      } else if (e.key === 'Enter') {\n        e.preventDefault();\n        handleInitModal();\n      } else if (e.key === 'Escape') {\n        e.preventDefault();\n        setShowPromptList(false);\n      } else {\n        setActivePromptIndex(0);\n      }\n    }\n  };\n\n  useEffect(() => {\n    if (textareaRef && textareaRef.current) {\n      textareaRef.current.style.height = 'inherit';\n      textareaRef.current.style.height = `${textareaRef.current?.scrollHeight}px`;\n    }\n  }, [value]);\n\n  useEffect(() => {\n    if (conversation.prompt) {\n      setValue(conversation.prompt);\n    } else {\n      setValue(DEFAULT_SYSTEM_PROMPT);\n    }\n  }, [conversation]);\n\n  useEffect(() => {\n    const handleOutsideClick = (e: MouseEvent) => {\n      if (\n        promptListRef.current &&\n        !promptListRef.current.contains(e.target as Node)\n      ) {\n        setShowPromptList(false);\n      }\n    };\n\n    window.addEventListener('click', handleOutsideClick);\n\n    return () => {\n      window.removeEventListener('click', handleOutsideClick);\n    };\n  }, []);\n\n  return (\n    <div className=\"flex flex-col\">\n      <label className=\"mb-2 text-left text-neutral-700 dark:text-neutral-400\">\n        {t('System Prompt')}\n      </label>\n      <textarea\n        ref={textareaRef}\n        className=\"w-full rounded-lg border border-neutral-600 bg-transparent px-4 py-3 text-neutral-900 dark:border-neutral-700 dark:text-neutral-100\"\n        style={{\n          resize: 'none',\n          bottom: `${textareaRef?.current?.scrollHeight}px`,\n          maxHeight: '300px',\n          overflow: `${\n            textareaRef.current && textareaRef.current.scrollHeight > 400\n              ? 'auto'\n              : 'hidden'\n          }`,\n        }}\n        placeholder={\n          t(`Enter a prompt or type \"/\" to select a prompt...`) || ''\n        }\n        value={t(value) || ''}\n        rows={1}\n        onChange={handleChange}\n        onKeyDown={handleKeyDown}\n      />\n\n      {showPromptList && filteredPrompts.length > 0 && (\n        <div>\n          <PromptList\n            activePromptIndex={activePromptIndex}\n            prompts={filteredPrompts}\n            onSelect={handleInitModal}\n            onMouseOver={setActivePromptIndex}\n            promptListRef={promptListRef}\n          />\n        </div>\n      )}\n\n      {isModalVisible && (\n        <VariableModal\n          prompt={prompts[activePromptIndex]}\n          variables={variables}\n          onSubmit={handleSubmit}\n          onClose={() => setIsModalVisible(false)}\n        />\n      )}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/Temperature.tsx",
    "content": "import { FC, useContext, useState } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { DEFAULT_TEMPERATURE } from '@/utils/app/const';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\ninterface Props {\n  label: string;\n  onChangeTemperature: (temperature: number) => void;\n}\n\nexport const TemperatureSlider: FC<Props> = ({\n  label,\n  onChangeTemperature,\n}) => {\n  const {\n    state: { conversations },\n  } = useContext(HomeContext);\n  const lastConversation = conversations[conversations.length - 1];\n  const [temperature, setTemperature] = useState(\n    lastConversation?.temperature ?? DEFAULT_TEMPERATURE,\n  );\n  const { t } = useTranslation('chat');\n  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n    const newValue = parseFloat(event.target.value);\n    setTemperature(newValue);\n    onChangeTemperature(newValue);\n  };\n\n  return (\n    <div className=\"flex flex-col\">\n      <label className=\"mb-2 text-left text-neutral-700 dark:text-neutral-400\">\n        {label}\n      </label>\n      <span className=\"text-[12px] text-black/50 dark:text-white/50 text-sm\">\n        {t(\n          'Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.',\n        )}\n      </span>\n      <span className=\"mt-2 mb-1 text-center text-neutral-900 dark:text-neutral-100\">\n        {temperature.toFixed(1)}\n      </span>\n      <input\n        className=\"cursor-pointer\"\n        type=\"range\"\n        min={0}\n        max={1}\n        step={0.1}\n        value={temperature}\n        onChange={handleChange}\n      />\n      <ul className=\"w mt-2 pb-8 flex justify-between px-[24px] text-neutral-900 dark:text-neutral-100\">\n        <li className=\"flex justify-center\">\n          <span className=\"absolute\">{t('Precise')}</span>\n        </li>\n        <li className=\"flex justify-center\">\n          <span className=\"absolute\">{t('Neutral')}</span>\n        </li>\n        <li className=\"flex justify-center\">\n          <span className=\"absolute\">{t('Creative')}</span>\n        </li>\n      </ul>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chat/VariableModal.tsx",
    "content": "import { FC, KeyboardEvent, useEffect, useRef, useState } from 'react';\n\nimport { Prompt } from '@/types/prompt';\n\ninterface Props {\n  prompt: Prompt;\n  variables: string[];\n  onSubmit: (updatedVariables: string[]) => void;\n  onClose: () => void;\n}\n\nexport const VariableModal: FC<Props> = ({\n  prompt,\n  variables,\n  onSubmit,\n  onClose,\n}) => {\n  const [updatedVariables, setUpdatedVariables] = useState<\n    { key: string; value: string }[]\n  >(\n    variables\n      .map((variable) => ({ key: variable, value: '' }))\n      .filter(\n        (item, index, array) =>\n          array.findIndex((t) => t.key === item.key) === index,\n      ),\n  );\n\n  const modalRef = useRef<HTMLDivElement>(null);\n  const nameInputRef = useRef<HTMLTextAreaElement>(null);\n\n  const handleChange = (index: number, value: string) => {\n    setUpdatedVariables((prev) => {\n      const updated = [...prev];\n      updated[index].value = value;\n      return updated;\n    });\n  };\n\n  const handleSubmit = () => {\n    if (updatedVariables.some((variable) => variable.value === '')) {\n      alert('Please fill out all variables');\n      return;\n    }\n\n    onSubmit(updatedVariables.map((variable) => variable.value));\n    onClose();\n  };\n\n  const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Enter' && !e.shiftKey) {\n      e.preventDefault();\n      handleSubmit();\n    } else if (e.key === 'Escape') {\n      onClose();\n    }\n  };\n\n  useEffect(() => {\n    const handleOutsideClick = (e: MouseEvent) => {\n      if (modalRef.current && !modalRef.current.contains(e.target as Node)) {\n        onClose();\n      }\n    };\n\n    window.addEventListener('click', handleOutsideClick);\n\n    return () => {\n      window.removeEventListener('click', handleOutsideClick);\n    };\n  }, [onClose]);\n\n  useEffect(() => {\n    if (nameInputRef.current) {\n      nameInputRef.current.focus();\n    }\n  }, []);\n\n  return (\n    <div\n      className=\"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50\"\n      onKeyDown={handleKeyDown}\n    >\n      <div\n        ref={modalRef}\n        className=\"dark:border-netural-400 inline-block max-h-[400px] transform overflow-y-auto rounded-lg border border-gray-300 bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all dark:bg-[#161519] sm:my-8 sm:max-h-[600px] sm:w-full sm:max-w-lg sm:p-6 sm:align-middle\"\n        role=\"dialog\"\n      >\n        <div className=\"mb-4 text-xl font-bold text-black dark:text-neutral-200\">\n          {prompt.name}\n        </div>\n\n        <div className=\"mb-4 text-sm italic text-black dark:text-neutral-200\">\n          {prompt.description}\n        </div>\n\n        {updatedVariables.map((variable, index) => (\n          <div className=\"mb-4\" key={index}>\n            <div className=\"mb-2 text-sm font-bold text-neutral-200\">\n              {variable.key}\n            </div>\n\n            <textarea\n              ref={index === 0 ? nameInputRef : undefined}\n              className=\"mt-1 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100\"\n              style={{ resize: 'none' }}\n              placeholder={`Enter a value for ${variable.key}...`}\n              value={variable.value}\n              onChange={(e) => handleChange(index, e.target.value)}\n              rows={3}\n            />\n          </div>\n        ))}\n\n        <button\n          className=\"mt-6 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300\"\n          onClick={handleSubmit}\n        >\n          Submit\n        </button>\n      </div>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/Chatbar.context.tsx",
    "content": "import { Dispatch, createContext } from 'react';\n\nimport { ActionType } from '@/hooks/useCreateReducer';\n\nimport { Conversation } from '@/types/chat';\nimport { SupportedExportFormats } from '@/types/export';\nimport { PluginKey } from '@/types/plugin';\n\nimport { ChatbarInitialState } from './Chatbar.state';\n\nexport interface ChatbarContextProps {\n  state: ChatbarInitialState;\n  dispatch: Dispatch<ActionType<ChatbarInitialState>>;\n  handleDeleteConversation: (conversation: Conversation) => void;\n  handleClearConversations: () => void;\n  handleExportData: () => void;\n  handleImportConversations: (data: SupportedExportFormats) => void;\n  handlePluginKeyChange: (pluginKey: PluginKey) => void;\n  handleClearPluginKey: (pluginKey: PluginKey) => void;\n  handleApiKeyChange: (apiKey: string) => void;\n}\n\nconst ChatbarContext = createContext<ChatbarContextProps>(undefined!);\n\nexport default ChatbarContext;\n"
  },
  {
    "path": "ui/components/Chatbar/Chatbar.state.tsx",
    "content": "import { Conversation } from '@/types/chat';\n\nexport interface ChatbarInitialState {\n  searchTerm: string;\n  filteredConversations: Conversation[];\n}\n\nexport const initialState: ChatbarInitialState = {\n  searchTerm: '',\n  filteredConversations: [],\n};\n"
  },
  {
    "path": "ui/components/Chatbar/Chatbar.tsx",
    "content": "import { useCallback, useContext, useEffect } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { useCreateReducer } from '@/hooks/useCreateReducer';\n\nimport { DEFAULT_SYSTEM_PROMPT, DEFAULT_TEMPERATURE } from '@/utils/app/const';\nimport { saveConversation, saveConversations } from '@/utils/app/conversation';\nimport { saveFolders } from '@/utils/app/folders';\nimport { exportData, importData } from '@/utils/app/importExport';\n\nimport { Conversation } from '@/types/chat';\nimport { LatestExportFormat, SupportedExportFormats } from '@/types/export';\nimport { OpenAIModels } from '@/types/openai';\nimport { PluginKey } from '@/types/plugin';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport { ChatFolders } from './components/ChatFolders';\nimport { ChatbarSettings } from './components/ChatbarSettings';\nimport { Conversations } from './components/Conversations';\n\nimport Sidebar from '../Sidebar';\nimport ChatbarContext from './Chatbar.context';\nimport { ChatbarInitialState, initialState } from './Chatbar.state';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nexport const Chatbar = () => {\n  const { t } = useTranslation('sidebar');\n\n  const chatBarContextValue = useCreateReducer<ChatbarInitialState>({\n    initialState,\n  });\n\n  const {\n    state: { conversations, showChatbar, defaultModelId, folders, pluginKeys },\n    dispatch: homeDispatch,\n    handleCreateFolder,\n    handleNewConversation,\n    handleUpdateConversation,\n  } = useContext(HomeContext);\n\n  const {\n    state: { searchTerm, filteredConversations },\n    dispatch: chatDispatch,\n  } = chatBarContextValue;\n\n  const handleApiKeyChange = useCallback(\n    (apiKey: string) => {\n      homeDispatch({ field: 'apiKey', value: apiKey });\n\n      localStorage.setItem('apiKey', apiKey);\n    },\n    [homeDispatch],\n  );\n\n  const handlePluginKeyChange = (pluginKey: PluginKey) => {\n    if (pluginKeys.some((key) => key.pluginId === pluginKey.pluginId)) {\n      const updatedPluginKeys = pluginKeys.map((key) => {\n        if (key.pluginId === pluginKey.pluginId) {\n          return pluginKey;\n        }\n\n        return key;\n      });\n\n      homeDispatch({ field: 'pluginKeys', value: updatedPluginKeys });\n\n      localStorage.setItem('pluginKeys', JSON.stringify(updatedPluginKeys));\n    } else {\n      homeDispatch({ field: 'pluginKeys', value: [...pluginKeys, pluginKey] });\n\n      localStorage.setItem(\n        'pluginKeys',\n        JSON.stringify([...pluginKeys, pluginKey]),\n      );\n    }\n  };\n\n  const handleClearPluginKey = (pluginKey: PluginKey) => {\n    const updatedPluginKeys = pluginKeys.filter(\n      (key) => key.pluginId !== pluginKey.pluginId,\n    );\n\n    if (updatedPluginKeys.length === 0) {\n      homeDispatch({ field: 'pluginKeys', value: [] });\n      localStorage.removeItem('pluginKeys');\n      return;\n    }\n\n    homeDispatch({ field: 'pluginKeys', value: updatedPluginKeys });\n\n    localStorage.setItem('pluginKeys', JSON.stringify(updatedPluginKeys));\n  };\n\n  const handleExportData = () => {\n    exportData();\n  };\n\n  const handleImportConversations = (data: SupportedExportFormats) => {\n    const { history, folders, prompts }: LatestExportFormat = importData(data);\n    homeDispatch({ field: 'conversations', value: history });\n    homeDispatch({\n      field: 'selectedConversation',\n      value: history[history.length - 1],\n    });\n    homeDispatch({ field: 'folders', value: folders });\n    homeDispatch({ field: 'prompts', value: prompts });\n\n    window.location.reload();\n  };\n\n  const handleClearConversations = () => {\n    defaultModelId &&\n      homeDispatch({\n        field: 'selectedConversation',\n        value: {\n          id: uuidv4(),\n          name: t('New Conversation'),\n          messages: [],\n          model: OpenAIModels[defaultModelId],\n          prompt: DEFAULT_SYSTEM_PROMPT,\n          temperature: DEFAULT_TEMPERATURE,\n          folderId: null,\n        },\n      });\n\n    homeDispatch({ field: 'conversations', value: [] });\n\n    localStorage.removeItem('conversationHistory');\n    localStorage.removeItem('selectedConversation');\n\n    const updatedFolders = folders.filter((f) => f.type !== 'chat');\n\n    homeDispatch({ field: 'folders', value: updatedFolders });\n    saveFolders(updatedFolders);\n  };\n\n  const handleDeleteConversation = (conversation: Conversation) => {\n    const updatedConversations = conversations.filter(\n      (c) => c.id !== conversation.id,\n    );\n\n    homeDispatch({ field: 'conversations', value: updatedConversations });\n    chatDispatch({ field: 'searchTerm', value: '' });\n    saveConversations(updatedConversations);\n\n    if (updatedConversations.length > 0) {\n      homeDispatch({\n        field: 'selectedConversation',\n        value: updatedConversations[updatedConversations.length - 1],\n      });\n\n      saveConversation(updatedConversations[updatedConversations.length - 1]);\n    } else {\n      defaultModelId &&\n        homeDispatch({\n          field: 'selectedConversation',\n          value: {\n            id: uuidv4(),\n            name: t('New Conversation'),\n            messages: [],\n            model: OpenAIModels[defaultModelId],\n            prompt: DEFAULT_SYSTEM_PROMPT,\n            temperature: DEFAULT_TEMPERATURE,\n            folderId: null,\n          },\n        });\n\n      localStorage.removeItem('selectedConversation');\n    }\n  };\n\n  const handleToggleChatbar = () => {\n    homeDispatch({ field: 'showChatbar', value: !showChatbar });\n    localStorage.setItem('showChatbar', JSON.stringify(!showChatbar));\n  };\n\n  const handleDrop = (e: any) => {\n    if (e.dataTransfer) {\n      const conversation = JSON.parse(e.dataTransfer.getData('conversation'));\n      handleUpdateConversation(conversation, { key: 'folderId', value: 0 });\n      chatDispatch({ field: 'searchTerm', value: '' });\n      e.target.style.background = 'none';\n    }\n  };\n\n  useEffect(() => {\n    if (searchTerm) {\n      chatDispatch({\n        field: 'filteredConversations',\n        value: conversations.filter((conversation) => {\n          const searchable =\n            conversation.name.toLocaleLowerCase() +\n            ' ' +\n            conversation.messages.map((message) => message.content).join(' ');\n          return searchable.toLowerCase().includes(searchTerm.toLowerCase());\n        }),\n      });\n    } else {\n      chatDispatch({\n        field: 'filteredConversations',\n        value: conversations,\n      });\n    }\n  }, [searchTerm, conversations]);\n\n  return (\n    <ChatbarContext.Provider\n      value={{\n        ...chatBarContextValue,\n        handleDeleteConversation,\n        handleClearConversations,\n        handleImportConversations,\n        handleExportData,\n        handlePluginKeyChange,\n        handleClearPluginKey,\n        handleApiKeyChange,\n      }}\n    >\n      <Sidebar<Conversation>\n        side={'left'}\n        isOpen={showChatbar}\n        addItemButtonTitle={t('New chat')}\n        itemComponent={<Conversations conversations={filteredConversations} />}\n        folderComponent={<ChatFolders searchTerm={searchTerm} />}\n        items={filteredConversations}\n        searchTerm={searchTerm}\n        handleSearchTerm={(searchTerm: string) =>\n          chatDispatch({ field: 'searchTerm', value: searchTerm })\n        }\n        toggleOpen={handleToggleChatbar}\n        handleCreateItem={handleNewConversation}\n        handleCreateFolder={() => handleCreateFolder(t('New folder'), 'chat')}\n        handleDrop={handleDrop}\n        footerComponent={<ChatbarSettings />}\n      />\n    </ChatbarContext.Provider>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/components/ChatFolders.tsx",
    "content": "import { useContext } from 'react';\n\nimport { FolderInterface } from '@/types/folder';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport Folder from '@/components/Folder';\n\nimport { ConversationComponent } from './Conversation';\n\ninterface Props {\n  searchTerm: string;\n}\n\nexport const ChatFolders = ({ searchTerm }: Props) => {\n  const {\n    state: { folders, conversations },\n    handleUpdateConversation,\n  } = useContext(HomeContext);\n\n  const handleDrop = (e: any, folder: FolderInterface) => {\n    if (e.dataTransfer) {\n      const conversation = JSON.parse(e.dataTransfer.getData('conversation'));\n      handleUpdateConversation(conversation, {\n        key: 'folderId',\n        value: folder.id,\n      });\n    }\n  };\n\n  const ChatFolders = (currentFolder: FolderInterface) => {\n    return (\n      conversations &&\n      conversations\n        .filter((conversation) => conversation.folderId)\n        .map((conversation, index) => {\n          if (conversation.folderId === currentFolder.id) {\n            return (\n              <div key={index} className=\"ml-5 gap-2 border-l pl-2\">\n                <ConversationComponent conversation={conversation} />\n              </div>\n            );\n          }\n        })\n    );\n  };\n\n  return (\n    <div className=\"flex w-full flex-col pt-2\">\n      {folders\n        .filter((folder) => folder.type === 'chat')\n        .sort((a, b) => a.name.localeCompare(b.name))\n        .map((folder, index) => (\n          <Folder\n            key={index}\n            searchTerm={searchTerm}\n            currentFolder={folder}\n            handleDrop={handleDrop}\n            folderComponent={ChatFolders(folder)}\n          />\n        ))}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/components/ChatbarSettings.tsx",
    "content": "import { IconFileExport, IconSettings } from '@tabler/icons-react';\nimport { useContext, useState } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport { SettingDialog } from '@/components/Settings/SettingDialog';\n\nimport { Import } from '../../Settings/Import';\nimport { Key } from '../../Settings/Key';\nimport { SidebarButton } from '../../Sidebar/SidebarButton';\nimport ChatbarContext from '../Chatbar.context';\nimport { ClearConversations } from './ClearConversations';\nimport { PluginKeys } from './PluginKeys';\n\nexport const ChatbarSettings = () => {\n  const { t } = useTranslation('sidebar');\n  const [isSettingDialogOpen, setIsSettingDialog] = useState<boolean>(false);\n\n  const {\n    state: {\n      apiKey,\n      lightMode,\n      serverSideApiKeyIsSet,\n      serverSidePluginKeysSet,\n      conversations,\n    },\n    dispatch: homeDispatch,\n  } = useContext(HomeContext);\n\n  const {\n    handleClearConversations,\n    handleImportConversations,\n    handleExportData,\n    handleApiKeyChange,\n  } = useContext(ChatbarContext);\n\n  return (\n    <div className=\"flex flex-col items-center space-y-1 border-t border-white/20 pt-1 text-sm\">\n      {conversations.length > 0 ? (\n        <ClearConversations onClearConversations={handleClearConversations} />\n      ) : null}\n\n      {/* <Import onImport={handleImportConversations} /> */}\n\n      {/* <SidebarButton\n        text={t('Export data')}\n        icon={<IconFileExport size={18} />}\n        onClick={() => handleExportData()}\n      /> */}\n\n      {/* <SidebarButton\n        text={t('Settings')}\n        icon={<IconSettings size={18} />}\n        onClick={() => setIsSettingDialog(true)}\n      /> */}\n\n      {/* {!serverSideApiKeyIsSet ? (\n        <Key apiKey={apiKey} onApiKeyChange={handleApiKeyChange} />\n      ) : null} */}\n\n      {/* {!serverSidePluginKeysSet ? <PluginKeys /> : null} */}\n\n      {/* <SettingDialog\n        open={isSettingDialogOpen}\n        onClose={() => {\n          setIsSettingDialog(false);\n        }}\n      /> */}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/components/ClearConversations.tsx",
    "content": "import { IconCheck, IconTrash, IconX } from '@tabler/icons-react';\nimport { FC, useState } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { SidebarButton } from '@/components/Sidebar/SidebarButton';\n\ninterface Props {\n  onClearConversations: () => void;\n}\n\nexport const ClearConversations: FC<Props> = ({ onClearConversations }) => {\n  const [isConfirming, setIsConfirming] = useState<boolean>(false);\n\n  const { t } = useTranslation('sidebar');\n\n  const handleClearConversations = () => {\n    onClearConversations();\n    setIsConfirming(false);\n  };\n\n  return isConfirming ? (\n    <div className=\"flex w-full cursor-pointer items-center rounded-lg py-3 px-3 hover:bg-gray-500/10\">\n      <IconTrash size={18} />\n\n      <div className=\"ml-3 flex-1 text-left text-[12.5px] leading-3 text-white\">\n        {t('Are you sure?')}\n      </div>\n\n      <div className=\"flex w-[40px]\">\n        <IconCheck\n          className=\"ml-auto mr-1 min-w-[20px] text-neutral-400 hover:text-neutral-100\"\n          size={18}\n          onClick={(e) => {\n            e.stopPropagation();\n            handleClearConversations();\n          }}\n        />\n\n        <IconX\n          className=\"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100\"\n          size={18}\n          onClick={(e) => {\n            e.stopPropagation();\n            setIsConfirming(false);\n          }}\n        />\n      </div>\n    </div>\n  ) : (\n    <SidebarButton\n      text={t('Clear conversations')}\n      icon={<IconTrash size={18} />}\n      onClick={() => setIsConfirming(true)}\n    />\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/components/Conversation.tsx",
    "content": "import {\n  IconCheck,\n  IconMessage,\n  IconPencil,\n  IconTrash,\n  IconX,\n} from '@tabler/icons-react';\nimport {\n  DragEvent,\n  KeyboardEvent,\n  MouseEventHandler,\n  useContext,\n  useEffect,\n  useState,\n} from 'react';\n\nimport { Conversation } from '@/types/chat';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport SidebarActionButton from '@/components/Buttons/SidebarActionButton';\nimport ChatbarContext from '@/components/Chatbar/Chatbar.context';\n\ninterface Props {\n  conversation: Conversation;\n}\n\nexport const ConversationComponent = ({ conversation }: Props) => {\n  const {\n    state: { selectedConversation, messageIsStreaming },\n    handleSelectConversation,\n    handleUpdateConversation,\n  } = useContext(HomeContext);\n\n  const { handleDeleteConversation } = useContext(ChatbarContext);\n\n  const [isDeleting, setIsDeleting] = useState(false);\n  const [isRenaming, setIsRenaming] = useState(false);\n  const [renameValue, setRenameValue] = useState('');\n\n  const handleEnterDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Enter') {\n      e.preventDefault();\n      selectedConversation && handleRename(selectedConversation);\n    }\n  };\n\n  const handleDragStart = (\n    e: DragEvent<HTMLButtonElement>,\n    conversation: Conversation,\n  ) => {\n    if (e.dataTransfer) {\n      e.dataTransfer.setData('conversation', JSON.stringify(conversation));\n    }\n  };\n\n  const handleRename = (conversation: Conversation) => {\n    if (renameValue.trim().length > 0) {\n      handleUpdateConversation(conversation, {\n        key: 'name',\n        value: renameValue,\n      });\n      setRenameValue('');\n      setIsRenaming(false);\n    }\n  };\n\n  const handleConfirm: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n    if (isDeleting) {\n      handleDeleteConversation(conversation);\n    } else if (isRenaming) {\n      handleRename(conversation);\n    }\n    setIsDeleting(false);\n    setIsRenaming(false);\n  };\n\n  const handleCancel: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n    setIsDeleting(false);\n    setIsRenaming(false);\n  };\n\n  const handleOpenRenameModal: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n    setIsRenaming(true);\n    selectedConversation && setRenameValue(selectedConversation.name);\n  };\n  const handleOpenDeleteModal: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n    setIsDeleting(true);\n  };\n\n  useEffect(() => {\n    if (isRenaming) {\n      setIsDeleting(false);\n    } else if (isDeleting) {\n      setIsRenaming(false);\n    }\n  }, [isRenaming, isDeleting]);\n\n  return (\n    <div className=\"relative flex items-center\">\n      {isRenaming && selectedConversation?.id === conversation.id ? (\n        <div className=\"flex w-full items-center gap-3 rounded-lg bg-[#1d1c21]/90 p-3\">\n          <IconMessage size={18} />\n          <input\n            className=\"mr-12 flex-1 overflow-hidden overflow-ellipsis border-neutral-400 bg-transparent text-left text-[12.5px] leading-3 text-white outline-none focus:border-neutral-100\"\n            type=\"text\"\n            value={renameValue}\n            onChange={(e) => setRenameValue(e.target.value)}\n            onKeyDown={handleEnterDown}\n            autoFocus\n          />\n        </div>\n      ) : (\n        <button\n          className={`flex w-full cursor-pointer items-center gap-3 rounded-lg p-3 text-sm transition-colors duration-200 hover:bg-[#1d1c21]/90 ${\n            messageIsStreaming ? 'disabled:cursor-not-allowed' : ''\n          } ${\n            selectedConversation?.id === conversation.id\n              ? 'bg-[#1d1c21]/90'\n              : ''\n          }`}\n          onClick={() => handleSelectConversation(conversation)}\n          disabled={messageIsStreaming}\n          draggable=\"true\"\n          onDragStart={(e) => handleDragStart(e, conversation)}\n        >\n          <IconMessage size={18} />\n          <div\n            className={`relative max-h-5 flex-1 overflow-hidden text-ellipsis whitespace-nowrap break-all text-left text-[12.5px] leading-3 ${\n              selectedConversation?.id === conversation.id ? 'pr-12' : 'pr-1'\n            }`}\n          >\n            {conversation.name}\n          </div>\n        </button>\n      )}\n\n      {(isDeleting || isRenaming) &&\n        selectedConversation?.id === conversation.id && (\n          <div className=\"absolute right-1 z-10 flex text-gray-300\">\n            <SidebarActionButton handleClick={handleConfirm}>\n              <IconCheck size={18} />\n            </SidebarActionButton>\n            <SidebarActionButton handleClick={handleCancel}>\n              <IconX size={18} />\n            </SidebarActionButton>\n          </div>\n        )}\n\n      {selectedConversation?.id === conversation.id &&\n        !isDeleting &&\n        !isRenaming && (\n          <div className=\"absolute right-1 z-10 flex text-gray-300\">\n            <SidebarActionButton handleClick={handleOpenRenameModal}>\n              <IconPencil size={18} />\n            </SidebarActionButton>\n            <SidebarActionButton handleClick={handleOpenDeleteModal}>\n              <IconTrash size={18} />\n            </SidebarActionButton>\n          </div>\n        )}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/components/Conversations.tsx",
    "content": "import { Conversation } from '@/types/chat';\n\nimport { ConversationComponent } from './Conversation';\n\ninterface Props {\n  conversations: Conversation[];\n}\n\nexport const Conversations = ({ conversations }: Props) => {\n  return (\n    <div className=\"flex w-full flex-col gap-1\">\n      {conversations\n        .filter((conversation) => !conversation.folderId)\n        .slice()\n        .reverse()\n        .map((conversation, index) => (\n          <ConversationComponent key={index} conversation={conversation} />\n        ))}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Chatbar/components/PluginKeys.tsx",
    "content": "import { IconKey } from '@tabler/icons-react';\nimport { KeyboardEvent, useContext, useEffect, useRef, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { PluginID, PluginKey } from '@/types/plugin';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport { SidebarButton } from '@/components/Sidebar/SidebarButton';\n\nimport ChatbarContext from '../Chatbar.context';\n\nexport const PluginKeys = () => {\n  const { t } = useTranslation('sidebar');\n\n  const {\n    state: { pluginKeys },\n  } = useContext(HomeContext);\n\n  const { handlePluginKeyChange, handleClearPluginKey } =\n    useContext(ChatbarContext);\n\n  const [isChanging, setIsChanging] = useState(false);\n\n  const modalRef = useRef<HTMLDivElement>(null);\n\n  const handleEnter = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Enter' && !e.shiftKey) {\n      e.preventDefault();\n      setIsChanging(false);\n    }\n  };\n\n  useEffect(() => {\n    const handleMouseDown = (e: MouseEvent) => {\n      if (modalRef.current && !modalRef.current.contains(e.target as Node)) {\n        window.addEventListener('mouseup', handleMouseUp);\n      }\n    };\n\n    const handleMouseUp = (e: MouseEvent) => {\n      window.removeEventListener('mouseup', handleMouseUp);\n      setIsChanging(false);\n    };\n\n    window.addEventListener('mousedown', handleMouseDown);\n\n    return () => {\n      window.removeEventListener('mousedown', handleMouseDown);\n    };\n  }, []);\n\n  return (\n    <>\n      <SidebarButton\n        text={t('Plugin Keys')}\n        icon={<IconKey size={18} />}\n        onClick={() => setIsChanging(true)}\n      />\n\n      {isChanging && (\n        <div\n          className=\"z-100 fixed inset-0 flex items-center justify-center bg-black bg-opacity-50\"\n          onKeyDown={handleEnter}\n        >\n          <div className=\"fixed inset-0 z-10 overflow-hidden\">\n            <div className=\"flex min-h-screen items-center justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0\">\n              <div\n                className=\"hidden sm:inline-block sm:h-screen sm:align-middle\"\n                aria-hidden=\"true\"\n              />\n\n              <div\n                ref={modalRef}\n                className=\"dark:border-netural-400 inline-block max-h-[400px] transform overflow-y-auto rounded-lg border border-gray-300 bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all dark:bg-[#161519] sm:my-8 sm:max-h-[600px] sm:w-full sm:max-w-lg sm:p-6 sm:align-middle\"\n                role=\"dialog\"\n              >\n                <div className=\"mb-10 text-4xl\">Plugin Keys</div>\n\n                <div className=\"mt-6 rounded border p-4\">\n                  <div className=\"text-xl font-bold\">Google Search Plugin</div>\n                  <div className=\"mt-4 italic\">\n                    Please enter your Google API Key and Google CSE ID to enable\n                    the Google Search Plugin.\n                  </div>\n\n                  <div className=\"mt-6 text-sm font-bold text-black dark:text-neutral-200\">\n                    Google API Key\n                  </div>\n                  <input\n                    className=\"mt-2 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100\"\n                    type=\"password\"\n                    value={\n                      pluginKeys\n                        .find((p) => p.pluginId === PluginID.GOOGLE_SEARCH)\n                        ?.requiredKeys.find((k) => k.key === 'GOOGLE_API_KEY')\n                        ?.value\n                    }\n                    onChange={(e) => {\n                      const pluginKey = pluginKeys.find(\n                        (p) => p.pluginId === PluginID.GOOGLE_SEARCH,\n                      );\n\n                      if (pluginKey) {\n                        const requiredKey = pluginKey.requiredKeys.find(\n                          (k) => k.key === 'GOOGLE_API_KEY',\n                        );\n\n                        if (requiredKey) {\n                          const updatedPluginKey = {\n                            ...pluginKey,\n                            requiredKeys: pluginKey.requiredKeys.map((k) => {\n                              if (k.key === 'GOOGLE_API_KEY') {\n                                return {\n                                  ...k,\n                                  value: e.target.value,\n                                };\n                              }\n\n                              return k;\n                            }),\n                          };\n\n                          handlePluginKeyChange(updatedPluginKey);\n                        }\n                      } else {\n                        const newPluginKey: PluginKey = {\n                          pluginId: PluginID.GOOGLE_SEARCH,\n                          requiredKeys: [\n                            {\n                              key: 'GOOGLE_API_KEY',\n                              value: e.target.value,\n                            },\n                            {\n                              key: 'GOOGLE_CSE_ID',\n                              value: '',\n                            },\n                          ],\n                        };\n\n                        handlePluginKeyChange(newPluginKey);\n                      }\n                    }}\n                  />\n\n                  <div className=\"mt-6 text-sm font-bold text-black dark:text-neutral-200\">\n                    Google CSE ID\n                  </div>\n                  <input\n                    className=\"mt-2 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100\"\n                    type=\"password\"\n                    value={\n                      pluginKeys\n                        .find((p) => p.pluginId === PluginID.GOOGLE_SEARCH)\n                        ?.requiredKeys.find((k) => k.key === 'GOOGLE_CSE_ID')\n                        ?.value\n                    }\n                    onChange={(e) => {\n                      const pluginKey = pluginKeys.find(\n                        (p) => p.pluginId === PluginID.GOOGLE_SEARCH,\n                      );\n\n                      if (pluginKey) {\n                        const requiredKey = pluginKey.requiredKeys.find(\n                          (k) => k.key === 'GOOGLE_CSE_ID',\n                        );\n\n                        if (requiredKey) {\n                          const updatedPluginKey = {\n                            ...pluginKey,\n                            requiredKeys: pluginKey.requiredKeys.map((k) => {\n                              if (k.key === 'GOOGLE_CSE_ID') {\n                                return {\n                                  ...k,\n                                  value: e.target.value,\n                                };\n                              }\n\n                              return k;\n                            }),\n                          };\n\n                          handlePluginKeyChange(updatedPluginKey);\n                        }\n                      } else {\n                        const newPluginKey: PluginKey = {\n                          pluginId: PluginID.GOOGLE_SEARCH,\n                          requiredKeys: [\n                            {\n                              key: 'GOOGLE_API_KEY',\n                              value: '',\n                            },\n                            {\n                              key: 'GOOGLE_CSE_ID',\n                              value: e.target.value,\n                            },\n                          ],\n                        };\n\n                        handlePluginKeyChange(newPluginKey);\n                      }\n                    }}\n                  />\n\n                  <button\n                    className=\"mt-6 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300\"\n                    onClick={() => {\n                      const pluginKey = pluginKeys.find(\n                        (p) => p.pluginId === PluginID.GOOGLE_SEARCH,\n                      );\n\n                      if (pluginKey) {\n                        handleClearPluginKey(pluginKey);\n                      }\n                    }}\n                  >\n                    Clear Google Search Plugin Keys\n                  </button>\n                </div>\n\n                <button\n                  type=\"button\"\n                  className=\"mt-6 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300\"\n                  onClick={() => setIsChanging(false)}\n                >\n                  {t('Save')}\n                </button>\n              </div>\n            </div>\n          </div>\n        </div>\n      )}\n    </>\n  );\n};\n"
  },
  {
    "path": "ui/components/Folder/Folder.tsx",
    "content": "import {\n  IconCaretDown,\n  IconCaretRight,\n  IconCheck,\n  IconPencil,\n  IconTrash,\n  IconX,\n} from '@tabler/icons-react';\nimport {\n  KeyboardEvent,\n  ReactElement,\n  useContext,\n  useEffect,\n  useState,\n} from 'react';\n\nimport { FolderInterface } from '@/types/folder';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport SidebarActionButton from '@/components/Buttons/SidebarActionButton';\n\ninterface Props {\n  currentFolder: FolderInterface;\n  searchTerm: string;\n  handleDrop: (e: any, folder: FolderInterface) => void;\n  folderComponent: (ReactElement | undefined)[];\n}\n\nconst Folder = ({\n  currentFolder,\n  searchTerm,\n  handleDrop,\n  folderComponent,\n}: Props) => {\n  const { handleDeleteFolder, handleUpdateFolder } = useContext(HomeContext);\n\n  const [isDeleting, setIsDeleting] = useState(false);\n  const [isRenaming, setIsRenaming] = useState(false);\n  const [renameValue, setRenameValue] = useState('');\n  const [isOpen, setIsOpen] = useState(false);\n\n  const handleEnterDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Enter') {\n      e.preventDefault();\n      handleRename();\n    }\n  };\n\n  const handleRename = () => {\n    handleUpdateFolder(currentFolder.id, renameValue);\n    setRenameValue('');\n    setIsRenaming(false);\n  };\n\n  const dropHandler = (e: any) => {\n    if (e.dataTransfer) {\n      setIsOpen(true);\n\n      handleDrop(e, currentFolder);\n\n      e.target.style.background = 'none';\n    }\n  };\n\n  const allowDrop = (e: any) => {\n    e.preventDefault();\n  };\n\n  const highlightDrop = (e: any) => {\n    e.target.style.background = '#1d1c21';\n  };\n\n  const removeHighlight = (e: any) => {\n    e.target.style.background = 'none';\n  };\n\n  useEffect(() => {\n    if (isRenaming) {\n      setIsDeleting(false);\n    } else if (isDeleting) {\n      setIsRenaming(false);\n    }\n  }, [isRenaming, isDeleting]);\n\n  useEffect(() => {\n    if (searchTerm) {\n      setIsOpen(true);\n    } else {\n      setIsOpen(false);\n    }\n  }, [searchTerm]);\n\n  return (\n    <>\n      <div className=\"relative flex items-center\">\n        {isRenaming ? (\n          <div className=\"flex w-full items-center gap-3 bg-[#1d1c21]/90 p-3\">\n            {isOpen ? (\n              <IconCaretDown size={18} />\n            ) : (\n              <IconCaretRight size={18} />\n            )}\n            <input\n              className=\"mr-12 flex-1 overflow-hidden overflow-ellipsis border-neutral-400 bg-transparent text-left text-[12.5px] leading-3 text-white outline-none focus:border-neutral-100\"\n              type=\"text\"\n              value={renameValue}\n              onChange={(e) => setRenameValue(e.target.value)}\n              onKeyDown={handleEnterDown}\n              autoFocus\n            />\n          </div>\n        ) : (\n          <button\n            className={`flex w-full cursor-pointer items-center gap-3 rounded-lg p-3 text-sm transition-colors duration-200 hover:bg-[#1d1c21]/90`}\n            onClick={() => setIsOpen(!isOpen)}\n            onDrop={(e) => dropHandler(e)}\n            onDragOver={allowDrop}\n            onDragEnter={highlightDrop}\n            onDragLeave={removeHighlight}\n          >\n            {isOpen ? (\n              <IconCaretDown size={18} />\n            ) : (\n              <IconCaretRight size={18} />\n            )}\n\n            <div className=\"relative max-h-5 flex-1 overflow-hidden text-ellipsis whitespace-nowrap break-all text-left text-[12.5px] leading-3\">\n              {currentFolder.name}\n            </div>\n          </button>\n        )}\n\n        {(isDeleting || isRenaming) && (\n          <div className=\"absolute right-1 z-10 flex text-gray-300\">\n            <SidebarActionButton\n              handleClick={(e) => {\n                e.stopPropagation();\n\n                if (isDeleting) {\n                  handleDeleteFolder(currentFolder.id);\n                } else if (isRenaming) {\n                  handleRename();\n                }\n\n                setIsDeleting(false);\n                setIsRenaming(false);\n              }}\n            >\n              <IconCheck size={18} />\n            </SidebarActionButton>\n            <SidebarActionButton\n              handleClick={(e) => {\n                e.stopPropagation();\n                setIsDeleting(false);\n                setIsRenaming(false);\n              }}\n            >\n              <IconX size={18} />\n            </SidebarActionButton>\n          </div>\n        )}\n\n        {!isDeleting && !isRenaming && (\n          <div className=\"absolute right-1 z-10 flex text-gray-300\">\n            <SidebarActionButton\n              handleClick={(e) => {\n                e.stopPropagation();\n                setIsRenaming(true);\n                setRenameValue(currentFolder.name);\n              }}\n            >\n              <IconPencil size={18} />\n            </SidebarActionButton>\n            <SidebarActionButton\n              handleClick={(e) => {\n                e.stopPropagation();\n                setIsDeleting(true);\n              }}\n            >\n              <IconTrash size={18} />\n            </SidebarActionButton>\n          </div>\n        )}\n      </div>\n\n      {isOpen ? folderComponent : null}\n    </>\n  );\n};\n\nexport default Folder;\n"
  },
  {
    "path": "ui/components/Folder/index.ts",
    "content": "export { default } from './Folder';\n"
  },
  {
    "path": "ui/components/Markdown/CodeBlock.tsx",
    "content": "import { IconCheck, IconClipboard, IconDownload } from '@tabler/icons-react';\nimport { FC, memo, useState } from 'react';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { oneDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';\n\nimport { useTranslation } from 'next-i18next';\n\nimport {\n  generateRandomString,\n  programmingLanguages,\n} from '@/utils/app/codeblock';\n\ninterface Props {\n  language: string;\n  value: string;\n}\n\nexport const CodeBlock: FC<Props> = memo(({ language, value }) => {\n  const { t } = useTranslation('markdown');\n  const [isCopied, setIsCopied] = useState<Boolean>(false);\n\n  const copyToClipboard = () => {\n    // fallback to allow copying to clipboard over http\n    const copyToClipboardFallback = (text: string) => {\n      let textArea = document.createElement(\"textarea\");\n      textArea.value = text;\n      textArea.style.position = \"absolute\";\n      textArea.style.opacity = \"0\";\n      document.body.appendChild(textArea);\n      textArea.select();\n      document.execCommand(\"copy\");\n      textArea.remove();\n    };\n  \n    if (navigator.clipboard && window.isSecureContext) {\n      navigator.clipboard.writeText(value);\n    } else {\n      copyToClipboardFallback(value);\n    }\n  \n    setIsCopied(true);\n    setTimeout(() => {\n      setIsCopied(false);\n    }, 2000);\n  };\n  const downloadAsFile = () => {\n    const fileExtension = programmingLanguages[language] || '.file';\n    const suggestedFileName = `file-${generateRandomString(\n      3,\n      true,\n    )}${fileExtension}`;\n    const fileName = window.prompt(\n      t('Enter file name') || '',\n      suggestedFileName,\n    );\n\n    if (!fileName) {\n      // user pressed cancel on prompt\n      return;\n    }\n\n    const blob = new Blob([value], { type: 'text/plain' });\n    const url = URL.createObjectURL(blob);\n    const link = document.createElement('a');\n    link.download = fileName;\n    link.href = url;\n    link.style.display = 'none';\n    document.body.appendChild(link);\n    link.click();\n    document.body.removeChild(link);\n    URL.revokeObjectURL(url);\n  };\n  return (\n    <div className=\"codeblock relative font-sans text-[16px]\">\n      <div className=\"flex items-center justify-between py-1.5 px-4\">\n        <span className=\"text-xs lowercase text-white\">{language}</span>\n\n        <div className=\"flex items-center\">\n          <button\n            className=\"flex gap-1.5 items-center rounded bg-none p-1 text-xs text-white\"\n            onClick={copyToClipboard}\n          >\n            {isCopied ? <IconCheck size={18} /> : <IconClipboard size={18} />}\n            {isCopied ? t('Copied!') : t('Copy code')}\n          </button>\n          <button\n            className=\"flex items-center rounded bg-none p-1 text-xs text-white\"\n            onClick={downloadAsFile}\n          >\n            <IconDownload size={18} />\n          </button>\n        </div>\n      </div>\n\n      <SyntaxHighlighter\n        language={language}\n        style={oneDark}\n        customStyle={{ margin: 0 }}\n      >\n        {value}\n      </SyntaxHighlighter>\n    </div>\n  );\n});\nCodeBlock.displayName = 'CodeBlock';\n"
  },
  {
    "path": "ui/components/Markdown/MemoizedReactMarkdown.tsx",
    "content": "import { FC, memo } from 'react';\nimport ReactMarkdown, { Options } from 'react-markdown';\n\nexport const MemoizedReactMarkdown: FC<Options> = memo(\n    ReactMarkdown,\n    (prevProps, nextProps) => (\n        prevProps.children === nextProps.children\n    )\n);\n"
  },
  {
    "path": "ui/components/Mobile/Navbar.tsx",
    "content": "import { IconPlus } from '@tabler/icons-react';\nimport { FC } from 'react';\n\nimport { Conversation } from '@/types/chat';\n\ninterface Props {\n  selectedConversation: Conversation;\n  onNewConversation: () => void;\n}\n\nexport const Navbar: FC<Props> = ({\n  selectedConversation,\n  onNewConversation,\n}) => {\n  return (\n    <nav className=\"flex w-full justify-between bg-[#161519] py-3 px-4\">\n      <div className=\"mr-4\"></div>\n\n      <div className=\"max-w-[240px] overflow-hidden text-ellipsis whitespace-nowrap\">\n        {selectedConversation.name}\n      </div>\n\n      <IconPlus\n        className=\"cursor-pointer hover:text-neutral-400 mr-8\"\n        onClick={onNewConversation}\n      />\n    </nav>\n  );\n};\n"
  },
  {
    "path": "ui/components/Promptbar/PromptBar.context.tsx",
    "content": "import { Dispatch, createContext } from 'react';\n\nimport { ActionType } from '@/hooks/useCreateReducer';\n\nimport { Prompt } from '@/types/prompt';\n\nimport { PromptbarInitialState } from './Promptbar.state';\n\nexport interface PromptbarContextProps {\n  state: PromptbarInitialState;\n  dispatch: Dispatch<ActionType<PromptbarInitialState>>;\n  handleCreatePrompt: () => void;\n  handleDeletePrompt: (prompt: Prompt) => void;\n  handleUpdatePrompt: (prompt: Prompt) => void;\n}\n\nconst PromptbarContext = createContext<PromptbarContextProps>(undefined!);\n\nexport default PromptbarContext;\n"
  },
  {
    "path": "ui/components/Promptbar/Promptbar.state.tsx",
    "content": "import { Prompt } from '@/types/prompt';\n\nexport interface PromptbarInitialState {\n  searchTerm: string;\n  filteredPrompts: Prompt[];\n}\n\nexport const initialState: PromptbarInitialState = {\n  searchTerm: '',\n  filteredPrompts: [],\n};\n"
  },
  {
    "path": "ui/components/Promptbar/Promptbar.tsx",
    "content": "import { useContext, useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { useCreateReducer } from '@/hooks/useCreateReducer';\n\nimport { savePrompts } from '@/utils/app/prompts';\n\nimport { OpenAIModels } from '@/types/openai';\nimport { Prompt } from '@/types/prompt';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport { PromptFolders } from './components/PromptFolders';\nimport { PromptbarSettings } from './components/PromptbarSettings';\nimport { Prompts } from './components/Prompts';\n\nimport Sidebar from '../Sidebar';\nimport PromptbarContext from './PromptBar.context';\nimport { PromptbarInitialState, initialState } from './Promptbar.state';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nconst Promptbar = () => {\n  const { t } = useTranslation('promptbar');\n\n  const promptBarContextValue = useCreateReducer<PromptbarInitialState>({\n    initialState,\n  });\n\n  const {\n    state: { prompts, defaultModelId, showPromptbar },\n    dispatch: homeDispatch,\n    handleCreateFolder,\n  } = useContext(HomeContext);\n\n  const {\n    state: { searchTerm, filteredPrompts },\n    dispatch: promptDispatch,\n  } = promptBarContextValue;\n\n  const handleTogglePromptbar = () => {\n    homeDispatch({ field: 'showPromptbar', value: !showPromptbar });\n    localStorage.setItem('showPromptbar', JSON.stringify(!showPromptbar));\n  };\n\n  const handleCreatePrompt = () => {\n    if (defaultModelId) {\n      const newPrompt: Prompt = {\n        id: uuidv4(),\n        name: `Prompt ${prompts.length + 1}`,\n        description: '',\n        content: '',\n        model: OpenAIModels[defaultModelId],\n        folderId: null,\n      };\n\n      const updatedPrompts = [...prompts, newPrompt];\n\n      homeDispatch({ field: 'prompts', value: updatedPrompts });\n\n      savePrompts(updatedPrompts);\n    }\n  };\n\n  const handleDeletePrompt = (prompt: Prompt) => {\n    const updatedPrompts = prompts.filter((p) => p.id !== prompt.id);\n\n    homeDispatch({ field: 'prompts', value: updatedPrompts });\n    savePrompts(updatedPrompts);\n  };\n\n  const handleUpdatePrompt = (prompt: Prompt) => {\n    const updatedPrompts = prompts.map((p) => {\n      if (p.id === prompt.id) {\n        return prompt;\n      }\n\n      return p;\n    });\n    homeDispatch({ field: 'prompts', value: updatedPrompts });\n\n    savePrompts(updatedPrompts);\n  };\n\n  const handleDrop = (e: any) => {\n    if (e.dataTransfer) {\n      const prompt = JSON.parse(e.dataTransfer.getData('prompt'));\n\n      const updatedPrompt = {\n        ...prompt,\n        folderId: e.target.dataset.folderId,\n      };\n\n      handleUpdatePrompt(updatedPrompt);\n\n      e.target.style.background = 'none';\n    }\n  };\n\n  useEffect(() => {\n    if (searchTerm) {\n      promptDispatch({\n        field: 'filteredPrompts',\n        value: prompts.filter((prompt) => {\n          const searchable =\n            prompt.name.toLowerCase() +\n            ' ' +\n            prompt.description.toLowerCase() +\n            ' ' +\n            prompt.content.toLowerCase();\n          return searchable.includes(searchTerm.toLowerCase());\n        }),\n      });\n    } else {\n      promptDispatch({ field: 'filteredPrompts', value: prompts });\n    }\n  }, [searchTerm, prompts]);\n\n  return (\n    <PromptbarContext.Provider\n      value={{\n        ...promptBarContextValue,\n        handleCreatePrompt,\n        handleDeletePrompt,\n        handleUpdatePrompt,\n      }}\n    >\n      <Sidebar<Prompt>\n        side={'right'}\n        isOpen={showPromptbar}\n        addItemButtonTitle={t('New prompt')}\n        itemComponent={\n          <Prompts\n            prompts={filteredPrompts.filter((prompt) => !prompt.folderId)}\n          />\n        }\n        folderComponent={<PromptFolders />}\n        items={filteredPrompts}\n        searchTerm={searchTerm}\n        handleSearchTerm={(searchTerm: string) =>\n          promptDispatch({ field: 'searchTerm', value: searchTerm })\n        }\n        toggleOpen={handleTogglePromptbar}\n        handleCreateItem={handleCreatePrompt}\n        handleCreateFolder={() => handleCreateFolder(t('New folder'), 'prompt')}\n        handleDrop={handleDrop}\n      />\n    </PromptbarContext.Provider>\n  );\n};\n\nexport default Promptbar;\n"
  },
  {
    "path": "ui/components/Promptbar/components/Prompt.tsx",
    "content": "import {\n  IconBulbFilled,\n  IconCheck,\n  IconTrash,\n  IconX,\n} from '@tabler/icons-react';\nimport {\n  DragEvent,\n  MouseEventHandler,\n  useContext,\n  useEffect,\n  useState,\n} from 'react';\n\nimport { Prompt } from '@/types/prompt';\n\nimport SidebarActionButton from '@/components/Buttons/SidebarActionButton';\n\nimport PromptbarContext from '../PromptBar.context';\nimport { PromptModal } from './PromptModal';\n\ninterface Props {\n  prompt: Prompt;\n}\n\nexport const PromptComponent = ({ prompt }: Props) => {\n  const {\n    dispatch: promptDispatch,\n    handleUpdatePrompt,\n    handleDeletePrompt,\n  } = useContext(PromptbarContext);\n\n  const [showModal, setShowModal] = useState<boolean>(false);\n  const [isDeleting, setIsDeleting] = useState(false);\n  const [isRenaming, setIsRenaming] = useState(false);\n  const [renameValue, setRenameValue] = useState('');\n\n  const handleUpdate = (prompt: Prompt) => {\n    handleUpdatePrompt(prompt);\n    promptDispatch({ field: 'searchTerm', value: '' });\n  };\n\n  const handleDelete: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n\n    if (isDeleting) {\n      handleDeletePrompt(prompt);\n      promptDispatch({ field: 'searchTerm', value: '' });\n    }\n\n    setIsDeleting(false);\n  };\n\n  const handleCancelDelete: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n    setIsDeleting(false);\n  };\n\n  const handleOpenDeleteModal: MouseEventHandler<HTMLButtonElement> = (e) => {\n    e.stopPropagation();\n    setIsDeleting(true);\n  };\n\n  const handleDragStart = (e: DragEvent<HTMLButtonElement>, prompt: Prompt) => {\n    if (e.dataTransfer) {\n      e.dataTransfer.setData('prompt', JSON.stringify(prompt));\n    }\n  };\n\n  useEffect(() => {\n    if (isRenaming) {\n      setIsDeleting(false);\n    } else if (isDeleting) {\n      setIsRenaming(false);\n    }\n  }, [isRenaming, isDeleting]);\n\n  return (\n    <div className=\"relative flex items-center\">\n      <button\n        className=\"flex w-full cursor-pointer items-center gap-3 rounded-lg p-3 text-sm transition-colors duration-200 hover:bg-[#1d1c21]/90\"\n        draggable=\"true\"\n        onClick={(e) => {\n          e.stopPropagation();\n          setShowModal(true);\n        }}\n        onDragStart={(e) => handleDragStart(e, prompt)}\n        onMouseLeave={() => {\n          setIsDeleting(false);\n          setIsRenaming(false);\n          setRenameValue('');\n        }}\n      >\n        <IconBulbFilled size={18} />\n\n        <div className=\"relative max-h-5 flex-1 overflow-hidden text-ellipsis whitespace-nowrap break-all pr-4 text-left text-[12.5px] leading-3\">\n          {prompt.name}\n        </div>\n      </button>\n\n      {(isDeleting || isRenaming) && (\n        <div className=\"absolute right-1 z-10 flex text-gray-300\">\n          <SidebarActionButton handleClick={handleDelete}>\n            <IconCheck size={18} />\n          </SidebarActionButton>\n\n          <SidebarActionButton handleClick={handleCancelDelete}>\n            <IconX size={18} />\n          </SidebarActionButton>\n        </div>\n      )}\n\n      {!isDeleting && !isRenaming && (\n        <div className=\"absolute right-1 z-10 flex text-gray-300\">\n          <SidebarActionButton handleClick={handleOpenDeleteModal}>\n            <IconTrash size={18} />\n          </SidebarActionButton>\n        </div>\n      )}\n\n      {showModal && (\n        <PromptModal\n          prompt={prompt}\n          onClose={() => setShowModal(false)}\n          onUpdatePrompt={handleUpdate}\n        />\n      )}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Promptbar/components/PromptFolders.tsx",
    "content": "import { useContext } from 'react';\n\nimport { FolderInterface } from '@/types/folder';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\nimport Folder from '@/components/Folder';\nimport { PromptComponent } from '@/components/Promptbar/components/Prompt';\n\nimport PromptbarContext from '../PromptBar.context';\n\nexport const PromptFolders = () => {\n  const {\n    state: { folders },\n  } = useContext(HomeContext);\n\n  const {\n    state: { searchTerm, filteredPrompts },\n    handleUpdatePrompt,\n  } = useContext(PromptbarContext);\n\n  const handleDrop = (e: any, folder: FolderInterface) => {\n    if (e.dataTransfer) {\n      const prompt = JSON.parse(e.dataTransfer.getData('prompt'));\n\n      const updatedPrompt = {\n        ...prompt,\n        folderId: folder.id,\n      };\n\n      handleUpdatePrompt(updatedPrompt);\n    }\n  };\n\n  const PromptFolders = (currentFolder: FolderInterface) =>\n    filteredPrompts\n      .filter((p) => p.folderId)\n      .map((prompt, index) => {\n        if (prompt.folderId === currentFolder.id) {\n          return (\n            <div key={index} className=\"ml-5 gap-2 border-l pl-2\">\n              <PromptComponent prompt={prompt} />\n            </div>\n          );\n        }\n      });\n\n  return (\n    <div className=\"flex w-full flex-col pt-2\">\n      {folders\n        .filter((folder) => folder.type === 'prompt')\n        .sort((a, b) => a.name.localeCompare(b.name))\n        .map((folder, index) => (\n          <Folder\n            key={index}\n            searchTerm={searchTerm}\n            currentFolder={folder}\n            handleDrop={handleDrop}\n            folderComponent={PromptFolders(folder)}\n          />\n        ))}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Promptbar/components/PromptModal.tsx",
    "content": "import { FC, KeyboardEvent, useEffect, useRef, useState } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { Prompt } from '@/types/prompt';\n\ninterface Props {\n  prompt: Prompt;\n  onClose: () => void;\n  onUpdatePrompt: (prompt: Prompt) => void;\n}\n\nexport const PromptModal: FC<Props> = ({ prompt, onClose, onUpdatePrompt }) => {\n  const { t } = useTranslation('promptbar');\n  const [name, setName] = useState(prompt.name);\n  const [description, setDescription] = useState(prompt.description);\n  const [content, setContent] = useState(prompt.content);\n\n  const modalRef = useRef<HTMLDivElement>(null);\n  const nameInputRef = useRef<HTMLInputElement>(null);\n\n  const handleEnter = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Enter' && !e.shiftKey) {\n      onUpdatePrompt({ ...prompt, name, description, content: content.trim() });\n      onClose();\n    }\n  };\n\n  useEffect(() => {\n    const handleMouseDown = (e: MouseEvent) => {\n      if (modalRef.current && !modalRef.current.contains(e.target as Node)) {\n        window.addEventListener('mouseup', handleMouseUp);\n      }\n    };\n\n    const handleMouseUp = (e: MouseEvent) => {\n      window.removeEventListener('mouseup', handleMouseUp);\n      onClose();\n    };\n\n    window.addEventListener('mousedown', handleMouseDown);\n\n    return () => {\n      window.removeEventListener('mousedown', handleMouseDown);\n    };\n  }, [onClose]);\n\n  useEffect(() => {\n    nameInputRef.current?.focus();\n  }, []);\n\n  return (\n    <div\n      className=\"fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50\"\n      onKeyDown={handleEnter}\n    >\n      <div className=\"fixed inset-0 z-10 overflow-hidden\">\n        <div className=\"flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0\">\n          <div\n            className=\"hidden sm:inline-block sm:h-screen sm:align-middle\"\n            aria-hidden=\"true\"\n          />\n\n          <div\n            ref={modalRef}\n            className=\"dark:border-netural-400 inline-block max-h-[400px] transform overflow-y-auto rounded-lg border border-gray-300 bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all dark:bg-[#161519] sm:my-8 sm:max-h-[600px] sm:w-full sm:max-w-lg sm:p-6 sm:align-middle\"\n            role=\"dialog\"\n          >\n            <div className=\"text-sm font-bold text-black dark:text-neutral-200\">\n              {t('Name')}\n            </div>\n            <input\n              ref={nameInputRef}\n              className=\"mt-2 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100\"\n              placeholder={t('A name for your prompt.') || ''}\n              value={name}\n              onChange={(e) => setName(e.target.value)}\n            />\n\n            <div className=\"mt-6 text-sm font-bold text-black dark:text-neutral-200\">\n              {t('Description')}\n            </div>\n            <textarea\n              className=\"mt-2 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100\"\n              style={{ resize: 'none' }}\n              placeholder={t('A description for your prompt.') || ''}\n              value={description}\n              onChange={(e) => setDescription(e.target.value)}\n              rows={3}\n            />\n\n            <div className=\"mt-6 text-sm font-bold text-black dark:text-neutral-200\">\n              {t('Prompt')}\n            </div>\n            <textarea\n              className=\"mt-2 w-full rounded-lg border border-neutral-600 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100\"\n              style={{ resize: 'none' }}\n              placeholder={\n                t(\n                  'Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}',\n                ) || ''\n              }\n              value={content}\n              onChange={(e) => setContent(e.target.value)}\n              rows={10}\n            />\n\n            <button\n              type=\"button\"\n              className=\"w-full px-4 py-2 mt-6 border rounded-lg shadow border-neutral-600 text-neutral-900 hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300\"\n              onClick={() => {\n                const updatedPrompt = {\n                  ...prompt,\n                  name,\n                  description,\n                  content: content.trim(),\n                };\n\n                onUpdatePrompt(updatedPrompt);\n                onClose();\n              }}\n            >\n              {t('Save')}\n            </button>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Promptbar/components/PromptbarSettings.tsx",
    "content": "import { FC } from 'react';\n\ninterface Props {}\n\nexport const PromptbarSettings: FC<Props> = () => {\n  return <div></div>;\n};\n"
  },
  {
    "path": "ui/components/Promptbar/components/Prompts.tsx",
    "content": "import { FC } from 'react';\n\nimport { Prompt } from '@/types/prompt';\n\nimport { PromptComponent } from './Prompt';\n\ninterface Props {\n  prompts: Prompt[];\n}\n\nexport const Prompts: FC<Props> = ({ prompts }) => {\n  return (\n    <div className=\"flex w-full flex-col gap-1\">\n      {prompts\n        .slice()\n        .reverse()\n        .map((prompt, index) => (\n          <PromptComponent key={index} prompt={prompt} />\n        ))}\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Promptbar/index.ts",
    "content": "export { default } from './Promptbar';\n"
  },
  {
    "path": "ui/components/Search/Search.tsx",
    "content": "import { IconX } from '@tabler/icons-react';\nimport { FC } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\ninterface Props {\n  placeholder: string;\n  searchTerm: string;\n  onSearch: (searchTerm: string) => void;\n}\nconst Search: FC<Props> = ({ placeholder, searchTerm, onSearch }) => {\n  const { t } = useTranslation('sidebar');\n\n  const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n    onSearch(e.target.value);\n  };\n\n  const clearSearch = () => {\n    onSearch('');\n  };\n\n  return (\n    <div className=\"relative flex items-center\">\n      <input\n        className=\"w-full flex-1 rounded-md border border-neutral-700 bg-[#161519] px-4 py-3 pr-10 text-[14px] leading-3 text-white\"\n        type=\"text\"\n        placeholder={t(placeholder) || ''}\n        value={searchTerm}\n        onChange={handleSearchChange}\n      />\n\n      {searchTerm && (\n        <IconX\n          className=\"absolute right-4 cursor-pointer text-neutral-300 hover:text-neutral-400\"\n          size={18}\n          onClick={clearSearch}\n        />\n      )}\n    </div>\n  );\n};\n\nexport default Search;\n"
  },
  {
    "path": "ui/components/Search/index.ts",
    "content": "export { default } from './Search';\n"
  },
  {
    "path": "ui/components/Settings/Import.tsx",
    "content": "import { IconFileImport } from '@tabler/icons-react';\nimport { FC } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { SupportedExportFormats } from '@/types/export';\n\nimport { SidebarButton } from '../Sidebar/SidebarButton';\n\ninterface Props {\n  onImport: (data: SupportedExportFormats) => void;\n}\n\nexport const Import: FC<Props> = ({ onImport }) => {\n  const { t } = useTranslation('sidebar');\n  return (\n    <>\n      <input\n        id=\"import-file\"\n        className=\"sr-only\"\n        tabIndex={-1}\n        type=\"file\"\n        accept=\".json\"\n        onChange={(e) => {\n          if (!e.target.files?.length) return;\n\n          const file = e.target.files[0];\n          const reader = new FileReader();\n          reader.onload = (e) => {\n            let json = JSON.parse(e.target?.result as string);\n            onImport(json);\n          };\n          reader.readAsText(file);\n        }}\n      />\n\n      <SidebarButton\n        text={t('Import data')}\n        icon={<IconFileImport size={18} />}\n        onClick={() => {\n          const importFile = document.querySelector(\n            '#import-file',\n          ) as HTMLInputElement;\n          if (importFile) {\n            importFile.click();\n          }\n        }}\n      />\n    </>\n  );\n};\n"
  },
  {
    "path": "ui/components/Settings/Key.tsx",
    "content": "import { IconCheck, IconKey, IconX } from '@tabler/icons-react';\nimport { FC, KeyboardEvent, useEffect, useRef, useState } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { SidebarButton } from '../Sidebar/SidebarButton';\n\ninterface Props {\n  apiKey: string;\n  onApiKeyChange: (apiKey: string) => void;\n}\n\nexport const Key: FC<Props> = ({ apiKey, onApiKeyChange }) => {\n  const { t } = useTranslation('sidebar');\n  const [isChanging, setIsChanging] = useState(false);\n  const [newKey, setNewKey] = useState(apiKey);\n  const inputRef = useRef<HTMLInputElement>(null);\n\n  const handleEnterDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Enter') {\n      e.preventDefault();\n      handleUpdateKey(newKey);\n    }\n  };\n\n  const handleUpdateKey = (newKey: string) => {\n    onApiKeyChange(newKey.trim());\n    setIsChanging(false);\n  };\n\n  useEffect(() => {\n    if (isChanging) {\n      inputRef.current?.focus();\n    }\n  }, [isChanging]);\n\n  return isChanging ? (\n    <div className=\"duration:200 flex w-full cursor-pointer items-center rounded-md py-3 px-3 transition-colors hover:bg-gray-500/10\">\n      <IconKey size={18} />\n\n      <input\n        ref={inputRef}\n        className=\"ml-2 h-[20px] flex-1 overflow-hidden overflow-ellipsis border-b border-neutral-400 bg-transparent pr-1 text-[12.5px] leading-3 text-left text-white outline-none focus:border-neutral-100\"\n        type=\"password\"\n        value={newKey}\n        onChange={(e) => setNewKey(e.target.value)}\n        onKeyDown={handleEnterDown}\n        placeholder={t('API Key') || 'API Key'}\n      />\n\n      <div className=\"flex w-[40px]\">\n        <IconCheck\n          className=\"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100\"\n          size={18}\n          onClick={(e) => {\n            e.stopPropagation();\n            handleUpdateKey(newKey);\n          }}\n        />\n\n        <IconX\n          className=\"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100\"\n          size={18}\n          onClick={(e) => {\n            e.stopPropagation();\n            setIsChanging(false);\n            setNewKey(apiKey);\n          }}\n        />\n      </div>\n    </div>\n  ) : (\n    <SidebarButton\n      text={t('OpenAI API Key')}\n      icon={<IconKey size={18} />}\n      onClick={() => setIsChanging(true)}\n    />\n  );\n};\n"
  },
  {
    "path": "ui/components/Settings/SettingDialog.tsx",
    "content": "import { FC, useContext, useEffect, useReducer, useRef } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { useCreateReducer } from '@/hooks/useCreateReducer';\n\nimport { getSettings, saveSettings } from '@/utils/app/settings';\n\nimport { Settings } from '@/types/settings';\n\nimport HomeContext from '@/pages/api/home/home.context';\n\ninterface Props {\n  open: boolean;\n  onClose: () => void;\n}\n\nexport const SettingDialog: FC<Props> = ({ open, onClose }) => {\n  const { t } = useTranslation('settings');\n  const settings: Settings = getSettings();\n  const { state, dispatch } = useCreateReducer<Settings>({\n    initialState: settings,\n  });\n  const { dispatch: homeDispatch } = useContext(HomeContext);\n  const modalRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const handleMouseDown = (e: MouseEvent) => {\n      if (modalRef.current && !modalRef.current.contains(e.target as Node)) {\n        window.addEventListener('mouseup', handleMouseUp);\n      }\n    };\n\n    const handleMouseUp = (e: MouseEvent) => {\n      window.removeEventListener('mouseup', handleMouseUp);\n      onClose();\n    };\n\n    window.addEventListener('mousedown', handleMouseDown);\n\n    return () => {\n      window.removeEventListener('mousedown', handleMouseDown);\n    };\n  }, [onClose]);\n\n  const handleSave = () => {\n    homeDispatch({ field: 'lightMode', value: state.theme });\n    saveSettings(state);\n  };\n\n  // Render nothing if the dialog is not open.\n  if (!open) {\n    return <></>;\n  }\n\n  // Render the dialog.\n  return (\n    <div className=\"fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50\">\n      <div className=\"fixed inset-0 z-10 overflow-hidden\">\n        <div className=\"flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0\">\n          <div\n            className=\"hidden sm:inline-block sm:h-screen sm:align-middle\"\n            aria-hidden=\"true\"\n          />\n\n          <div\n            ref={modalRef}\n            className=\"dark:border-netural-400 inline-block max-h-[400px] transform overflow-y-auto rounded-lg border border-gray-300 bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all dark:bg-[#161519] sm:my-8 sm:max-h-[600px] sm:w-full sm:max-w-lg sm:p-6 sm:align-middle\"\n            role=\"dialog\"\n          >\n            <div className=\"text-lg pb-4 font-bold text-black dark:text-neutral-200\">\n              {t('Settings')}\n            </div>\n\n            <div className=\"text-sm font-bold mb-2 text-black dark:text-neutral-200\">\n              {t('Theme')}\n            </div>\n\n            <select\n              className=\"w-full cursor-pointer bg-transparent p-2 text-neutral-700 dark:text-neutral-200\"\n              value={state.theme}\n              onChange={(event) =>\n                dispatch({ field: 'theme', value: event.target.value })\n              }\n            >\n              <option value=\"dark\">{t('Dark mode')}</option>\n              <option value=\"light\">{t('Light mode')}</option>\n            </select>\n\n            <button\n              type=\"button\"\n              className=\"w-full px-4 py-2 mt-6 border rounded-lg shadow border-neutral-600 text-neutral-900 hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300\"\n              onClick={() => {\n                handleSave();\n                onClose();\n              }}\n            >\n              {t('Save')}\n            </button>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n};\n"
  },
  {
    "path": "ui/components/Sidebar/Sidebar.tsx",
    "content": "import { IconFolderPlus, IconMistOff, IconPlus } from '@tabler/icons-react';\nimport { ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport {\n  CloseSidebarButton,\n  OpenSidebarButton,\n} from './components/OpenCloseButton';\n\nimport Search from '../Search';\n\ninterface Props<T> {\n  isOpen: boolean;\n  addItemButtonTitle: string;\n  side: 'left' | 'right';\n  items: T[];\n  itemComponent: ReactNode;\n  folderComponent: ReactNode;\n  footerComponent?: ReactNode;\n  searchTerm: string;\n  handleSearchTerm: (searchTerm: string) => void;\n  toggleOpen: () => void;\n  handleCreateItem: () => void;\n  handleCreateFolder: () => void;\n  handleDrop: (e: any) => void;\n}\n\nconst Sidebar = <T,>({\n  isOpen,\n  addItemButtonTitle,\n  side,\n  items,\n  itemComponent,\n  folderComponent,\n  footerComponent,\n  searchTerm,\n  handleSearchTerm,\n  toggleOpen,\n  handleCreateItem,\n  handleCreateFolder,\n  handleDrop,\n}: Props<T>) => {\n  const { t } = useTranslation('promptbar');\n\n  const allowDrop = (e: any) => {\n    e.preventDefault();\n  };\n\n  const highlightDrop = (e: any) => {\n    e.target.style.background = '#1d1c21';\n  };\n\n  const removeHighlight = (e: any) => {\n    e.target.style.background = 'none';\n  };\n\n  return isOpen ? (\n    <div>\n      <div\n        className={`fixed top-0 ${side}-0 z-40 flex h-full w-[260px] flex-none flex-col space-y-2 bg-[#161519] p-2 text-[14px] transition-all sm:relative sm:top-0`}\n      >\n        <div className=\"flex items-center\">\n          <button\n            className=\"text-sidebar flex w-[190px] flex-shrink-0 cursor-pointer select-none items-center gap-3 rounded-md border border-white/20 p-3 text-white transition-colors duration-200 hover:bg-gray-500/10\"\n            onClick={() => {\n              handleCreateItem();\n              handleSearchTerm('');\n            }}\n          >\n            <IconPlus size={16} />\n            {addItemButtonTitle}\n          </button>\n\n          <button\n            className=\"ml-2 flex flex-shrink-0 cursor-pointer items-center gap-3 rounded-md border border-white/20 p-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10\"\n            onClick={handleCreateFolder}\n          >\n            <IconFolderPlus size={16} />\n          </button>\n        </div>\n        <Search\n          placeholder={t('Search...') || ''}\n          searchTerm={searchTerm}\n          onSearch={handleSearchTerm}\n        />\n\n        <div className=\"flex-grow overflow-auto\">\n          {items?.length > 0 && (\n            <div className=\"flex border-b border-white/20 pb-2\">\n              {folderComponent}\n            </div>\n          )}\n\n          {items?.length > 0 ? (\n            <div\n              className=\"pt-2\"\n              onDrop={handleDrop}\n              onDragOver={allowDrop}\n              onDragEnter={highlightDrop}\n              onDragLeave={removeHighlight}\n            >\n              {itemComponent}\n            </div>\n          ) : (\n            <div className=\"mt-8 select-none text-center text-white opacity-50\">\n              <IconMistOff className=\"mx-auto mb-3\" />\n              <span className=\"text-[14px] leading-normal\">\n                {t('No data.')}\n              </span>\n            </div>\n          )}\n        </div>\n        {footerComponent}\n      </div>\n\n      <CloseSidebarButton onClick={toggleOpen} side={side} />\n    </div>\n  ) : (\n    <OpenSidebarButton onClick={toggleOpen} side={side} />\n  );\n};\n\nexport default Sidebar;\n"
  },
  {
    "path": "ui/components/Sidebar/SidebarButton.tsx",
    "content": "import { FC } from 'react';\n\ninterface Props {\n  text: string;\n  icon: JSX.Element;\n  onClick: () => void;\n}\n\nexport const SidebarButton: FC<Props> = ({ text, icon, onClick }) => {\n  return (\n    <button\n      className=\"flex w-full cursor-pointer select-none items-center gap-3 rounded-md py-3 px-3 text-[14px] leading-3 text-white transition-colors duration-200 hover:bg-gray-500/10\"\n      onClick={onClick}\n    >\n      <div>{icon}</div>\n      <span>{text}</span>\n    </button>\n  );\n};\n"
  },
  {
    "path": "ui/components/Sidebar/components/OpenCloseButton.tsx",
    "content": "import { IconArrowBarLeft, IconArrowBarRight } from '@tabler/icons-react';\n\ninterface Props {\n  onClick: any;\n  side: 'left' | 'right';\n}\n\nexport const CloseSidebarButton = ({ onClick, side }: Props) => {\n  return (\n    <>\n      <button\n        className={`fixed top-5 ${\n          side === 'right' ? 'right-[270px]' : 'left-[270px]'\n        } z-50 h-7 w-7 hover:text-gray-400 dark:text-white dark:hover:text-gray-300 sm:top-0.5 sm:${\n          side === 'right' ? 'right-[270px]' : 'left-[270px]'\n        } sm:h-8 sm:w-8 sm:text-neutral-700`}\n        onClick={onClick}\n      >\n        {side === 'right' ? <IconArrowBarRight /> : <IconArrowBarLeft />}\n      </button>\n      <div\n        onClick={onClick}\n        className=\"absolute top-0 left-0 z-10 h-full w-full bg-black opacity-70 sm:hidden\"\n      ></div>\n    </>\n  );\n};\n\nexport const OpenSidebarButton = ({ onClick, side }: Props) => {\n  return (\n    <button\n      className={`fixed top-2.5 ${\n        side === 'right' ? 'right-2' : 'left-2'\n      } z-50 h-7 w-7 text-white hover:text-gray-400 dark:text-white dark:hover:text-gray-300 sm:top-0.5 sm:${\n        side === 'right' ? 'right-2' : 'left-2'\n      } sm:h-8 sm:w-8 sm:text-neutral-700`}\n      onClick={onClick}\n    >\n      {side === 'right' ? <IconArrowBarLeft /> : <IconArrowBarRight />}\n    </button>\n  );\n};\n"
  },
  {
    "path": "ui/components/Sidebar/index.ts",
    "content": "export { default } from './Sidebar';\n"
  },
  {
    "path": "ui/components/Spinner/Spinner.tsx",
    "content": "import { FC } from 'react';\n\ninterface Props {\n  size?: string;\n  className?: string;\n}\n\nconst Spinner = ({ size = '1em', className = '' }: Props) => {\n  return (\n    <svg\n      stroke=\"currentColor\"\n      fill=\"none\"\n      strokeWidth=\"2\"\n      viewBox=\"0 0 24 24\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      className={`animate-spin ${className}`}\n      height={size}\n      width={size}\n      xmlns=\"http://www.w3.org/2000/svg\"\n    >\n      <line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"6\"></line>\n      <line x1=\"12\" y1=\"18\" x2=\"12\" y2=\"22\"></line>\n      <line x1=\"4.93\" y1=\"4.93\" x2=\"7.76\" y2=\"7.76\"></line>\n      <line x1=\"16.24\" y1=\"16.24\" x2=\"19.07\" y2=\"19.07\"></line>\n      <line x1=\"2\" y1=\"12\" x2=\"6\" y2=\"12\"></line>\n      <line x1=\"18\" y1=\"12\" x2=\"22\" y2=\"12\"></line>\n      <line x1=\"4.93\" y1=\"19.07\" x2=\"7.76\" y2=\"16.24\"></line>\n      <line x1=\"16.24\" y1=\"7.76\" x2=\"19.07\" y2=\"4.93\"></line>\n    </svg>\n  );\n};\n\nexport default Spinner;\n"
  },
  {
    "path": "ui/components/Spinner/index.ts",
    "content": "export { default } from './Spinner';\n"
  },
  {
    "path": "ui/docker-compose.yml",
    "content": "version: '3.6'\n\nservices:\n  chatgpt:\n    build: .\n    ports:\n      - 3000:3000\n    environment:\n      - 'OPENAI_API_KEY='\n"
  },
  {
    "path": "ui/docs/google_search.md",
    "content": "# Google Search Tool\n\nUse the Google Search API to search the web in Chatbot UI.\n\n## How To Enable\n\n1. Create a new project at https://console.developers.google.com/apis/dashboard\n\n2. Create a new API key at https://console.developers.google.com/apis/credentials\n\n3. Enable the Custom Search API at https://console.developers.google.com/apis/library/customsearch.googleapis.com\n\n4. Create a new Custom Search Engine at https://cse.google.com/cse/all\n\n5. Add your API Key and your Custom Search Engine ID to your .env.local file\n\n6. You can now select the Google Search Tool in the search tools dropdown\n\n## Usage Limits\n\nGoogle gives you 100 free searches per day. You can increase this limit by creating a billing account.\n"
  },
  {
    "path": "ui/hooks/useCreateReducer.ts",
    "content": "import { useMemo, useReducer } from 'react';\n\n// Extracts property names from initial state of reducer to allow typesafe dispatch objects\nexport type FieldNames<T> = {\n  [K in keyof T]: T[K] extends string ? K : K;\n}[keyof T];\n\n// Returns the Action Type for the dispatch object to be used for typing in things like context\nexport type ActionType<T> =\n  | { type: 'reset' }\n  | { type?: 'change'; field: FieldNames<T>; value: any };\n\n// Returns a typed dispatch and state\nexport const useCreateReducer = <T>({ initialState }: { initialState: T }) => {\n  type Action =\n    | { type: 'reset' }\n    | { type?: 'change'; field: FieldNames<T>; value: any };\n\n  const reducer = (state: T, action: Action) => {\n    if (!action.type) return { ...state, [action.field]: action.value };\n\n    if (action.type === 'reset') return initialState;\n\n    throw new Error();\n  };\n\n  const [state, dispatch] = useReducer(reducer, initialState);\n\n  return useMemo(() => ({ state, dispatch }), [state, dispatch]);\n};\n"
  },
  {
    "path": "ui/hooks/useFetch.ts",
    "content": "export type RequestModel = {\n  params?: object;\n  headers?: object;\n  signal?: AbortSignal;\n};\n\nexport type RequestWithBodyModel = RequestModel & {\n  body?: object | FormData;\n};\n\nexport const useFetch = () => {\n  const handleFetch = async (\n    url: string,\n    request: any,\n    signal?: AbortSignal,\n  ) => {\n    const requestUrl = request?.params ? `${url}${request.params}` : url;\n\n    const requestBody = request?.body\n      ? request.body instanceof FormData\n        ? { ...request, body: request.body }\n        : { ...request, body: JSON.stringify(request.body) }\n      : request;\n\n    const headers = {\n      ...(request?.headers\n        ? request.headers\n        : request?.body && request.body instanceof FormData\n        ? {}\n        : { 'Content-type': 'application/json' }),\n    };\n\n    return fetch(requestUrl, { ...requestBody, headers, signal })\n      .then((response) => {\n        if (!response.ok) throw response;\n\n        const contentType = response.headers.get('content-type');\n        const contentDisposition = response.headers.get('content-disposition');\n\n        const headers = response.headers;\n\n        const result =\n          contentType &&\n          (contentType?.indexOf('application/json') !== -1 ||\n            contentType?.indexOf('text/plain') !== -1)\n            ? response.json()\n            : contentDisposition?.indexOf('attachment') !== -1\n            ? response.blob()\n            : response;\n\n        return result;\n      })\n      .catch(async (err) => {\n        const contentType = err.headers.get('content-type');\n\n        const errResult =\n          contentType && contentType?.indexOf('application/problem+json') !== -1\n            ? await err.json()\n            : err;\n\n        throw errResult;\n      });\n  };\n\n  return {\n    get: async <T>(url: string, request?: RequestModel): Promise<T> => {\n      return handleFetch(url, { ...request, method: 'get' });\n    },\n    post: async <T>(\n      url: string,\n      request?: RequestWithBodyModel,\n    ): Promise<T> => {\n      return handleFetch(url, { ...request, method: 'post' });\n    },\n    put: async <T>(url: string, request?: RequestWithBodyModel): Promise<T> => {\n      return handleFetch(url, { ...request, method: 'put' });\n    },\n    patch: async <T>(\n      url: string,\n      request?: RequestWithBodyModel,\n    ): Promise<T> => {\n      return handleFetch(url, { ...request, method: 'patch' });\n    },\n    delete: async <T>(url: string, request?: RequestModel): Promise<T> => {\n      return handleFetch(url, { ...request, method: 'delete' });\n    },\n  };\n};\n"
  },
  {
    "path": "ui/k8s/chatbot-ui.yaml",
    "content": "apiVersion: v1\nkind: Namespace\nmetadata:\n  name: chatbot-ui\n---\napiVersion: v1\nkind: Secret\nmetadata:\n  namespace: chatbot-ui\n  name: chatbot-ui\ntype: Opaque\ndata:\n  OPENAI_API_KEY: <base64 encoded key>\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  namespace: chatbot-ui\n  name: chatbot-ui\n  labels:\n    app: chatbot-ui\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: chatbot-ui\n  template:\n    metadata:\n      labels:\n        app: chatbot-ui\n    spec:\n      containers:\n        - name: chatbot-ui\n          image: <docker user>/chatbot-ui:latest\n          resources: {}\n          ports:\n            - containerPort: 3000\n          env:\n            - name: OPENAI_API_KEY\n              valueFrom:\n                secretKeyRef:\n                  name: chatbot-ui\n                  key: OPENAI_API_KEY\n---\nkind: Service\napiVersion: v1\nmetadata:\n  namespace: chatbot-ui\n  name: chatbot-ui\n  labels:\n    app: chatbot-ui\nspec:\n  ports:\n    - name: http\n      protocol: TCP\n      port: 80\n      targetPort: 3000\n  selector:\n    app: chatbot-ui\n  type: ClusterIP\n"
  },
  {
    "path": "ui/next-i18next.config.js",
    "content": "module.exports = {\n  i18n: {\n    defaultLocale: 'en',\n    locales: [\n      \"bn\",\n      \"de\",\n      \"en\",\n      \"es\",\n      \"fr\",\n      \"he\",\n      \"id\",\n      \"it\",\n      \"ja\",\n      \"ko\",\n      \"pl\",\n      \"pt\",\n      \"ru\",\n      \"ro\",      \n      \"sv\",\n      \"te\",\n      \"vi\",\n      \"zh\",\n      \"ar\",\n      \"tr\",\n      \"ca\",\n      \"fi\",\n    ],\n  },\n  localePath:\n    typeof window === 'undefined'\n      ? require('path').resolve('./public/locales')\n      : '/public/locales',\n};\n"
  },
  {
    "path": "ui/next.config.js",
    "content": "const { i18n } = require('./next-i18next.config');\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  i18n,\n  reactStrictMode: true,\n\n  webpack(config, { isServer, dev }) {\n    config.experiments = {\n      asyncWebAssembly: true,\n      layers: true,\n    };\n\n    return config;\n  },\n};\n\nmodule.exports = nextConfig;\n"
  },
  {
    "path": "ui/no-wait.Dockerfile",
    "content": "# ---- Base Node ----\nFROM node:19-alpine AS base\nWORKDIR /app\nCOPY package*.json ./\n\n# ---- Dependencies ----\nFROM base AS dependencies\nRUN npm ci\n\n# ---- Build ----\nFROM dependencies AS build\nCOPY . .\nRUN npm run build\n\n# ---- Production ----\nFROM node:19-alpine AS production\nWORKDIR /app\nCOPY --from=dependencies /app/node_modules ./node_modules\nCOPY --from=build /app/.next ./.next\nCOPY --from=build /app/public ./public\nCOPY --from=build /app/package*.json ./\nCOPY --from=build /app/next.config.js ./next.config.js\nCOPY --from=build /app/next-i18next.config.js ./next-i18next.config.js\n\n# Expose the port the app will run on\nEXPOSE 3000\n\n# Start the application after the API is ready\nCMD npm start\n\n"
  },
  {
    "path": "ui/package.json",
    "content": "{\n  \"name\": \"ai-chatbot-starter\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"next dev\",\n    \"build\": \"next build\",\n    \"start\": \"next start\",\n    \"lint\": \"next lint\",\n    \"format\": \"prettier --write .\",\n    \"test\": \"vitest\",\n    \"coverage\": \"vitest run --coverage\"\n  },\n  \"dependencies\": {\n    \"@dqbd/tiktoken\": \"^1.0.2\",\n    \"@tabler/icons-react\": \"^2.9.0\",\n    \"eventsource-parser\": \"^0.1.0\",\n    \"i18next\": \"^22.4.13\",\n    \"next\": \"13.2.4\",\n    \"next-i18next\": \"^13.2.2\",\n    \"openai\": \"^3.2.1\",\n    \"react\": \"18.2.0\",\n    \"react-dom\": \"18.2.0\",\n    \"react-hot-toast\": \"^2.4.0\",\n    \"react-i18next\": \"^12.2.0\",\n    \"react-markdown\": \"^8.0.5\",\n    \"react-query\": \"^3.39.3\",\n    \"react-syntax-highlighter\": \"^15.5.0\",\n    \"rehype-mathjax\": \"^4.0.2\",\n    \"remark-gfm\": \"^3.0.1\",\n    \"remark-math\": \"^5.1.1\",\n    \"uuid\": \"^9.0.0\"\n  },\n  \"devDependencies\": {\n    \"@mozilla/readability\": \"^0.4.4\",\n    \"@tailwindcss/typography\": \"^0.5.9\",\n    \"@trivago/prettier-plugin-sort-imports\": \"^4.1.1\",\n    \"@types/jsdom\": \"^21.1.1\",\n    \"@types/node\": \"18.15.0\",\n    \"@types/react\": \"18.0.28\",\n    \"@types/react-dom\": \"18.0.11\",\n    \"@types/react-syntax-highlighter\": \"^15.5.6\",\n    \"@types/uuid\": \"^9.0.1\",\n    \"@vitest/coverage-c8\": \"^0.29.7\",\n    \"autoprefixer\": \"^10.4.14\",\n    \"endent\": \"^2.1.0\",\n    \"eslint\": \"8.36.0\",\n    \"eslint-config-next\": \"13.2.4\",\n    \"gpt-3-encoder\": \"^1.1.4\",\n    \"jsdom\": \"^21.1.1\",\n    \"postcss\": \"^8.4.21\",\n    \"prettier\": \"^2.8.7\",\n    \"prettier-plugin-tailwindcss\": \"^0.2.5\",\n    \"tailwindcss\": \"^3.2.7\",\n    \"typescript\": \"4.9.5\",\n    \"vitest\": \"^0.29.7\"\n  }\n}\n"
  },
  {
    "path": "ui/pages/_app.tsx",
    "content": "import { Toaster } from 'react-hot-toast';\nimport { QueryClient, QueryClientProvider } from 'react-query';\n\nimport { appWithTranslation } from 'next-i18next';\nimport type { AppProps } from 'next/app';\nimport { Inter } from 'next/font/google';\n\nimport '@/styles/globals.css';\n\nconst inter = Inter({ subsets: ['latin'] });\n\nfunction App({ Component, pageProps }: AppProps<{}>) {\n  const queryClient = new QueryClient();\n\n  return (\n    <div className={inter.className}>\n      <Toaster />\n      <QueryClientProvider client={queryClient}>\n        <Component {...pageProps} />\n      </QueryClientProvider>\n    </div>\n  );\n}\n\nexport default appWithTranslation(App);\n"
  },
  {
    "path": "ui/pages/_document.tsx",
    "content": "import { DocumentProps, Head, Html, Main, NextScript } from 'next/document';\n\n// import i18nextConfig from '../next-i18next.config';\n\ntype Props = DocumentProps & {\n  // add custom document props\n};\n\nexport default function Document(props: Props) {\n  // const currentLocale =\n  //   props.__NEXT_DATA__.locale ?? i18nextConfig.i18n.defaultLocale;\n  return (\n    // <Html lang={currentLocale}>\n    <Html>\n      <Head>\n        <meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n        <meta name=\"apple-mobile-web-app-title\" content=\"LlamaGPT\"></meta>\n      </Head>\n      <body>\n        <Main />\n        <NextScript />\n      </body>\n    </Html>\n  );\n}\n"
  },
  {
    "path": "ui/pages/api/chat.ts",
    "content": "import { DEFAULT_SYSTEM_PROMPT, DEFAULT_TEMPERATURE } from '@/utils/app/const';\nimport { OpenAIError, OpenAIStream } from '@/utils/server';\n\nimport { ChatBody, Message } from '@/types/chat';\n\n// @ts-expect-error\nimport wasm from '../../node_modules/@dqbd/tiktoken/lite/tiktoken_bg.wasm?module';\n\nimport tiktokenModel from '@dqbd/tiktoken/encoders/cl100k_base.json';\nimport { Tiktoken, init } from '@dqbd/tiktoken/lite/init';\n\nexport const config = {\n  runtime: 'edge',\n};\n\nconst handler = async (req: Request): Promise<Response> => {\n  try {\n    const { model, messages, key, prompt, temperature } = (await req.json()) as ChatBody;\n\n    await init((imports) => WebAssembly.instantiate(wasm, imports));\n    const encoding = new Tiktoken(\n      tiktokenModel.bpe_ranks,\n      tiktokenModel.special_tokens,\n      tiktokenModel.pat_str,\n    );\n\n    let promptToSend = prompt;\n    if (!promptToSend) {\n      promptToSend = DEFAULT_SYSTEM_PROMPT;\n    }\n\n    let temperatureToUse = temperature;\n    if (temperatureToUse == null) {\n      temperatureToUse = DEFAULT_TEMPERATURE;\n    }\n\n    const prompt_tokens = encoding.encode(promptToSend);\n\n    let tokenCount = prompt_tokens.length;\n    let messagesToSend: Message[] = [];\n\n    for (let i = messages.length - 1; i >= 0; i--) {\n      const message = messages[i];\n      const tokens = encoding.encode(message.content);\n\n      if (tokenCount + tokens.length + 1000 > model.tokenLimit) {\n        break;\n      }\n      tokenCount += tokens.length;\n      messagesToSend = [message, ...messagesToSend];\n    }\n\n    encoding.free();\n\n    console.log(model,  promptToSend, temperatureToUse, key, messagesToSend);\n\n    const stream = await OpenAIStream(model, promptToSend, temperatureToUse, key, messagesToSend);\n\n    return new Response(stream);\n  } catch (error) {\n    console.error(error);\n    if (error instanceof OpenAIError) {\n      return new Response('Error', { status: 500, statusText: error.message });\n    } else {\n      return new Response('Error', { status: 500 });\n    }\n  }\n};\n\nexport default handler;\n"
  },
  {
    "path": "ui/pages/api/google.ts",
    "content": "import { NextApiRequest, NextApiResponse } from 'next';\n\nimport { OPENAI_API_HOST } from '@/utils/app/const';\nimport { cleanSourceText } from '@/utils/server/google';\n\nimport { Message } from '@/types/chat';\nimport { GoogleBody, GoogleSource } from '@/types/google';\n\nimport { Readability } from '@mozilla/readability';\nimport endent from 'endent';\nimport jsdom, { JSDOM } from 'jsdom';\n\nconst handler = async (req: NextApiRequest, res: NextApiResponse<any>) => {\n  try {\n    const { messages, key, model, googleAPIKey, googleCSEId } =\n      req.body as GoogleBody;\n\n    const userMessage = messages[messages.length - 1];\n    const query = encodeURIComponent(userMessage.content.trim());\n\n    const googleRes = await fetch(\n      `https://customsearch.googleapis.com/customsearch/v1?key=${\n        googleAPIKey ? googleAPIKey : process.env.GOOGLE_API_KEY\n      }&cx=${\n        googleCSEId ? googleCSEId : process.env.GOOGLE_CSE_ID\n      }&q=${query}&num=5`,\n    );\n\n    const googleData = await googleRes.json();\n\n    const sources: GoogleSource[] = googleData.items.map((item: any) => ({\n      title: item.title,\n      link: item.link,\n      displayLink: item.displayLink,\n      snippet: item.snippet,\n      image: item.pagemap?.cse_image?.[0]?.src,\n      text: '',\n    }));\n\n    const sourcesWithText: any = await Promise.all(\n      sources.map(async (source) => {\n        try {\n          const timeoutPromise = new Promise((_, reject) =>\n            setTimeout(() => reject(new Error('Request timed out')), 5000),\n          );\n\n          const res = (await Promise.race([\n            fetch(source.link),\n            timeoutPromise,\n          ])) as any;\n\n          // if (res) {\n          const html = await res.text();\n\n          const virtualConsole = new jsdom.VirtualConsole();\n          virtualConsole.on('error', (error) => {\n            if (!error.message.includes('Could not parse CSS stylesheet')) {\n              console.error(error);\n            }\n          });\n\n          const dom = new JSDOM(html, { virtualConsole });\n          const doc = dom.window.document;\n          const parsed = new Readability(doc).parse();\n\n          if (parsed) {\n            let sourceText = cleanSourceText(parsed.textContent);\n\n            return {\n              ...source,\n              // TODO: switch to tokens\n              text: sourceText.slice(0, 2000),\n            } as GoogleSource;\n          }\n          // }\n\n          return null;\n        } catch (error) {\n          console.error(error);\n          return null;\n        }\n      }),\n    );\n\n    const filteredSources: GoogleSource[] = sourcesWithText.filter(Boolean);\n\n    const answerPrompt = endent`\n    Provide me with the information I requested. Use the sources to provide an accurate response. Respond in markdown format. Cite the sources you used as a markdown link as you use them at the end of each sentence by number of the source (ex: [[1]](link.com)). Provide an accurate response and then stop. Today's date is ${new Date().toLocaleDateString()}.\n\n    Example Input:\n    What's the weather in San Francisco today?\n\n    Example Sources:\n    [Weather in San Francisco](https://www.google.com/search?q=weather+san+francisco)\n\n    Example Response:\n    It's 70 degrees and sunny in San Francisco today. [[1]](https://www.google.com/search?q=weather+san+francisco)\n\n    Input:\n    ${userMessage.content.trim()}\n\n    Sources:\n    ${filteredSources.map((source) => {\n      return endent`\n      ${source.title} (${source.link}):\n      ${source.text}\n      `;\n    })}\n\n    Response:\n    `;\n\n    const answerMessage: Message = { role: 'user', content: answerPrompt };\n\n    const answerRes = await fetch(`${OPENAI_API_HOST}/v1/chat/completions`, {\n      headers: {\n        'Content-Type': 'application/json',\n        Authorization: `Bearer ${key ? key : process.env.OPENAI_API_KEY}`,\n        ...(process.env.OPENAI_ORGANIZATION && {\n          'OpenAI-Organization': process.env.OPENAI_ORGANIZATION,\n        }),\n      },\n      method: 'POST',\n      body: JSON.stringify({\n        model: model.id,\n        messages: [\n          {\n            role: 'system',\n            content: `Use the sources to provide an accurate response. Respond in markdown format. Cite the sources you used as [1](link), etc, as you use them. Maximum 4 sentences.`,\n          },\n          answerMessage,\n        ],\n        max_tokens: 1000,\n        temperature: 1,\n        stream: false,\n      }),\n    });\n\n    const { choices: choices2 } = await answerRes.json();\n    const answer = choices2[0].message.content;\n\n    res.status(200).json({ answer });\n  } catch (error) {\n    console.error(error);\n    res.status(500).json({ error: 'Error'})\n  }\n};\n\nexport default handler;\n"
  },
  {
    "path": "ui/pages/api/home/home.context.tsx",
    "content": "import { Dispatch, createContext } from 'react';\n\nimport { ActionType } from '@/hooks/useCreateReducer';\n\nimport { Conversation } from '@/types/chat';\nimport { KeyValuePair } from '@/types/data';\nimport { FolderType } from '@/types/folder';\n\nimport { HomeInitialState } from './home.state';\n\nexport interface HomeContextProps {\n  state: HomeInitialState;\n  dispatch: Dispatch<ActionType<HomeInitialState>>;\n  handleNewConversation: () => void;\n  handleCreateFolder: (name: string, type: FolderType) => void;\n  handleDeleteFolder: (folderId: string) => void;\n  handleUpdateFolder: (folderId: string, name: string) => void;\n  handleSelectConversation: (conversation: Conversation) => void;\n  handleUpdateConversation: (\n    conversation: Conversation,\n    data: KeyValuePair,\n  ) => void;\n}\n\nconst HomeContext = createContext<HomeContextProps>(undefined!);\n\nexport default HomeContext;\n"
  },
  {
    "path": "ui/pages/api/home/home.state.tsx",
    "content": "import { Conversation, Message } from '@/types/chat';\nimport { ErrorMessage } from '@/types/error';\nimport { FolderInterface } from '@/types/folder';\nimport { OpenAIModel, OpenAIModelID } from '@/types/openai';\nimport { PluginKey } from '@/types/plugin';\nimport { Prompt } from '@/types/prompt';\n\nexport interface HomeInitialState {\n  apiKey: string;\n  pluginKeys: PluginKey[];\n  loading: boolean;\n  lightMode: 'light' | 'dark';\n  messageIsStreaming: boolean;\n  modelError: ErrorMessage | null;\n  models: OpenAIModel[];\n  folders: FolderInterface[];\n  conversations: Conversation[];\n  selectedConversation: Conversation | undefined;\n  currentMessage: Message | undefined;\n  prompts: Prompt[];\n  temperature: number;\n  showChatbar: boolean;\n  showPromptbar: boolean;\n  currentFolder: FolderInterface | undefined;\n  messageError: boolean;\n  searchTerm: string;\n  defaultModelId: OpenAIModelID | undefined;\n  serverSideApiKeyIsSet: boolean;\n  serverSidePluginKeysSet: boolean;\n}\n\nexport const initialState: HomeInitialState = {\n  apiKey: '',\n  loading: false,\n  pluginKeys: [],\n  lightMode: 'dark',\n  messageIsStreaming: false,\n  modelError: null,\n  models: [],\n  folders: [],\n  conversations: [],\n  selectedConversation: undefined,\n  currentMessage: undefined,\n  prompts: [],\n  temperature: 1,\n  showPromptbar: true,\n  showChatbar: true,\n  currentFolder: undefined,\n  messageError: false,\n  searchTerm: '',\n  defaultModelId: undefined,\n  serverSideApiKeyIsSet: false,\n  serverSidePluginKeysSet: false,\n};\n"
  },
  {
    "path": "ui/pages/api/home/home.tsx",
    "content": "import { useEffect, useRef, useState } from 'react';\nimport { useQuery } from 'react-query';\n\nimport { GetServerSideProps } from 'next';\nimport { useTranslation } from 'next-i18next';\nimport { serverSideTranslations } from 'next-i18next/serverSideTranslations';\nimport Head from 'next/head';\n\nimport { useCreateReducer } from '@/hooks/useCreateReducer';\n\nimport useErrorService from '@/services/errorService';\nimport useApiService from '@/services/useApiService';\n\nimport {\n  cleanConversationHistory,\n  cleanSelectedConversation,\n} from '@/utils/app/clean';\nimport { DEFAULT_SYSTEM_PROMPT, DEFAULT_TEMPERATURE } from '@/utils/app/const';\nimport {\n  saveConversation,\n  saveConversations,\n  updateConversation,\n} from '@/utils/app/conversation';\nimport { saveFolders } from '@/utils/app/folders';\nimport { savePrompts } from '@/utils/app/prompts';\nimport { getSettings } from '@/utils/app/settings';\n\nimport { Conversation } from '@/types/chat';\nimport { KeyValuePair } from '@/types/data';\nimport { FolderInterface, FolderType } from '@/types/folder';\nimport { OpenAIModelID, OpenAIModels, fallbackModelID } from '@/types/openai';\nimport { Prompt } from '@/types/prompt';\n\nimport { Chat } from '@/components/Chat/Chat';\nimport { Chatbar } from '@/components/Chatbar/Chatbar';\nimport { Navbar } from '@/components/Mobile/Navbar';\nimport Promptbar from '@/components/Promptbar';\n\nimport HomeContext from './home.context';\nimport { HomeInitialState, initialState } from './home.state';\n\nimport { v4 as uuidv4 } from 'uuid';\n\ninterface Props {\n  serverSideApiKeyIsSet: boolean;\n  serverSidePluginKeysSet: boolean;\n  defaultModelId: OpenAIModelID;\n}\n\nconst Home = ({\n  serverSideApiKeyIsSet,\n  serverSidePluginKeysSet,\n  defaultModelId,\n}: Props) => {\n  const { t } = useTranslation('chat');\n  const { getModels } = useApiService();\n  const { getModelsError } = useErrorService();\n  const [initialRender, setInitialRender] = useState<boolean>(true);\n\n  const contextValue = useCreateReducer<HomeInitialState>({\n    initialState,\n  });\n\n  const {\n    state: {\n      apiKey,\n      lightMode,\n      folders,\n      conversations,\n      selectedConversation,\n      prompts,\n      temperature,\n    },\n    dispatch,\n  } = contextValue;\n\n  const stopConversationRef = useRef<boolean>(false);\n\n  const { data, error, refetch } = useQuery(\n    ['GetModels', apiKey, serverSideApiKeyIsSet],\n    ({ signal }) => {\n      if (!apiKey && !serverSideApiKeyIsSet) return null;\n\n      return getModels(\n        {\n          key: apiKey,\n        },\n        signal,\n      );\n    },\n    { enabled: true, refetchOnMount: false },\n  );\n\n  useEffect(() => {\n    if (data) dispatch({ field: 'models', value: data });\n  }, [data, dispatch]);\n\n  useEffect(() => {\n    dispatch({ field: 'modelError', value: getModelsError(error) });\n  }, [dispatch, error, getModelsError]);\n\n  // FETCH MODELS ----------------------------------------------\n\n  const handleSelectConversation = (conversation: Conversation) => {\n    dispatch({\n      field: 'selectedConversation',\n      value: conversation,\n    });\n\n    saveConversation(conversation);\n  };\n\n  // FOLDER OPERATIONS  --------------------------------------------\n\n  const handleCreateFolder = (name: string, type: FolderType) => {\n    const newFolder: FolderInterface = {\n      id: uuidv4(),\n      name,\n      type,\n    };\n\n    const updatedFolders = [...folders, newFolder];\n\n    dispatch({ field: 'folders', value: updatedFolders });\n    saveFolders(updatedFolders);\n  };\n\n  const handleDeleteFolder = (folderId: string) => {\n    const updatedFolders = folders.filter((f) => f.id !== folderId);\n    dispatch({ field: 'folders', value: updatedFolders });\n    saveFolders(updatedFolders);\n\n    const updatedConversations: Conversation[] = conversations.map((c) => {\n      if (c.folderId === folderId) {\n        return {\n          ...c,\n          folderId: null,\n        };\n      }\n\n      return c;\n    });\n\n    dispatch({ field: 'conversations', value: updatedConversations });\n    saveConversations(updatedConversations);\n\n    const updatedPrompts: Prompt[] = prompts.map((p) => {\n      if (p.folderId === folderId) {\n        return {\n          ...p,\n          folderId: null,\n        };\n      }\n\n      return p;\n    });\n\n    dispatch({ field: 'prompts', value: updatedPrompts });\n    savePrompts(updatedPrompts);\n  };\n\n  const handleUpdateFolder = (folderId: string, name: string) => {\n    const updatedFolders = folders.map((f) => {\n      if (f.id === folderId) {\n        return {\n          ...f,\n          name,\n        };\n      }\n\n      return f;\n    });\n\n    dispatch({ field: 'folders', value: updatedFolders });\n\n    saveFolders(updatedFolders);\n  };\n\n  // CONVERSATION OPERATIONS  --------------------------------------------\n\n  const handleNewConversation = () => {\n    const lastConversation = conversations[conversations.length - 1];\n\n    const newConversation: Conversation = {\n      id: uuidv4(),\n      name: t('New Conversation'),\n      messages: [],\n      model: lastConversation?.model || {\n        id: OpenAIModels[defaultModelId].id,\n        name: OpenAIModels[defaultModelId].name,\n        maxLength: OpenAIModels[defaultModelId].maxLength,\n        tokenLimit: OpenAIModels[defaultModelId].tokenLimit,\n      },\n      prompt: DEFAULT_SYSTEM_PROMPT,\n      temperature: lastConversation?.temperature ?? DEFAULT_TEMPERATURE,\n      folderId: null,\n    };\n\n    const updatedConversations = [...conversations, newConversation];\n\n    dispatch({ field: 'selectedConversation', value: newConversation });\n    dispatch({ field: 'conversations', value: updatedConversations });\n\n    saveConversation(newConversation);\n    saveConversations(updatedConversations);\n\n    dispatch({ field: 'loading', value: false });\n  };\n\n  const handleUpdateConversation = (\n    conversation: Conversation,\n    data: KeyValuePair,\n  ) => {\n    const updatedConversation = {\n      ...conversation,\n      [data.key]: data.value,\n    };\n\n    const { single, all } = updateConversation(\n      updatedConversation,\n      conversations,\n    );\n\n    dispatch({ field: 'selectedConversation', value: single });\n    dispatch({ field: 'conversations', value: all });\n  };\n\n  // EFFECTS  --------------------------------------------\n\n  useEffect(() => {\n    if (window.innerWidth < 640) {\n      dispatch({ field: 'showChatbar', value: false });\n    }\n  }, [selectedConversation]);\n\n  useEffect(() => {\n    defaultModelId &&\n      dispatch({ field: 'defaultModelId', value: defaultModelId });\n    serverSideApiKeyIsSet &&\n      dispatch({\n        field: 'serverSideApiKeyIsSet',\n        value: serverSideApiKeyIsSet,\n      });\n    serverSidePluginKeysSet &&\n      dispatch({\n        field: 'serverSidePluginKeysSet',\n        value: serverSidePluginKeysSet,\n      });\n  }, [defaultModelId, serverSideApiKeyIsSet, serverSidePluginKeysSet]);\n\n  // ON LOAD --------------------------------------------\n\n  useEffect(() => {\n    const settings = getSettings();\n    if (settings.theme) {\n      dispatch({\n        field: 'lightMode',\n        value: settings.theme,\n      });\n    }\n\n    const apiKey = localStorage.getItem('apiKey');\n\n    if (serverSideApiKeyIsSet) {\n      dispatch({ field: 'apiKey', value: '' });\n\n      localStorage.removeItem('apiKey');\n    } else if (apiKey) {\n      dispatch({ field: 'apiKey', value: apiKey });\n    }\n\n    const pluginKeys = localStorage.getItem('pluginKeys');\n    if (serverSidePluginKeysSet) {\n      dispatch({ field: 'pluginKeys', value: [] });\n      localStorage.removeItem('pluginKeys');\n    } else if (pluginKeys) {\n      dispatch({ field: 'pluginKeys', value: pluginKeys });\n    }\n\n    if (window.innerWidth < 640) {\n      dispatch({ field: 'showChatbar', value: false });\n      dispatch({ field: 'showPromptbar', value: false });\n    }\n\n    const showChatbar = localStorage.getItem('showChatbar');\n    if (showChatbar) {\n      dispatch({ field: 'showChatbar', value: showChatbar === 'true' });\n    }\n\n    const showPromptbar = localStorage.getItem('showPromptbar');\n    if (showPromptbar) {\n      dispatch({ field: 'showPromptbar', value: showPromptbar === 'true' });\n    }\n\n    const folders = localStorage.getItem('folders');\n    if (folders) {\n      dispatch({ field: 'folders', value: JSON.parse(folders) });\n    }\n\n    const prompts = localStorage.getItem('prompts');\n    if (prompts) {\n      dispatch({ field: 'prompts', value: JSON.parse(prompts) });\n    }\n\n    const conversationHistory = localStorage.getItem('conversationHistory');\n    if (conversationHistory) {\n      const parsedConversationHistory: Conversation[] =\n        JSON.parse(conversationHistory);\n      const cleanedConversationHistory = cleanConversationHistory(\n        parsedConversationHistory,\n      );\n\n      dispatch({ field: 'conversations', value: cleanedConversationHistory });\n    }\n\n    const selectedConversation = localStorage.getItem('selectedConversation');\n    if (selectedConversation) {\n      const parsedSelectedConversation: Conversation =\n        JSON.parse(selectedConversation);\n      const cleanedSelectedConversation = cleanSelectedConversation(\n        parsedSelectedConversation,\n      );\n\n      dispatch({\n        field: 'selectedConversation',\n        value: cleanedSelectedConversation,\n      });\n    } else {\n      const lastConversation = conversations[conversations.length - 1];\n      dispatch({\n        field: 'selectedConversation',\n        value: {\n          id: uuidv4(),\n          name: t('New Conversation'),\n          messages: [],\n          model: OpenAIModels[defaultModelId],\n          prompt: DEFAULT_SYSTEM_PROMPT,\n          temperature: lastConversation?.temperature ?? DEFAULT_TEMPERATURE,\n          folderId: null,\n        },\n      });\n    }\n  }, [\n    defaultModelId,\n    dispatch,\n    serverSideApiKeyIsSet,\n    serverSidePluginKeysSet,\n  ]);\n\n  return (\n    <HomeContext.Provider\n      value={{\n        ...contextValue,\n        handleNewConversation,\n        handleCreateFolder,\n        handleDeleteFolder,\n        handleUpdateFolder,\n        handleSelectConversation,\n        handleUpdateConversation,\n      }}\n    >\n      <Head>\n        <title>LlamaGPT</title>\n        <meta name=\"description\" content=\"Chat with a local LLM on your Umbrel without leaking your data to OpenAI\" />\n        <meta\n          name=\"viewport\"\n          content=\"height=device-height ,width=device-width, initial-scale=1, user-scalable=no\"\n        />\n        <link rel=\"icon\" href=\"/favicon.ico\" />\n      </Head>\n      {selectedConversation && (\n        <main\n          className={`flex h-screen w-screen flex-col text-sm text-white dark:text-white ${lightMode}`}\n        >\n          <div className=\"fixed top-0 w-full sm:hidden\">\n            <Navbar\n              selectedConversation={selectedConversation}\n              onNewConversation={handleNewConversation}\n            />\n          </div>\n\n          <div className=\"flex h-full w-full pt-[48px] sm:pt-0\">\n            <Chatbar />\n\n            <div className=\"flex flex-1\">\n              <Chat stopConversationRef={stopConversationRef} />\n            </div>\n\n            <Promptbar />\n          </div>\n        </main>\n      )}\n    </HomeContext.Provider>\n  );\n};\nexport default Home;\n\nexport const getServerSideProps: GetServerSideProps = async ({ locale }) => {\n  const defaultModelId =\n    (process.env.DEFAULT_MODEL &&\n      Object.values(OpenAIModelID).includes(\n        process.env.DEFAULT_MODEL as OpenAIModelID,\n      ) &&\n      process.env.DEFAULT_MODEL) ||\n    fallbackModelID;\n\n  let serverSidePluginKeysSet = false;\n\n  const googleApiKey = process.env.GOOGLE_API_KEY;\n  const googleCSEId = process.env.GOOGLE_CSE_ID;\n\n  if (googleApiKey && googleCSEId) {\n    serverSidePluginKeysSet = true;\n  }\n\n  return {\n    props: {\n      serverSideApiKeyIsSet: !!process.env.OPENAI_API_KEY,\n      defaultModelId,\n      serverSidePluginKeysSet,\n      ...(await serverSideTranslations(locale ?? 'en', [\n        'common',\n        'chat',\n        'sidebar',\n        'markdown',\n        'promptbar',\n        'settings',\n      ])),\n    },\n  };\n};\n"
  },
  {
    "path": "ui/pages/api/home/index.ts",
    "content": "export { default, getServerSideProps } from './home';\n"
  },
  {
    "path": "ui/pages/api/models.ts",
    "content": "import { OPENAI_API_HOST, OPENAI_API_TYPE, OPENAI_API_VERSION, OPENAI_ORGANIZATION } from '@/utils/app/const';\n\nimport { OpenAIModel, OpenAIModelID, OpenAIModels } from '@/types/openai';\n\nexport const config = {\n  runtime: 'edge',\n};\n\nconst handler = async (req: Request): Promise<Response> => {\n  try {\n    const { key } = (await req.json()) as {\n      key: string;\n    };\n\n    let url = `${OPENAI_API_HOST}/v1/models`;\n    if (OPENAI_API_TYPE === 'azure') {\n      url = `${OPENAI_API_HOST}/openai/deployments?api-version=${OPENAI_API_VERSION}`;\n    }\n\n    console.log(\"making request to \", url);\n    const response = await fetch(url, {\n      headers: {\n        'Content-Type': 'application/json',\n        ...(OPENAI_API_TYPE === 'openai' && {\n          Authorization: `Bearer ${key ? key : process.env.OPENAI_API_KEY}`\n        }),\n        ...(OPENAI_API_TYPE === 'azure' && {\n          'api-key': `${key ? key : process.env.OPENAI_API_KEY}`\n        }),\n        ...((OPENAI_API_TYPE === 'openai' && OPENAI_ORGANIZATION) && {\n          'OpenAI-Organization': OPENAI_ORGANIZATION,\n        }),\n      },\n    });\n\n    if (response.status === 401) {\n      return new Response(response.body, {\n        status: 500,\n        headers: response.headers,\n      });\n    } else if (response.status !== 200) {\n      console.error(\n        `OpenAI API returned an error ${\n          response.status\n        }: ${await response.text()}`,\n      );\n      throw new Error('OpenAI API returned an error');\n    }\n\n    const json = await response.json();\n\n    const models: OpenAIModel[] = json.data\n      .map((model: any) => {\n        const model_name = (OPENAI_API_TYPE === 'azure') ? model.model : model.id;\n        for (const [key, value] of Object.entries(OpenAIModelID)) {\n          if (value === model_name) {\n            return {\n              id: model.id,\n              name: OpenAIModels[value].name,\n            };\n          }\n        }\n      })\n      .filter(Boolean);\n\n    return new Response(JSON.stringify(models), { status: 200 });\n  } catch (error) {\n    console.error(error);\n    return new Response('Error', { status: 500 });\n  }\n};\n\nexport default handler;\n"
  },
  {
    "path": "ui/pages/index.tsx",
    "content": "export { default, getServerSideProps } from './api/home';\n"
  },
  {
    "path": "ui/postcss.config.js",
    "content": "module.exports = {\n  plugins: {\n    tailwindcss: {},\n    autoprefixer: {},\n  },\n};\n"
  },
  {
    "path": "ui/prettier.config.js",
    "content": "module.exports = {\n  trailingComma: 'all',\n  singleQuote: true,\n  plugins: [\n    'prettier-plugin-tailwindcss',\n    '@trivago/prettier-plugin-sort-imports',\n  ],\n  importOrder: [\n    'react', // React\n    '^react-.*$', // React-related imports\n    '^next', // Next-related imports\n    '^next-.*$', // Next-related imports\n    '^next/.*$', // Next-related imports\n    '^.*/hooks/.*$', // Hooks\n    '^.*/services/.*$', // Services\n    '^.*/utils/.*$', // Utils\n    '^.*/types/.*$', // Types\n    '^.*/pages/.*$', // Components\n    '^.*/components/.*$', // Components\n    '^[./]', // Other imports\n    '.*', // Any uncaught imports\n  ],\n  importOrderSeparation: true,\n  importOrderSortSpecifiers: true,\n};\n"
  },
  {
    "path": "ui/public/locales/ar/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \" (أوبن أيه أي) OpenAI API Key (مطلوب (مفتاح واجهة برمجة تطبيقات  \",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"يرجى تعيين مفتاح واجهة برمجة تطبيقات أوبن أيه أي الخاص بك في الجزء السفلي الأيسر من الشريط الجانبي\",\n  \"Stop Generating\": \"إيقاف التوليد\",\n  \"Prompt limit is {{maxLength}} characters\": \"حرفًا {{maxLength}} حد المطالبة هو\",\n  \"System Prompt\": \"مطالبة النظام\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"أنت شات جبت نموذج لغة كبير تم تدريبه بواسطة أوبن أيه أي. اتبع تعليمات المستخدم بعناية. الرد باستخدام الماركداون\",\n  \"Enter a prompt\": \"أدخل المطالبة\",\n  \"Regenerate response\": \"إعادة توليد الرد\",\n  \"Sorry, there was an error.\": \"عذرًا، حدث خطأ\",\n  \"Model\": \"النموذج\",\n  \"Conversation\": \"المحادثة\",\n  \"OR\": \"أو\",\n  \"Loading...\": \"...جاري التحميل\",\n  \"Type a message...\": \"...اكتب رسالة\",\n  \"Error fetching models.\": \"خطأ في جلب النماذج\",\n  \"AI\": \"الذكاء الاصطناعي\",\n  \"You\": \"أنت\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"تأكد من تعيين مفتاح واجهة برمجة تطبيقات الخاص بك في الجزء السفلي الأيسر من الشريط\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"من مشاكل OpenAI إذا اكتملت هذه الخطوة، فقد يعاني\",\n\n  \"click if using a .env.local file\": \".env.local انقر إذا كنت تستخدم ملف\",\n\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"حرفًا {{maxLength}}  حد الرسالة هو {{valueLength}} لقد أدخلت \",\n\n  \"Please enter a message\": \"يرجى إدخال رسالة\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI هي مجموعة متقدمة للدردشة تستخدم\",\n  \"Are you sure you want to clear all messages?\": \"هل أنت متأكد أنك تريد مسح كافة الرسائل؟\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"القيم الأعلى مثل 0.8 ستجعل الإخراج أكثر عشوائية، في حين أن القيم الأقل مثل 0.2 ستجعله أكثر تركيزًا وتحديدًا.\"\n}\n"
  },
  {
    "path": "ui/public/locales/ar/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/ar/markdown.json",
    "content": "{\n  \"Copy code\": \"نسخ الكود\",\n  \"Copied!\": \"تم النسخ!\",\n  \"Enter file name\": \"أدخل اسم الملف\"\n}\n"
  },
  {
    "path": "ui/public/locales/ar/promptbar.json",
    "content": "{\n  \"New prompt\": \"مطلب جديد\",\n  \"New folder\": \"مجلد جديد\",\n  \"No prompts.\": \"لا يوجد مطالبات.\",\n  \"Search prompts...\": \"...البحث عن مطالبات\",\n  \"Name\": \"الاسم\",\n  \"Description\": \"الوصف\",\n  \"A description for your prompt.\": \"وصف لمطلبك\",\n  \"Prompt\": \"مطلب\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"محتوى المطلب. استخدم {{}} للإشارة إلى متغير. مثال: {{الاسم}} هي {{صفة}} {{اسم}}\",\n  \"Save\": \"حفظ\"\n}\n"
  },
  {
    "path": "ui/public/locales/ar/settings.json",
    "content": "{\n  \"Dark mode\": \"الوضع الداكن\",\n  \"Light mode\": \"الوضع الفاتح\"\n}\n"
  },
  {
    "path": "ui/public/locales/ar/sidebar.json",
    "content": "{\n  \"New folder\": \"مجلد جديد\",\n  \"New chat\": \"محادثة جديدة\",\n  \"No conversations.\": \"لا يوجد محادثات\",\n  \"Search conversations...\": \"...البحث عن المحادثات\",\n  \"OpenAI API Key\": \" (أوبن أيه أي) OpenAI API Key (مفتاح واجهة برمجة تطبيقات)\",\n  \"Import data\": \"استيراد المحادثات\",\n  \"Are you sure?\": \"هل أنت متأكد؟\",\n  \"Clear conversations\": \"مسح المحادثات\",\n  \"Export data\": \"تصدير المحادثات\",\n  \"Dark mode\": \"الوضع الداكن\",\n  \"Light mode\": \"الوضع الفاتح\"\n}\n"
  },
  {
    "path": "ui/public/locales/bn/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API key বাধ্যতামূলক\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"দয়া করে আপনার OpenAI API key বামে সাইডবারের নিচের দিকে সেট করুন।\",\n  \"Stop Generating\": \"বার্তা জেনারেট করা বন্ধ করুন\",\n  \"Prompt limit is {{maxLength}} characters\": \"নির্দেশনা (বার্তা) সীমা সর্বোচ্চ {{maxLength}} অক্ষর\",\n  \"System Prompt\": \"সিস্টেম নির্দেশনা (বার্তা)\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"তুমি ChatGPT, OpenAI দ্বারা প্রশিক্ষিত একটি বড় ভাষা মডেল। সাবধানে ব্যবহারকারীর নির্দেশাবলী অনুসরণ করুন. মার্কডাউন ব্যবহার করে উত্তর দিন।\",\n  \"Enter a prompt\": \"একটি নির্দেশনা (বার্তা) দিন\",\n  \"Regenerate response\": \"বার্তা আবার জেনারেট করুন\",\n  \"Sorry, there was an error.\": \"দুঃখিত, কোনো একটি সমস্যা হয়েছে।\",\n  \"Model\": \"মডেল\",\n  \"Conversation\": \"আলাপচারিতা\",\n  \"OR\": \"অথবা\",\n  \"Loading...\": \"লোড হচ্ছে...\",\n  \"Type a message...\": \"কোনো মেসেজ লিখুন...\",\n  \"Error fetching models.\": \"মডেল পেতে সমস্যা হচ্ছে।\",\n  \"AI\": \"AI\",\n  \"You\": \"তুমি\",\n  \"Cancel\": \"বাতিল করুন\",\n  \"Save & Submit\": \"সংরক্ষণ করুন এবং জমা দিন\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"নিশ্চিত করুন যে আপনার OpenAI API key সাইডবারের নীচে বাম দিকে সেট করা আছে।\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"আপনি এই ধাপটি সম্পন্ন করে থাকলে, হতে পারে যে OpenAI কোনো সমস্যার সম্মুখীন হয়েছে।\",\n  \"click if using a .env.local file\": \"একটি .env.local ফাইল ব্যবহার করলে এখানে ক্লিক করুন\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"বার্তার সর্বোচ্চ সীমা হল {{maxLength}} অক্ষর৷ আপনি {{valueLength}} অক্ষর লিখেছেন।\",\n  \"Please enter a message\": \"দয়া করে একটি মেসেজ লিখুন\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI হল OpenAI-এর চ্যাট মডেলগুলির জন্য একটি উন্নত চ্যাটবট কিট যার লক্ষ্য হল ChatGPT-এর ইন্টারফেস এবং কার্যকারিতা অনুকরণ করা।\",\n  \"Are you sure you want to clear all messages?\": \"সমস্ত বার্তা মুছে ফেলতে আপনি কি নিশ্চিত?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"০.৮ এর বেশি মান দিলে আউটপুট বেশি ইউনিক হবে, যেহেতু ০.২ এর মতো নিম্নমানের মান দিলে তা আরও ফোকাস এবং ধারাবাহিকতা বজায় থাকবে এবং নিশ্চয়তামূলক হবে।\"\n}\n"
  },
  {
    "path": "ui/public/locales/bn/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/bn/markdown.json",
    "content": "{\n  \"Copy code\": \"কোড কপি করুন\",\n  \"Copied!\": \"কপি করা হয়েছে!\",\n  \"Enter file name\": \"ফাইল নাম লিখুন\"\n}\n"
  },
  {
    "path": "ui/public/locales/bn/promptbar.json",
    "content": "{\n  \"New prompt\": \"নতুন prompt\",\n  \"New folder\": \"নতুন ফোল্ডার\",\n  \"No prompts.\": \"কোনো prompts নেই।\",\n  \"Search prompts...\": \"prompts অনুসন্ধান হচ্ছে...\",\n  \"Name\": \"নাম\",\n  \"Description\": \"বর্ণনা\",\n  \"A description for your prompt.\": \"আপনার Prompt জন্য একটি বিবরণ লিখুন.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"সংরক্ষণ করুন\"\n}\n"
  },
  {
    "path": "ui/public/locales/bn/settings.json",
    "content": "{\n  \"Dark mode\": \"ডার্ক মোড\",\n  \"Light mode\": \"লাইট মোড\"\n}\n"
  },
  {
    "path": "ui/public/locales/bn/sidebar.json",
    "content": "{\n  \"New folder\": \"নতুন ফোল্ডার\",\n  \"New chat\": \"নতুন আড্ডা\",\n  \"No conversations.\": \"কোনো আলাপচারিতা নেই।\",\n  \"Search conversations...\": \"আলাপচারিতা খুঁজুন...\",\n  \"OpenAI API Key\": \"OpenAI API Key\",\n  \"Import data\": \"আলাপচারিতা ইমপোর্ট\",\n  \"Are you sure?\": \"আপনি কি নিশ্চিত?\",\n  \"Clear conversations\": \"কথোপকথন পরিষ্কার করুন\",\n  \"Export data\": \"আলাপচারিতা এক্সপোর্ট\"\n}\n"
  },
  {
    "path": "ui/public/locales/ca/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Cal la clau d'API d'OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Si us plau, introdueix la teva clau d'API d'OpenAI a la cantonada inferior esquerra de la barra lateral.\",\n  \"Stop Generating\": \"Parar de generar\",\n  \"Prompt limit is {{maxLength}} characters\": \"El límit del missatge és de {{maxLength}} caràcters\",\n  \"System Prompt\": \"Missatge del sistema\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Ets ChatGPT, un model de llenguatge gran entrenat per OpenAI. Segueix les instruccions de l'usuari amb cura. Respon utilitzant markdown.\",\n  \"Enter a prompt\": \"Introdueix un missatge\",\n  \"Regenerate response\": \"Regenerar resposta\",\n  \"Sorry, there was an error.\": \"Ho sentim, ha ocorregut un error.\",\n  \"Model\": \"Model\",\n  \"Conversation\": \"Conversa\",\n  \"OR\": \"O\",\n  \"Loading...\": \"Carregant...\",\n  \"Type a message...\": \"Escriu un missatge...\",\n  \"Error fetching models.\": \"Error en obtenir els models.\",\n  \"AI\": \"IA\",\n  \"You\": \"Tu\",\n  \"Cancel\": \"Cancel·lar\",\n  \"Save & Submit\": \"Guardar i enviar\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Assegura't que has introduït la clau d'API d'OpenAI a la cantonada inferior esquerra de la barra lateral.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Si has completat aquest pas, OpenAI podria estar experimentant problemes.\",\n  \"click if using a .env.local file\": \"fes clic si estàs utilitzant un fitxer .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"El límit del missatge és de {{maxLength}} caràcters. Has introduït {{valueLength}} caràcters.\",\n  \"Please enter a message\": \"Si us plau, introdueix un missatge\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI és un kit avançat de chatbot per als models de xat d'OpenAI que busca imitar la interfície i funcionalitat de ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Estàs segur que vols esborrar tots els missatges?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Valors més alts com 0,8 faran que la sortida sigui més aleatòria, mentre que valors més baixos com 0,2 la faran més enfocada i determinista.\"\n}\n"
  },
  {
    "path": "ui/public/locales/ca/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/ca/markdown.json",
    "content": "{\n  \"Copy code\": \"Copiar codi\",\n  \"Copied!\": \"Copiat!\",\n  \"Enter file name\": \"Introdueix el nom de l'arxiu\"\n}\n"
  },
  {
    "path": "ui/public/locales/ca/promptbar.json",
    "content": "{\n  \"New prompt\": \"Nou prompt\",\n  \"New folder\": \"Nova carpeta\",\n  \"No prompts.\": \"No hi ha prompts.\",\n  \"Search prompts...\": \"Cerca prompts...\",\n  \"Name\": \"Nom\",\n  \"Description\": \"Descripció\",\n  \"A description for your prompt.\": \"Descripció del teu prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Contingut del missatge. Utilitza {{}} per indicar una variable. Ex: {{nom}} és un {{adjectiu}} {{substantiu}}\",\n  \"Save\": \"Guardar\"\n}\n"
  },
  {
    "path": "ui/public/locales/ca/sidebar.json",
    "content": "{\n  \"New folder\": \"Nova carpeta\",\n  \"New chat\": \"Nova conversa\",\n  \"No conversations.\": \"No hi ha converses.\",\n  \"Search conversations...\": \"Cerca converses...\",\n  \"OpenAI API Key\": \"Clau d'API d'OpenAI\",\n  \"Import data\": \"Importar converses\",\n  \"Are you sure?\": \"Estàs segur?\",\n  \"Clear conversations\": \"Esborrar converses\",\n  \"Export data\": \"Exportar converses\",\n  \"Dark mode\": \"Mode fosc\",\n  \"Light mode\": \"Mode clar\"\n}\n"
  },
  {
    "path": "ui/public/locales/de/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API-Schlüssel erforderlich\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Bitte trage deinen OpenAI API-Schlüssel in der linken unteren Ecke der Seitenleiste ein.\",\n  \"Stop Generating\": \"Generieren stoppen\",\n  \"Prompt limit is {{maxLength}} characters\": \"Das Eingabelimit liegt bei {{maxLength}} Zeichen\",\n  \"System Prompt\": \"Systemaufforderung\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Du bist ChatGPT, ein großes Sprachmodell, das von OpenAI trainiert wurde. Befolge die Anweisungen des Benutzers sorgfältig. Antworte in Markdown-Format.\",\n  \"Enter a prompt\": \"Gib eine Anweisung ein\",\n  \"Regenerate response\": \"Antwort erneut generieren\",\n  \"Sorry, there was an error.\": \"Entschuldigung, es ist ein Fehler aufgetreten.\",\n  \"Model\": \"Modell\",\n  \"Conversation\": \"Konversation\",\n  \"OR\": \"ODER\",\n  \"Loading...\": \"Laden...\",\n  \"Type a message...\": \"Schreibe eine Nachricht...\",\n  \"Error fetching models.\": \"Fehler beim Abrufen der Sprachmodelle.\",\n  \"AI\": \"KI\",\n  \"You\": \"Du\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Stelle sicher, dass dein OpenAI API-Schlüssel in der unteren linken Ecke der Seitenleiste eingetragen ist.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Wenn dies der Fall ist, könnte OpenAI möglicherweise momentan Probleme haben.\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Das Nachrichtenlimit beträgt {{maxLength}} Zeichen. Du hast bereits {{valueLength}} Zeichen eingegeben.\",\n  \"Please enter a message\": \"Bitte gib eine Nachricht ein\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI ist ein fortschrittliches Chatbot-Toolkit für OpenAI's Chat-Modelle, das darauf abzielt, die Benutzeroberfläche und Funktionalität von ChatGPT nachzuahmen.\",\n  \"Are you sure you want to clear all messages?\": \"Bist du sicher, dass du alle Nachrichten löschen möchtest?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Höhere Werte wie 0,8 machen die Ausgabe zufälliger, während niedrigere Werte wie 0,2 sie fokussierter und deterministischer machen werden.\"\n}\n"
  },
  {
    "path": "ui/public/locales/de/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/de/markdown.json",
    "content": "{\n  \"Copy code\": \"Code kopieren\",\n  \"Copied!\": \"Kopiert!\",\n  \"Enter file name\": \"Dateinamen eingeben\"\n}\n"
  },
  {
    "path": "ui/public/locales/de/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/de/settings.json",
    "content": "{\n  \"Dark mode\": \"Dark Mode\",\n  \"Light mode\": \"Light Mode\"\n}\n"
  },
  {
    "path": "ui/public/locales/de/sidebar.json",
    "content": "{\n  \"New folder\": \"Neuer Ordner\",\n  \"New chat\": \"Neue Konversation\",\n  \"No conversations.\": \"Keine Konversationen.\",\n  \"Search conversations...\": \"Konversationen suchen...\",\n  \"OpenAI API Key\": \"OpenAI API-Schlüssel\",\n  \"Import data\": \"Konversationen importieren\",\n  \"Are you sure?\": \"Bist du sicher?\",\n  \"Clear conversations\": \"Konversationen löschen\",\n  \"Export data\": \"Konversationen exportieren\"\n}\n"
  },
  {
    "path": "ui/public/locales/en/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/es/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Se requiere la clave de API de OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Por favor, ingrese su clave de API de OpenAI en la esquina inferior izquierda de la barra lateral.\",\n  \"Stop Generating\": \"Dejar de generar\",\n  \"Prompt limit is {{maxLength}} characters\": \"El límite del mensaje es de {{maxLength}} caracteres\",\n  \"System Prompt\": \"Mensaje del sistema\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Eres ChatGPT, un modelo de lenguaje grande entrenado por OpenAI. Sigue las instrucciones del usuario cuidadosamente. Responde usando markdown.\",\n  \"Enter a prompt\": \"Ingrese un mensaje\",\n  \"Regenerate response\": \"Regenerar respuesta\",\n  \"Sorry, there was an error.\": \"Lo sentimos, ha ocurrido un error.\",\n  \"Model\": \"Modelo\",\n  \"Conversation\": \"Conversación\",\n  \"OR\": \"O\",\n  \"Loading...\": \"Cargando...\",\n  \"Type a message...\": \"Escriba un mensaje...\",\n  \"Error fetching models.\": \"Error al obtener los modelos.\",\n  \"AI\": \"IA\",\n  \"You\": \"Tú\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Asegúrate de que hayas ingresado la clave de API de OpenAI en la esquina inferior izquierda de la barra lateral.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Si completaste este paso, OpenAI podría estar experimentando problemas.\",\n  \"click if using a .env.local file\": \"haz clic si estás utilizando un archivo .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"El límite del mensaje es de {{maxLength}} caracteres. Has ingresado {{valueLength}} caracteres.\",\n  \"Please enter a message\": \"Por favor, ingrese un mensaje\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI es un kit avanzado de chatbot para los modelos de chat de OpenAI que busca imitar la interfaz y funcionalidad de ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"¿Está seguro de que desea borrar todos los mensajes?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Valores más altos como 0,8 harán que la salida sea más aleatoria, mientras que valores más bajos como 0,2 la harán más enfocada y determinista.\"\n}\n"
  },
  {
    "path": "ui/public/locales/es/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/es/markdown.json",
    "content": "{\n  \"Copy code\": \"Copiar código\",\n  \"Copied!\": \"¡Copiado!\",\n  \"Enter file name\": \"Ingrese el nombre del archivo\"\n}\n"
  },
  {
    "path": "ui/public/locales/es/promptbar.json",
    "content": "{\n  \"New prompt\": \"Nuevo prompt\",\n  \"New folder\": \"Nueva carpeta\",\n  \"No prompts.\": \"No hay prompts.\",\n  \"Search prompts...\": \"Buscar prompts...\",\n  \"Name\": \"Nombre\",\n  \"Description\": \"Descripción\",\n  \"A description for your prompt.\": \"Descripción de su prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Contenido del prompt. Utilice {{}} para indicar una variable. Ej: {{nombre}} es un {{adjetivo}} {{nombre}}\",\n  \"Save\": \"Guardar\"\n}\n"
  },
  {
    "path": "ui/public/locales/es/settings.json",
    "content": "{\n  \"Dark mode\": \"Modo oscuro\",\n  \"Light mode\": \"Modo claro\"\n}\n"
  },
  {
    "path": "ui/public/locales/es/sidebar.json",
    "content": "{\n  \"New folder\": \"Nueva carpeta\",\n  \"New chat\": \"Nueva conversación\",\n  \"No conversations.\": \"No hay conversaciones.\",\n  \"Search conversations...\": \"Buscar conversaciones...\",\n  \"OpenAI API Key\": \"Llave de API de OpenAI\",\n  \"Import data\": \"Importar conversaciones\",\n  \"Are you sure?\": \"¿Estás seguro?\",\n  \"Clear conversations\": \"Borrar conversaciones\",\n  \"Export data\": \"Exportar conversaciones\"\n}\n"
  },
  {
    "path": "ui/public/locales/fi/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API-avain tarvitaan\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Ole hyvä ja aseta OpenAI API-avaimesi sivupalkin vasemmassa alareunassa.\",\n  \"Stop Generating\": \"Lopeta generointi\",\n  \"Prompt limit is {{maxLength}} characters\": \"Promptin maksimipituus on {{maxLength}} merkkiä\",\n  \"System Prompt\": \"System prompt\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Sinä olet ChatGPT, OpenAI:n opettama laaja kielimalli. Seuraa käyttäjän ohjeita tarkasti. Vastaa käyttäen markdownia.\",\n  \"Enter a prompt\": \"Syötä prompti\",\n  \"Regenerate response\": \"Luo vastaus uudelleen\",\n  \"Sorry, there was an error.\": \"Valitettavasti tapahtui virhe.\",\n  \"Model\": \"Malli\",\n  \"Conversation\": \"Keskustelu\",\n  \"OR\": \"TAI\",\n  \"Loading...\": \"Ladataan...\",\n  \"Type a message...\": \"Kirjoita viesti...\",\n  \"Type a message or type \\\"/\\\" to select a prompt...\": \"Kirjoita viesti tai \\\"/\\\" valitaksesi promptin...\",\n  \"Error fetching models.\": \"Virhe malleja haettaessa.\",\n  \"AI\": \"AI\",\n  \"You\": \"Sinä\",\n  \"Cancel\": \"Peruuta\",\n  \"Save & Submit\": \"Tallenna & Lähetä\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Varmista että OpenAI API-avaimesi on asetettu sivupalkin vasemmassa alareunassa.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Jos olet suorittanut tämän kohdan, OpenAI:lla saattaa olla tällä hetkellä ongelmia.\",\n  \"click if using a .env.local file\": \"klikkaa jos käytät .env.local-tiedostoa\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Viestin maksimipituus on {{maxLength}} merkkiä. Olet käyttänyt {{valueLength}} merkkiä.\",\n  \"Please enter a message\": \"Ole hyvä ja syötä viesti\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI on OpenAI:n keskustelumalleille tarkoitettu käyttöliittymä joka pyrkii jäljittelemään ChatGPT:n käyttöliittymää ja toiminnallisuuksia.\",\n  \"Are you sure you want to clear all messages?\": \"Haluatko varmasti poistaa kaikki viestit?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Suuremmat arvot kuten 0.8 tekevät vastauksista satunnaisempia, kun taas pienemmät arvot kuten 0.2 tekevät niistä keskittyneempiä ja johdonmukaisempia.\",\n  \"Precise\": \"Tarkka\",\n  \"Neutral\": \"Neutraali\",\n  \"Creative\": \"Luova\",\n  \"View Account Usage\": \"Näytä tilin käyttötilastot\",\n  \"Search...\": \"Hae...\"\n}\n"
  },
  {
    "path": "ui/public/locales/fi/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/fi/markdown.json",
    "content": "{\n  \"Copy code\": \"Kopioi koodi\",\n  \"Copied!\": \"Kopioitu!\",\n  \"Enter file name\": \"Syötä tiedostonimi\"\n}\n"
  },
  {
    "path": "ui/public/locales/fi/promptbar.json",
    "content": "{\n  \"New prompt\": \"Uusi prompt\",\n  \"New folder\": \"Uusi kansio\",\n  \"No prompts.\": \"Ei prompteja.\",\n  \"Search prompts...\": \"Hae prompteista...\",\n  \"Name\": \"Nimi\",\n  \"Description\": \"Kuvaus\",\n  \"A description for your prompt.\": \"Promptisi kuvaus.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Promptin sisältö. Käytä {{}} muuttujien merkitsemiseen. Esim: {{nimi}} on {{adjektiivi}} {{substantiivi}}\",\n  \"Save\": \"Tallenna\"\n}\n"
  },
  {
    "path": "ui/public/locales/fi/settings.json",
    "content": "{\n  \"Settings\": \"Asetukset\",\n  \"Theme\": \"Teema\",\n  \"Dark mode\": \"Tumma teema\",\n  \"Light mode\": \"Vaalea teema\",\n  \"Save\": \"Tallenna\"\n}\n"
  },
  {
    "path": "ui/public/locales/fi/sidebar.json",
    "content": "{\n  \"New folder\": \"Uusi kansio\",\n  \"New chat\": \"Uusi keskustelu\",\n  \"No conversations.\": \"Ei keskusteluja.\",\n  \"Search conversations...\": \"Hae keskusteluista...\",\n  \"OpenAI API Key\": \"OpenAI API-avain\",\n  \"Import data\": \"Tuo keskusteluita\",\n  \"Are you sure?\": \"Oletko varma?\",\n  \"Clear conversations\": \"Tyhjennä keskustelut\",\n  \"Export data\": \"Vie keskustelut\",\n  \"Settings\": \"Asetukset\",\n  \"Plugin Keys\": \"Plugin-avaimet\"\n}\n"
  },
  {
    "path": "ui/public/locales/fr/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Clé API OpenAI requise\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Veuillez saisir votre clé API OpenAI dans le coin inférieur gauche de la barre latérale.\",\n  \"Stop Generating\": \"Interrompre la génération\",\n  \"Prompt limit is {{maxLength}} characters\": \"La limite du prompt est de {{maxLength}} caractères\",\n  \"System Prompt\": \"Prompt du système\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Vous êtes ChatGPT, un grand modèle linguistique entraîné par OpenAI. Suivez attentivement les instructions de l'utilisateur. Répondez en utilisant Markdown.\",\n  \"Enter a prompt\": \"Entrez un prompt\",\n  \"Regenerate response\": \"Régénérer la réponse\",\n  \"Sorry, there was an error.\": \"Désolé, une erreur est survenue.\",\n  \"Model\": \"Modèle\",\n  \"Conversation\": \"Conversation\",\n  \"OR\": \"OU\",\n  \"Loading...\": \"Chargement...\",\n  \"Type a message...\": \"Tapez un message...\",\n  \"Error fetching models.\": \"Erreur lors de la récupération des modèles.\",\n  \"AI\": \"IA\",\n  \"You\": \"Vous\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Assurez-vous que votre clé API OpenAI est définie dans le coin inférieur gauche de la barre latérale.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Si vous avez effectué cette étape, OpenAI peut rencontrer des problèmes.\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"La limite de message est de {{maxLength}} caractères. Vous avez saisi {{valueLength}} caractères.\",\n  \"Please enter a message\": \"Veuillez entrer un message\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI est un kit de chatbot avancé pour les modèles de chat d'OpenAI visant à imiter l'interface et les fonctionnalités de ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Êtes-vous sûr de vouloir effacer tous les messages ?\"\n}\n"
  },
  {
    "path": "ui/public/locales/fr/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/fr/markdown.json",
    "content": "{\n  \"Copy code\": \"Copier le code\",\n  \"Copied!\": \"Copié !\",\n  \"Enter file name\": \"Entrez le nom du fichier\"\n}\n"
  },
  {
    "path": "ui/public/locales/fr/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/fr/settings.json",
    "content": "{\n  \"Dark mode\": \"Mode sombre\",\n  \"Light mode\": \"Mode clair\"\n}\n"
  },
  {
    "path": "ui/public/locales/fr/sidebar.json",
    "content": "{\n  \"New folder\": \"Nouveau dossier\",\n  \"New chat\": \"Nouvelle discussion\",\n  \"No conversations.\": \"Aucune conversation.\",\n  \"Search conversations...\": \"Rechercher des conversations...\",\n  \"OpenAI API Key\": \"Clé API OpenAI\",\n  \"Import data\": \"Importer des conversations\",\n  \"Are you sure?\": \"Êtes-vous sûr ?\",\n  \"Clear conversations\": \"Effacer les conversations\",\n  \"Export data\": \"Exporter les conversations\"\n}\n"
  },
  {
    "path": "ui/public/locales/he/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"מפתח openAI API\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"עליך להזין את המפתח האישי שלך בצידו השמאלי התחתון של תפריט הניווט.\",\n  \"Stop Generating\": \"עצור תהליך הפקת התשובה\",\n  \"Prompt limit is {{maxLength}} characters\": \"אורך התשובה מוגבל ל {{maxLength}} תווים\",\n  \"System Prompt\": \"הגדרת בסיס לכל תשובה של המערכת\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"You are Hebrew speaking ChatGPT, a large language model trained by OpenAI which responds in Hebrew to any question or User comment. Follow the user's instructions carefully. Respond in Hebrew using markdown.\",\n  \"Enter a prompt\": \"הקלד הודעה\",\n  \"Regenerate response\": \"הפק תשובה מחדש\",\n  \"Sorry, there was an error.\": \"התנצלותנו הכנה, המערכת מדווחת על תקלה\",\n  \"Model\": \"מודל\",\n  \"Conversation\": \"שיחה\",\n  \"OR\": \"או\",\n  \"Loading...\": \"טוען...\",\n  \"Type a message...\": \"הקלד הודעתך...\",\n  \"Error fetching models.\": \"תקלה באיחזור רשימת המודלים\",\n  \"AI\": \"המערכת\",\n  \"You\": \"אתה\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"עליך לוודא שמפתח האישי שלך מוזן בתפריט מצד שמאל\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"אם טרם השלמת חלק זה יש סבירות גבוהה להתרחשות תקלה\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"מגבלת תווים היא {{maxLength}}. אתה הקלדת עד עכשיו {{valueLength}} תווים.\",\n  \"Please enter a message\": \"הקלד את הודעתך\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"מערכת הצאטבוט היא ערכה מתקדמת לניהול שיחה המכוונת לחקות את המראה והפונקציונאלית של ChatGPT\",\n  \"Are you sure you want to clear all messages?\": \"האם אתה בטוח שברצונך למחוק את כל ההודעות?\"\n}\n"
  },
  {
    "path": "ui/public/locales/he/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/he/markdown.json",
    "content": "{\n  \"Copy code\": \"העתק קוד\",\n  \"Copied!\": \"נשמר בזכרון\",\n  \"Enter file name\": \"הקלד שם לקובץ\"\n}\n"
  },
  {
    "path": "ui/public/locales/he/promptbar.json",
    "content": "{\n  \"New prompt\": \"פקודת מכונה חדשה\",\n  \"New folder\": \"תיקיה חדשה\",\n  \"No prompts.\": \"לא נמצאו פקודות מכונות\",\n  \"Search prompts...\": \"חיפוש פקודות...\",\n  \"Name\": \"שם\",\n  \"Description\": \"תיאור\",\n  \"A description for your prompt.\": \"תיאור שורת הפקודה למכונה\",\n  \"Prompt\": \"פקודה\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"תיאור הפקודה. השתמש {{}} להגדרת משתנים. לדוגמא {{שם משתנה}} הוא {{תואר}} {{שם עצם}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/he/settings.json",
    "content": "{\n  \"Dark mode\": \"מצב כהה\",\n  \"Light mode\": \"מצב בהיר\"\n}\n"
  },
  {
    "path": "ui/public/locales/he/sidebar.json",
    "content": "{\n  \"New folder\": \"תיקיה חדשה\",\n  \"New chat\": \"שיחה חדשה\",\n  \"No conversations.\": \"אין שיחות חדשות\",\n  \"Search conversations...\": \"חיפוש שיחות...\",\n  \"OpenAI API Key\": \"מפתח אישי ל openAI\",\n  \"Import data\": \"ייבוא שיחות\",\n  \"Are you sure?\": \"אתה בטוח?\",\n  \"Clear conversations\": \"ניקוי שיחות\",\n  \"Export data\": \"ייצוא שיחות\"\n}\n"
  },
  {
    "path": "ui/public/locales/id/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Memerlukan Kunci API OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Silakan atur kunci API OpenAI Anda di bagian kiri bawah bilah sisi.\",\n  \"Stop Generating\": \"Berhenti Menghasilkan\",\n  \"Prompt limit is {{maxLength}} characters\": \"Batas karakter untuk prompt adalah {{maxLength}} karakter\",\n  \"System Prompt\": \"Prompt Sistem\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Anda adalah ChatGPT, model bahasa besar yang dilatih oleh OpenAI. Ikuti instruksi pengguna dengan hati-hati. Balas menggunakan markdown.\",\n  \"Enter a prompt\": \"Masukkan sebuah prompt\",\n  \"Regenerate response\": \"Hasilkan kembali respons\",\n  \"Sorry, there was an error.\": \"Maaf, terjadi kesalahan.\",\n  \"Model\": \"Model\",\n  \"Conversation\": \"Percakapan\",\n  \"OR\": \"ATAU\",\n  \"Loading...\": \"Memuat...\",\n  \"Type a message...\": \"Ketik sebuah pesan...\",\n  \"Error fetching models.\": \"Kesalahan dalam mengambil model.\",\n  \"AI\": \"AI\",\n  \"You\": \"Anda\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Pastikan kunci API OpenAI Anda diatur di bagian kiri bawah bilah sisi.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Jika Anda telah menyelesaikan langkah ini, OpenAI mungkin mengalami masalah.\",\n  \"click if using a .env.local file\": \"klik jika menggunakan file .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Batas karakter untuk pesan adalah {{maxLength}} karakter. Anda telah memasukkan {{valueLength}} karakter.\",\n  \"Please enter a message\": \"Silakan masukkan sebuah pesan\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI adalah kit chatbot canggih untuk model obrolan OpenAI yang bertujuan meniru antarmuka dan fungsionalitas ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Apakah Anda yakin ingin menghapus semua pesan?\"\n}\n"
  },
  {
    "path": "ui/public/locales/id/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/id/markdown.json",
    "content": "{\n  \"Copy code\": \"Salin kode\",\n  \"Copied!\": \"Kode disalin!\",\n  \"Enter file name\": \"Masukkan nama file\"\n}\n"
  },
  {
    "path": "ui/public/locales/id/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/id/settings.json",
    "content": "{\n  \"Dark mode\": \"Mode gelap\",\n  \"Light mode\": \"Mode terang\"\n}\n"
  },
  {
    "path": "ui/public/locales/id/sidebar.json",
    "content": "{\n  \"New folder\": \"Folder baru\",\n  \"New chat\": \"Percakapan baru\",\n  \"No conversations.\": \"Tidak ada percakapan.\",\n  \"Search conversations...\": \"Cari percakapan...\",\n  \"OpenAI API Key\": \"Kunci API OpenAI\",\n  \"Import data\": \"Impor percakapan\",\n  \"Are you sure?\": \"Apakah Anda yakin?\",\n  \"Clear conversations\": \"Hapus percakapan\",\n  \"Export data\": \"Ekspor percakapan\"\n}\n"
  },
  {
    "path": "ui/public/locales/it/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"E' richiesta la chiave API OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Per favore, inserisci la tua Chiave API OpenAI in basso a sinistra nella barra laterale\",\n  \"Stop Generating\": \"Interrompi la generazione\",\n  \"Prompt limit is {{maxLength}} characters\": \"Il limite del messaggio è di {{maxLength}} caratteri\",\n  \"System Prompt\": \"Prompt del sistema\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Sei ChatGPT, un grande modello di linguaggio addestrato da OpenAI. Segui attentamente le istruzioni dell'utente. Rispondi usando il markdown.\",\n  \"Enter a prompt\": \"Inserisci un prompt\",\n  \"Regenerate response\": \"Rigenera risposta\",\n  \"Sorry, there was an error.\": \"Scusa, si è verificato un errore.\",\n  \"Model\": \"Modello\",\n  \"Conversation\": \"Conversazione\",\n  \"OR\": \"O\",\n  \"Loading...\": \"Caricamento...\",\n  \"Type a message...\": \"Digita un messaggio...\",\n  \"Error fetching models.\": \"Si è verificato un errore nel recupero dei modelli.\",\n  \"AI\": \"IA\",\n  \"You\": \"Tu\",\n  \"Cancel\": \"Annulla\",\n  \"Save & Submit\": \"Salva e invia\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Assicurati che la tua chiave API OpenAI sia inserita in basso a sinistra nella barra laterale\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Se hai completato questo passaggio, OpenAI potrebbe avere problemi.\",\n  \"click if using a .env.local file\": \"Fai click se stai utilizzando un file .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Il limite del messaggio è di {{maxLength}} caratteri. Hai inserito {{valueLength}} caratteri.\",\n  \"Please enter a message\": \"Per favore, scrivi un messaggio\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI è un kit avanzato di chatbot per i modelli di chat di OpenAI che mira a imitare l'interfaccia e le funzionalità di ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Sei sicuro di voler cancellare tutti i messaggi?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Valori più alti come 0,8 renderanno l'output più casuale, mentre valori più bassi come 0,2 lo renderanno più focalizzato e deterministico.\"\n}\n"
  },
  {
    "path": "ui/public/locales/it/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/it/markdown.json",
    "content": "{\n  \"Copy code\": \"Copia codice\",\n  \"Copied!\": \"Copiato!\",\n  \"Enter file name\": \"Inserisci il nome del file\"\n}\n"
  },
  {
    "path": "ui/public/locales/it/promptbar.json",
    "content": "{\n  \"New prompt\": \"Nuovo prompt\",\n  \"New folder\": \"Nuova cartella\",\n  \"No prompts.\": \"Nessun prompt.\",\n  \"Search prompts...\": \"Cerca prompts...\",\n  \"Name\": \"Nome\",\n  \"Description\": \"Descrizione\",\n  \"A description for your prompt.\": \"Descrizione del tuo prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Contenuto del prompt. Utilizza {{}} per indicare una variabile. Per esempio: {{nome}} è un {{aggettivo}} {{sostantivo}}\",\n  \"Save\": \"Salva\"\n}\n"
  },
  {
    "path": "ui/public/locales/it/settings.json",
    "content": "{\n  \"Dark mode\": \"Modalità scura\",\n  \"Light mode\": \"Modalità chiara\"\n}\n"
  },
  {
    "path": "ui/public/locales/it/sidebar.json",
    "content": "{\n  \"New folder\": \"Nuova cartella\",\n  \"New chat\": \"Nuova conversazione\",\n  \"No conversations.\": \"Nessuna conversazione.\",\n  \"Search conversations...\": \"Cerca conversazioni...\",\n  \"OpenAI API Key\": \"Chiave API OpenAI\",\n  \"Import data\": \"Importa dati\",\n  \"Are you sure?\": \"Sei sicuro?\",\n  \"Clear conversations\": \"Elimina conversazioni\",\n  \"Export data\": \"Esporta dati\"\n}\n"
  },
  {
    "path": "ui/public/locales/ja/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAIのAPIキーが必要です\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"左下のサイドバーでOpenAIのAPIキーを設定してください\",\n  \"Stop Generating\": \"回答をストップ\",\n  \"Prompt limit is {{maxLength}} characters\": \"プロンプトの文字数は{{maxLength}}文字までです\",\n  \"System Prompt\": \"システムのプロンプト\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"あなたはOpenAIによってトレーニングされた大規模言語モデルのChatGPTです。ユーザーの指示には注意深く従ってください。マークダウンを使用して応答してください。\",\n  \"Enter a prompt\": \"プロンプトを入力してください\",\n  \"Regenerate response\": \"もう一度回答する\",\n  \"Sorry, there was an error.\": \"すみません、エラーが発生しました。\",\n  \"Model\": \"モデル\",\n  \"Conversation\": \"会話\",\n  \"OR\": \"または\",\n  \"Loading...\": \"読み込み中...\",\n  \"Type a message...\": \"メッセージを入力...\",\n  \"Error fetching models.\": \"モデルの取得中にエラーが発生しました。\",\n  \"AI\": \"AI\",\n  \"You\": \"あなた\",\n  \"Cancel\": \"キャンセル\",\n  \"Save & Submit\": \"保存と送信\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"OpenAIのAPIキーがサイドバーの左下に設定されていることを確認してください。\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"このステップを完了した場合、OpenAIに問題が発生している可能性があります。\",\n  \"click if using a .env.local file\": \"もし.env.localファイルを使用している場合はこちらをクリックしてください\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"メッセージの文字数は{{maxLength}}文字までです。あなたは{{valueLength}}文字を入力しました。\",\n  \"Please enter a message\": \"メッセージを入力してください\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UIは、ChatGPTと同様のインターフェイスと機能を実現するための、チャットボットキットです。\",\n  \"Are you sure you want to clear all messages?\": \"すべてのメッセージを削除してもよろしいですか？\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"0.8のような高い値は出力をよりランダムにし、0.2のような低い値はより焦点を絞り、決定論的にします。\"\n}\n"
  },
  {
    "path": "ui/public/locales/ja/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/ja/markdown.json",
    "content": "{\n  \"Copy code\": \"コードをコピー\",\n  \"Copied!\": \"コピーしました！\",\n  \"Enter file name\": \"ファイル名を入力\"\n}\n"
  },
  {
    "path": "ui/public/locales/ja/promptbar.json",
    "content": "{\n  \"New prompt\": \"新しいプロンプト\",\n  \"New folder\": \"新しいフォルダ\",\n  \"No prompts.\": \"プロンプトはありません\",\n  \"Search prompts...\": \"プロンプトの検索...\",\n  \"Name\": \"名前\",\n  \"Description\": \"説明\",\n  \"A description for your prompt.\": \"プロンプトの説明\",\n  \"Prompt\": \"プロンプト\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"プロンプトの内容。変数を表すには {{}} を使ってください。 例: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"保存\"\n}\n"
  },
  {
    "path": "ui/public/locales/ja/settings.json",
    "content": "{\n  \"Settings\": \"設定\",\n  \"Theme\": \"テーマ\",\n  \"Save\": \"保存\",\n  \"Dark mode\": \"ダークモード\",\n  \"Light mode\": \"ライトモード\"\n}\n"
  },
  {
    "path": "ui/public/locales/ja/sidebar.json",
    "content": "{\n  \"New folder\": \"新規フォルダ\",\n  \"New chat\": \"新規チャット\",\n  \"No conversations.\": \"会話履歴はありません。\",\n  \"Search conversations...\": \"会話を検索...\",\n  \"OpenAI API Key\": \"OpenAI APIキー\",\n  \"Import data\": \"会話履歴をインポート\",\n  \"Are you sure?\": \"よろしいですか？\",\n  \"Clear conversations\": \" 会話をクリア\",\n  \"Export data\": \"会話履歴をエクスポート\",\n  \"Dark mode\": \"ダークモード\",\n  \"Light mode\": \"ライトモード\",\n  \"Settings\": \"設定\"\n}\n"
  },
  {
    "path": "ui/public/locales/ko/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API 키가 필요합니다\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"사이드바 왼쪽 하단에 OpenAI API 키를 설정하세요.\",\n  \"Stop Generating\": \"생성 중지\",\n  \"Prompt limit is {{maxLength}} characters\": \"프롬프트 제한은 {{maxLength}}자입니다\",\n  \"System Prompt\": \"시스템 프롬트\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"당신은 OpenAI에서 훈련된 대규모 언어 모델 ChatGPT입니다. 사용자의 지시를 주의해서 따르세요. 마크다운을 사용하여 응답하세요.\",\n  \"Enter a prompt\": \"프롬프트를 입력하세요\",\n  \"Regenerate response\": \"응답 재생성\",\n  \"Sorry, there was an error.\": \"죄송합니다, 오류가 발생했습니다.\",\n  \"Model\": \"모델\",\n  \"Conversation\": \"대화\",\n  \"OR\": \"또는\",\n  \"Loading...\": \"로드 중...\",\n  \"Type a message...\": \"메시지를 입력하세요...\",\n  \"Error fetching models.\": \"모델을 가져오는 중 오류가 발생했습니다.\",\n  \"AI\": \"인공지능\",\n  \"You\": \"당신\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"OpenAI API 키가 사이드바 왼쪽 하단에 설정되어 있는지 확인하세요.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"이 단계를 완료한 경우 OpenAI에 문제가 있을 수도 있습니다.\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"메시지 제한은 {{maxLength}}자입니다. {{valueLength}}자를 입력했습니다.\",\n  \"Please enter a message\": \"메시지를 입력하세요\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI는 ChatGPT의 인터페이스와 기능을 모방하는 것을 목표로 둔 OpenAI의 채팅 모델들을 위한 고급 챗봇 키트입니다.\",\n  \"Are you sure you want to clear all messages?\": \"모든 메시지를 지우시겠습니까?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"0.8과 같은 높은 값은 출력을 더 무작위로 만들고, 0.2와 같은 낮은 값은 더 집중적이고 결정론적으로 만들어줍니다.\"\n}\n"
  },
  {
    "path": "ui/public/locales/ko/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/ko/markdown.json",
    "content": "{\n  \"Copy code\": \"코드 복사\",\n  \"Copied!\": \"복사 완료!\",\n  \"Enter file name\": \"파일 이름을 입력하세요\"\n}\n"
  },
  {
    "path": "ui/public/locales/ko/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/ko/settings.json",
    "content": "{\n  \"Dark mode\": \"다크 모드\",\n  \"Light mode\": \"라이트 모드\"\n}\n"
  },
  {
    "path": "ui/public/locales/ko/sidebar.json",
    "content": "{\n  \"New folder\": \"새 폴더\",\n  \"New chat\": \"새 채팅\",\n  \"No conversations.\": \"대화가 없습니다.\",\n  \"Search conversations...\": \"대화 검색...\",\n  \"OpenAI API Key\": \"OpenAI API 키\",\n  \"Import data\": \"대화 가져오기\",\n  \"Are you sure?\": \"확실합니까?\",\n  \"Clear conversations\": \"대화 지우기\",\n  \"Export data\": \"대화 내보내기\"\n}\n"
  },
  {
    "path": "ui/public/locales/pl/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Klucz do OpenAI API jest wymagany\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Proszę wprowadzić swój klucz do OpenAI API na pasku bocznym w lewym dolnym rogu\",\n  \"Stop Generating\": \"Zatrzymaj generowanie\",\n  \"Prompt limit is {{maxLength}} characters\": \"Limit prompta wynosi {{maxLength}} znaków\",\n  \"System Prompt\": \"Prompt systemowy\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Jesteś ChatGPT, duży model językowy wytrenowany przez OpenAI. Postępuj zgodnie z instrukcjami użytkownika. Odpowiedz za pomocą formatu markdown.\",\n  \"Enter a prompt\": \"Wprowadź prompt\",\n  \"Regenerate response\": \"Wygeneruj odpowiedź\",\n  \"Sorry, there was an error.\": \"Przepraszam, wystąpił błąd.\",\n  \"Model\": \"Model\",\n  \"Conversation\": \"Rozmowa\",\n  \"OR\": \"LUB\",\n  \"Loading...\": \"Ładowanie...\",\n  \"Type a message...\": \"Napisz wiadomość...\",\n  \"Error fetching models.\": \"Błąd podczas pobierania modelu\",\n  \"AI\": \"SI\",\n  \"You\": \"Ty\",\n  \"Cancel\": \"Anuluj\",\n  \"Save & Submit\": \"Zapisz i wyślij\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Upewnij się, że wprowadziłeś swój klucz do OpenAI API na pasku bocznym w lewym dolnym rogu\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Jeśli wykonałeś ten krok to oznacza, że mogą występować problemy po stronie OpenAI.\",\n  \"click if using a .env.local file\": \"kliknij jeśli używasz pliku .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Limit wiadomości wynosi {{maxLength}} znaków. Wprowadziłeś {{valueLength}} znaków.\",\n  \"Please enter a message\": \"Proszę wpisać swoją wiadomość\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI to zaawansowane narzędzie chatbotów dla modeli czatów od OpenAI, którego celem jest naśladowanie interfejsu i funkcjonalności ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Czy na pewno chcesz usunąć wszystkie wiadomości?\"\n}\n"
  },
  {
    "path": "ui/public/locales/pl/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/pl/markdown.json",
    "content": "{\n  \"Copy code\": \"Skopiuj kod\",\n  \"Copied!\": \"Skopiowany\",\n  \"Enter file name\": \"Wprowadź nazwę pliku\"\n}\n"
  },
  {
    "path": "ui/public/locales/pl/promptbar.json",
    "content": "{\n  \"New prompt\": \"Nowy prompt\",\n  \"New folder\": \"Nowy folder\",\n  \"No prompts.\": \"Brak promptów.\",\n  \"Search prompts...\": \"Szukaj promptów...\",\n  \"Name\": \"Nazwa\",\n  \"Description\": \"Opis\",\n  \"A description for your prompt.\": \"Opis Twojego prompta.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Zawartość prompta. Użyj {{}} żeby oznaczyć zmienną. Np.: {{nazwa}} jest {{przymiotnik}} {{rzeczownik}}\",\n  \"Save\": \"Zapisz\"\n}\n"
  },
  {
    "path": "ui/public/locales/pl/settings.json",
    "content": "{\n  \"Dark mode\": \"Tryb ciemny\",\n  \"Light mode\": \"Tryb jasny\"\n}\n"
  },
  {
    "path": "ui/public/locales/pl/sidebar.json",
    "content": "{\n  \"New folder\": \"Nowy folder\",\n  \"New chat\": \"Nowy chat\",\n  \"No conversations.\": \"Brak rozmów.\",\n  \"Search conversations...\": \"Szukaj rozmów...\",\n  \"OpenAI API Key\": \"Klucz do OpenAI API\",\n  \"Import data\": \"Import rozmów\",\n  \"Are you sure?\": \"Czy jesteś pewien?\",\n  \"Clear conversations\": \"Usuń rozmowy\",\n  \"Export data\": \"Eksport rozmów\"\n}\n"
  },
  {
    "path": "ui/public/locales/pt/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"A API Key da OpenAI é necessária\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Por favor, insira sua API Key da OpenAI no canto inferior esquerdo da barra lateral.\",\n  \"Stop Generating\": \"Parar de gerar\",\n  \"Prompt limit is {{maxLength}} characters\": \"O limite da mensagem é de {{maxLength}} caracteres\",\n  \"System Prompt\": \"Mensagem do sistema\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Você é o ChatGPT, um grande modelo de linguagem treinado pela OpenAI. Siga as instruções do usuário cuidadosamente. Responda usando markdown.\",\n  \"Enter a prompt\": \"Insira uma mensagem\",\n  \"Regenerate response\": \"Gerar resposta novamente\",\n  \"Sorry, there was an error.\": \"Desculpe, ocorreu um erro.\",\n  \"Model\": \"Modelo\",\n  \"Conversation\": \"Conversação\",\n  \"OR\": \"Ou\",\n  \"Loading...\": \"Carregando...\",\n  \"Type a message...\": \"Escreva uma mensagem...\",\n  \"Error fetching models.\": \"Erro ao buscar os modelos.\",\n  \"AI\": \"IA\",\n  \"You\": \"Você\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Certifique-se de que sua API Key da OpenAI esteja definida na parte inferior esquerda da barra lateral.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Se você concluiu esta etapa, o OpenAI pode estar com problemas.\",\n  \"click if using a .env.local file\": \"clique se estiver usando um arquivo .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"O limite de mensagens é de {{maxLength}} caracteres. Você inseriu {{valueLength}} caracteres\",\n  \"Please enter a message\": \"Por favor, insira uma mensagem\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI é um kit de chatbot avançado para os modelos de chat do OpenAI com o objetivo de imitar a interface e a funcionalidade do ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Tem certeza de que deseja limpar todas as mensagens?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Valores mais altos como 0,8 tornarão a saída mais aleatória, enquanto valores mais baixos como 0,2 a tornarão mais focada e determinística.\"\n}\n"
  },
  {
    "path": "ui/public/locales/pt/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/pt/markdown.json",
    "content": "{\n  \"Copy code\": \"Copiar código\",\n  \"Copied!\": \"Copiado!\",\n  \"Enter file name\": \"Insira o nome do arquivo\"\n}\n"
  },
  {
    "path": "ui/public/locales/pt/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/pt/settings.json",
    "content": "{\n  \"Dark mode\": \"Modo escuro\",\n  \"Light mode\": \"Modo claro\"\n}\n"
  },
  {
    "path": "ui/public/locales/pt/sidebar.json",
    "content": "{\n  \"New folder\": \"Nova pasta\",\n  \"New chat\": \"Novo chat\",\n  \"No conversations.\": \"Não há conversas.\",\n  \"Search conversations...\": \"Buscar conversas...\",\n  \"OpenAI API Key\": \"API Key da OpenAI\",\n  \"Import data\": \"Importar conversas\",\n  \"Are you sure?\": \"Tem certeza?\",\n  \"Clear conversations\": \"Apagar conversas\",\n  \"Export data\": \"Exportar conversas\"\n}\n"
  },
  {
    "path": "ui/public/locales/ro/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Este necesară cheia API OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Introduceți cheia API OpenAI în partea stângă jos a barei laterale\",\n  \"Stop Generating\": \"Nu mai generați\",\n  \"Prompt limit is {{maxLength}} characters\": \"Limita mesajelor este de {{maxLength}} caractere\",\n  \"System Prompt\": \"Solicitări de sistem\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Sunteți ChatGPT, un model de limbă mare antrenat de OpenAI. Urmați cu atenție instrucțiunile de utilizare. Vă rugăm să răspundeți folosind markdown.\",\n  \"Enter a prompt\": \"Introdu o cerere\",\n  \"Regenerate response\": \"Regenerați răspunsul\",\n  \"Sorry, there was an error.\": \"Scuze, a aparut o eroare.\",\n  \"Model\": \"Model\",\n  \"Conversation\": \"Conversaţie\",\n  \"OR\": \"SAU\",\n  \"Loading...\": \"Se încarcă...\",\n  \"Type a message...\": \"Scrie un mesaj...\",\n  \"Error fetching models.\": \"A apărut o eroare la preluarea șabloanelor.\",\n  \"AI\": \"IA\",\n  \"You\": \"Tu\",\n  \"Cancel\": \"Anulare\",\n  \"Save & Submit\": \"Salvați și trimiteți\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Asigurați-vă că cheia dvs. API OpenAI este introdusă în partea stângă jos a barei laterale\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Dacă ați parcurs acest pas, OpenAI poate întâmpina probleme.\",\n  \"click if using a .env.local file\": \"Faceți clic dacă utilizați un fișier .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Limita mesajelor este de {{maxLength}} caractere. Ați introdus {{valueLength}} caractere.\",\n  \"Please enter a message\": \"Vă rugăm să scrieți un mesaj\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI este un kit de chatbot avansat pentru șabloanele de chat OpenAI, care își propune să imite interfața și funcționalitatea ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Sigur doriți să ștergeți toate mesajele?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Valori mai mari, cum ar fi 0,8, vor face ieșirea mai aleatorie, în timp ce valori mai mici, cum ar fi 0,2, o vor face mai concentrată și deterministă.\"\n\n}\n"
  },
  {
    "path": "ui/public/locales/ro/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/ro/markdown.json",
    "content": "{\n  \"Copy code\": \"Copiați codul\",\n  \"Copied!\": \"Copiat!\",\n  \"Enter file name\": \"Introduceți numele fișierului\"\n}\n"
  },
  {
    "path": "ui/public/locales/ro/promptbar.json",
    "content": "{\n  \"New prompt\": \"Noua solicitare\",\n  \"New folder\": \"Dosar nou\",\n  \"No prompts.\": \"Fără solicitări.\",\n  \"Search prompts...\": \"Cereri de căutare...\",\n  \"Name\": \"Nume\",\n  \"Description\": \"Descriere\",\n  \"A description for your prompt.\": \"Descrierea solicitării prompt.\",\n  \"Prompt\": \"Îndemnuri\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Conținut prompt. Utilizați {{}} pentru a indica o variabilă. De exemplu: {{nume}} este un {{adjectiv}} {{substantiv}}\",\n  \"Save\": \"Salvați\"\n}\n"
  },
  {
    "path": "ui/public/locales/ro/settings.json",
    "content": "{\n  \"Dark mode\": \"Modul întunecat\",\n  \"Light mode\": \"Modul de golire\"\n}\n"
  },
  {
    "path": "ui/public/locales/ro/sidebar.json",
    "content": "{\n  \"New folder\": \"Folder nou\",\n  \"New chat\": \"Conversație nouă\",\n  \"No conversations.\": \"Nicio conversație.\",\n  \"Search conversations...\": \"Căutați conversații...\",\n  \"OpenAI API Key\": \"Cheia API OpenAI\",\n  \"Import data\": \"Importați conversații\",\n  \"Are you sure?\": \"Esti sigur?\",\n  \"Clear conversations\": \"Ștergeți conversațiile\",\n  \"Export data\": \"Exportați conversații\"\n}\n"
  },
  {
    "path": "ui/public/locales/ru/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Необходим ключ OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Пожалуйста введите API-ключ OpenAI в левом нижнем углу\",\n  \"Stop Generating\": \"Прекратить\",\n  \"Prompt limit is {{maxLength}} characters\": \"Лимит сообщения на символы: {{maxLength}} символов\",\n  \"System Prompt\": \"Системное сообщение\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Вы ChatGPT, большая языковая модель, созданная компанией OpenAI. Следуйте инструкциям пользователя. Отвечайте на сообщения, используя Markdown\",\n  \"Enter a prompt\": \"Введите сообщение\",\n  \"Regenerate response\": \"Перегенерировать сообщение\",\n  \"Sorry, there was an error.\": \"Просим прощения, произошла ошибка\",\n  \"Model\": \"Модель\",\n  \"Conversation\": \"Чат\",\n  \"OR\": \"ИЛИ\",\n  \"Loading...\": \"Пожалуйста подождите...\",\n  \"Type a message...\": \"Введите сообщение...\",\n  \"Error fetching models.\": \"Ошибка при получении списка моделей\",\n  \"AI\": \"Бот\",\n  \"You\": \"Вы\",\n  \"Cancel\": \"Отмена\",\n  \"Save & Submit\": \"Отредактировать\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Убедитесь, что вы ввели API-ключ OpenAI.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Если вы выполнили этот шаг, то возможно OpenAI может испытывать проблемы\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Лимит сообщения: {{maxLength}} символов. Вы ввели {{valueLength}} символов.\",\n  \"Please enter a message\": \"Пожалуйста введите сообщение\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI - продвинутый интерфейс чатбота для чат-моделей OpenAI, имитирующий интерфейс ChatGPT\",\n  \"Are you sure you want to clear all messages?\": \"Вы уверены, что хотите удалить все сообщения?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Более высокие значения, такие как 0,8, сделают вывод более случайным, в то время как более низкие значения, например, 0,2, сделают его более фокусированным и детерминированным.\"\n}\n"
  },
  {
    "path": "ui/public/locales/ru/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/ru/markdown.json",
    "content": "{\n  \"Copy code\": \"Скопировать\",\n  \"Copied!\": \"Скопировано!\",\n  \"Enter file name\": \"Введите имя файла для загрузки\"\n}\n"
  },
  {
    "path": "ui/public/locales/ru/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/ru/settings.json",
    "content": "{\n  \"Dark mode\": \"Темный режим\",\n  \"Light mode\": \"Светлый режим\"\n}\n"
  },
  {
    "path": "ui/public/locales/ru/sidebar.json",
    "content": "{\n  \"New folder\": \"Новая папка\",\n  \"New chat\": \"Новый чат\",\n  \"No conversations.\": \"Нет чатов.\",\n  \"Search conversations...\": \"Поиск чатов...\",\n  \"OpenAI API Key\": \"API-ключ OpenAI\",\n  \"Import data\": \"Импортировать чаты\",\n  \"Are you sure?\": \"Вы уверены?\",\n  \"Clear conversations\": \"Удалить чаты\",\n  \"Export data\": \"Экспортировать чаты\"\n}\n"
  },
  {
    "path": "ui/public/locales/si/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API යතුර අවශ්‍යයි\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"කරුණාකර ඔබේ OpenAI API යතුර පැති තීරුවේ පහළ වම්පසින් සකසන්න.\",\n  \"Stop Generating\": \"උත්පාදනය නවත්වන්න\",\n  \"Prompt limit is {{maxLength}} characters\": \"වචන සීමාව අනුලකුණු {{maxLength}} කි\",\n  \"System Prompt\": \"පද්ධති ඉඟිය\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"ඔබ ChatGPT, OpenAI විසින් පුහුණු කරන ලද විශාල භාෂා ආකෘතියකි. පරිශීලක උපදෙස් ප්රවේශමෙන් අනුගමනය කරන්න. මාර්ක්ඩවුන් භාවිතයෙන් ප්‍රතිචාර දක්වන්න.\",\n  \"Enter a prompt\": \"ප්‍රේරකයක් ඇතුළු කරන්න\",\n  \"Regenerate response\": \"ප්‍රතිචාරය පුනර්ජනනය කරන්න\",\n  \"Sorry, there was an error.\": \"සමාවන්න, දෝෂයක් ඇති විය.\",\n  \"Model\": \"ආකෘතිය\",\n  \"Conversation\": \"සංවාදය\",\n  \"OR\": \"හෝ\",\n  \"Loading...\": \"පූරණය වෙමින්...\",\n  \"Type a message...\": \"පණිවිඩයක් ටයිප් කරන්න...\",\n  \"Error fetching models.\": \"ආකෘති ලබා ගැනීමේ දෝෂයකි.\",\n  \"AI\": \"AI\",\n  \"You\": \"ඔබ\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"ඔබේ OpenAI API යතුර පැති තීරුවේ පහළ වම්පස සකසා ඇති බවට වග බලා ගන්න.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"ඔබ මෙම පියවර සම්පූර්ණ කළේ නම්, OpenAI හි ගැටලුවක් විය හැකිය.\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"පණිවිඩ සීමාව අකුරු {{maxLength}} කි. ඔබ අක්ෂර {{valueLength}} ඇතුළත් කර ඇත.।\",\n  \"Please enter a message\": \"කරුණාකර පණිවිඩයක් ඇතුළු කරන්න\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI යනු ChatGPT හි අතුරු මුහුණත සහ ක්‍රියාකාරීත්වය අනුකරණය කිරීම අරමුණු කරගත් OpenAI හි චැට් මාදිලි සඳහා වන උසස් චැට්බෝට් කට්ටලයකි.\",\n  \"Are you sure you want to clear all messages?\": \"ඔබට සියලු පණිවිඩ හිස් කිරීමට අවශ්‍ය බව විශ්වාසද?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"0.8 ආකෘතිය ඉහළට පිරිමිතුරු වර්ණයෙන් තිබේ විය යුතුය, නමුත් 0.2 ආකෘතිය අවම වශයෙන් එය විශේෂිත හා නිර්ණායක වනු ඇත.\"\n}\n"
  },
  {
    "path": "ui/public/locales/si/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/si/markdown.json",
    "content": "{\n  \"Copy code\": \"කේතය පිටපත් කරන්න\",\n  \"Copied!\": \"පිටපත් කළා!\",\n  \"Enter file name\": \"ගොනු නාමය ඇතුළත් කරන්න\"\n}\n"
  },
  {
    "path": "ui/public/locales/si/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/si/settings.json",
    "content": "{\n  \"Dark mode\": \"අඳුරු මාදිලිය\",\n  \"Light mode\": \"ආලෝක මාදිලිය\"\n}\n"
  },
  {
    "path": "ui/public/locales/si/sidebar.json",
    "content": "{\n  \"New folder\": \"නව ෆෝල්ඩරය\",\n  \"New chat\": \"නව සංවාදයක්\",\n  \"No conversations.\": \"සංවාද නැත.\",\n  \"Search conversations...\": \"සංවාද සොයන්න...\",\n  \"OpenAI API Key\": \"OpenAI API යතුර\",\n  \"Import data\": \"සංවාද ආයාත කරන්න\",\n  \"Are you sure?\": \"ඔබට විශ්වාස ද?\",\n  \"Clear conversations\": \"සංවාද මකන්න\",\n  \"Export data\": \"සංවාද නිර්යාත කරන්න\"\n}\n"
  },
  {
    "path": "ui/public/locales/sv/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API-nyckel krävs\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Vänligen ange din OpenAI API-nyckel längst ner till vänster i sidofältet.\",\n  \"Stop Generating\": \"Sluta generera\",\n  \"Prompt limit is {{maxLength}} characters\": \"Din prompt kan inte ha fler än {{maxLength}} tecken\",\n  \"System Prompt\": \"System prompt\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Du är ChatGPT, en stor språkmodell tränad av OpenAI. Följ användarens instruktioner noggrant. Svara genom att använda markdown.\",\n  \"Enter a prompt\": \"Ange en prompt\",\n  \"Regenerate response\": \"Återskapa svar\",\n  \"Sorry, there was an error.\": \"Ursäkta, det uppstod ett fel.\",\n  \"Model\": \"Modell\",\n  \"Conversation\": \"Konversation\",\n  \"OR\": \"ELLER\",\n  \"Loading...\": \"Laddar...\",\n  \"Type a message...\": \"Skriv ett meddelande...\",\n  \"Error fetching models.\": \"Det gick inte att hämta modeller.\",\n  \"AI\": \"AI\",\n  \"You\": \"Du\",\n  \"Cancel\": \"Avbryt\",\n  \"Save & Submit\": \"Spara & Skicka\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Se till att du har angett din OpenAI API-nyckel längst ner till vänster i sidofältet.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Om du slutförde det här steget kan OpenAI ha problem.\",\n  \"click if using a .env.local file\": \"klicka om du använder en .env.local-fil\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Meddelandegränsen är {{maxLength}} tecken. Du har angett {{valueLength}} tecken.\",\n  \"Please enter a message\": \"Vänligen ange ett meddelande\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI är ett avancerat chatbot-kit för OpenAI:s chattmodeller som syftar till att efterlikna ChatGPT:s gränssnitt och funktionalitet.\",\n  \"Are you sure you want to clear all messages?\": \"Är du säker på att du vill rensa alla meddelanden?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Högre värden som 0,8 kommer att göra utdata mer slumpmässig, medan lägre värden som 0,2 kommer att göra den mer fokuserad och deterministisk.\"\n}\n"
  },
  {
    "path": "ui/public/locales/sv/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/sv/markdown.json",
    "content": "{\n  \"Copy code\": \"Kopiera kod\",\n  \"Copied!\": \"Kopierad!\",\n  \"Enter file name\": \"Ange filnamn\"\n}\n"
  },
  {
    "path": "ui/public/locales/sv/promptbar.json",
    "content": "{\n  \"New prompt\": \"Ny prompt\",\n  \"New folder\": \"Ny mapp\",\n  \"No prompts.\": \"Inga prompts.\",\n  \"Search prompts...\": \"Sök prompts...\",\n  \"Name\": \"Namn\",\n  \"Description\": \"Beskrivning\",\n  \"A description for your prompt.\": \"En beskrivning för din prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt-innehåll. Använd {{}} för att beteckna en variabel. Ex: {{namn}} är ett {{adjektiv}} {{substantiv}}\",\n  \"Save\": \"Spara\"\n}\n"
  },
  {
    "path": "ui/public/locales/sv/settings.json",
    "content": "{\n  \"Dark mode\": \"Mörkt läge\",\n  \"Light mode\": \"Ljust läge\"\n}\n"
  },
  {
    "path": "ui/public/locales/sv/sidebar.json",
    "content": "{\n  \"New folder\": \"Ny mapp\",\n  \"New chat\": \"Ny chatt\",\n  \"No conversations.\": \"Inga konversationer.\",\n  \"Search conversations...\": \"Sök konversationer...\",\n  \"OpenAI API Key\": \"OpenAI API-nyckel\",\n  \"Import data\": \"Importera konversationer\",\n  \"Are you sure?\": \"Är du säker?\",\n  \"Clear conversations\": \"Radera konversationer\",\n  \"Export data\": \"Exportera konversationer\"\n}\n"
  },
  {
    "path": "ui/public/locales/te/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"ఒపెన్ ఎయి ఐ API కీ అవసరం\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"దయచేసి మీ OpenAI API కీని సైడ్ బార్ యొక్క దిగువ ఎడమ భాగంలో సెట్ చేయండి.\",\n  \"Stop Generating\": \"జెనరేట్ చేస్తున్న ప్రక్రియ నిలిపేయి\",\n  \"Prompt limit is {{maxLength}} characters\": \"ప్రాంప్ట్(సంకేతం) పరిమితి {{maxLength}} అక్షరాలు మాత్రమే\",\n  \"System Prompt\": \"సిస్టమ్ ప్రాంప్ట్\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"మీరు ChatGPT, ఒక పెద్ద భాషా మోడల్ ఓపెన్‌ఏఐ ద్వారా ట్రైన్ చేయబడింది. యూజర్ ఇన్స్ట్రక్షన్స్ కనుగొనండి. మార్క్‌డౌన్ ఉపయోగించి సమాధానం ఇవ్వండి.\",\n  \"Enter a prompt\": \"ఒక ప్రాంప్ట్(సంకేతం) నమోదు చేయండి\",\n  \"Regenerate response\": \"పునరుత్పాదించు సమాధానం\",\n  \"Sorry, there was an error.\": \"క్షమించండి, ఒక పొరపాటు జరిగింది.\",\n  \"Model\": \"మోడల్\",\n  \"Conversation\": \"సంవాదం\",\n  \"OR\": \"లేదా\",\n  \"Loading...\": \"లోడ్ అవుతోంది...\",\n  \"Type a message...\": \"సందేశం టైప్ చేయండి...\",\n  \"Error fetching models.\": \"మోడల్స్ పొందడం లోపం జరిగింది.\",\n  \"AI\": \"AI\",\n  \"You\": \"నీవు\",\n  \"Cancel\": \"Cancel\",\n  \"Save & Submit\": \"Save & Submit\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"మీరు ఖాళీలో ఎడమ ఎరుగులో మీ OpenAI API కీను సెట్ చేస్తున్నారని ఖచ్చితం చేయండి.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"మీరు ఈ హంతం పూర్తి చేసినా, OpenAI సమస్యలు ఉన్నట్లు ఉంటాయి.\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"సందేశం పరిమితి {{maxLength}} అక్షరాలు. మీరు {{valueLength}} అక్షరాలు నమోదు చేసారు.\",\n  \"Please enter a message\": \"దయచేసి ఒక సందేశం నమోదు చేయండి\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI ఒక అభ్యంతర సంవిధానం మరియు కార్యాచరణ లక్ష్యం తీసుకున్న OpenAI ఛాట్ మోడల్లలో మార్పులు చేయడానికి ప్రయత్నిస్తుంది, ChatGPT ఇంటర్ఫేస్ మరియు కార్యాచరణను అనుకరించడానికి.\",\n  \"Are you sure you want to clear all messages?\": \"మీరు అన్ని సందేశాలను తొలగించాలా?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"0.8 పైకి ఉన్న పెరిగిన విలువలు ఎక్కువగా విస్తరించినట్లుగా ఉంటాయి, మరియు 0.2 పైకి ఉన్న తక్కువ విలువలు కేంద్రీకృతం మరియు నిర్ణయాత్మకంగా మార్చవచ్చు.\"\n}\n"
  },
  {
    "path": "ui/public/locales/te/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/te/markdown.json",
    "content": "{\n  \"Copy code\": \"కోడ్‌ను కాపీ చేయండి\",\n  \"Copied!\": \"కాపీ చేయబడింది!\",\n  \"Enter file name\": \"ఫైల్ పేరు నమోదు చేయండి\"\n}\n"
  },
  {
    "path": "ui/public/locales/te/promptbar.json",
    "content": "{\n  \"New prompt\": \"New prompt\",\n  \"New folder\": \"New folder\",\n  \"No prompts.\": \"No prompts.\",\n  \"Search prompts...\": \"Search prompts...\",\n  \"Name\": \"Name\",\n  \"Description\": \"Description\",\n  \"A description for your prompt.\": \"A description for your prompt.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\",\n  \"Save\": \"Save\"\n}\n"
  },
  {
    "path": "ui/public/locales/te/settings.json",
    "content": "{\n  \"Dark mode\": \"డార్క్ మోడ్\",\n  \"Light mode\": \"లైట్ మోడ్\"\n}\n"
  },
  {
    "path": "ui/public/locales/te/sidebar.json",
    "content": "{\n  \"New folder\": \"కొత్త ఫోల్డర్\",\n  \"New chat\": \"కొత్త చాట్\",\n  \"No conversations.\": \"సంభాషణలు లేవు.\",\n  \"Search conversations...\": \"సంభాషణలు వెతకండి...\",\n  \"OpenAI API Key\": \"ఒపెన్ ఎయి ఐ API కీ \",\n  \"Import data\": \"సంభాషణలు దిగుమతి చేయండి\",\n  \"Are you sure?\": \"మీరు ఖచ్చితంగా ఉన్నారా?\",\n  \"Clear conversations\": \"సంభాషణలు తొలగించు\",\n  \"Export data\": \"సంభాషణలు ఎగుమతి చేయండి\"\n}\n"
  },
  {
    "path": "ui/public/locales/tr/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"OpenAI API Anahtarı Gerekli\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Lütfen OpenAI API anahtarınızı yan çubuğun sol altınan'dan ayarlayın.\",\n  \"Stop Generating\": \"Durdur\",\n  \"Prompt limit is {{maxLength}} characters\": \"Prompt sınırı {{maxLength}} karakterdir\",\n  \"System Prompt\": \"Sistem Prompt\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Sen ChatGPT'sin, OpenAI tarafından eğitilmiş büyük bir dil modelisin. Kullanıcının talimatlarını dikkatlice takip et. Yanıtını markdown kullanarak ver.\",\n  \"Enter a prompt\": \"Bir prompt girin\",\n  \"Regenerate response\": \"Yanıtı Yeniden Oluştur\",\n  \"Sorry, there was an error.\": \"Üzgünüm, bir hata oluştu.\",\n  \"Model\": \"Model\",\n  \"Conversation\": \"Sohbet\",\n  \"OR\": \"VEYA\",\n  \"Loading...\": \"Yükleniyor...\",\n  \"Type a message...\": \"Bir mesaj yazın...\",\n  \"Error fetching models.\": \"Modeller getirilirken hata oluştu.\",\n  \"AI\": \"Yapay Zeka\",\n  \"You\": \"Sen\",\n  \"Cancel\": \"İptal\",\n  \"Save & Submit\": \"Kaydet ve Gönder\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"OpenAI API anahtarınızın yan çubuğun sol altında ayarlandığından emin ol.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Bu adımı tamamladıysanız, OpenAI sorun yaşıyor olabilir.\",\n  \"click if using a .env.local file\": \"Eğer .env.local dosyası kullanıyorsanız tıklayın\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Mesaj sınırı {{maxLength}} karakterdir. {{valueLength}} karakter girdiniz.\",\n  \"Please enter a message\": \"Lütfen bir mesaj girin\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI, ChatGPT'nin arayüz ve işlevselliğini taklit etmeyi amaçlayan OpenAI'in sohbet modelleri için gelişmiş bir sohbetbot kitidir.\",\n  \"Are you sure you want to clear all messages?\": \"Tüm mesajları temizlemek istediğinize emin misiniz?\"\n}\n"
  },
  {
    "path": "ui/public/locales/tr/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/tr/markdown.json",
    "content": "{\n  \"Copy code\": \"Kodu kopyala\",\n  \"Copied!\": \"Kopyalandi!\",\n  \"Enter file name\": \"Dosya ismi gir\"\n}\n"
  },
  {
    "path": "ui/public/locales/tr/promptbar.json",
    "content": "{\n  \"New prompt\": \"Yeni prompt\",\n  \"New folder\": \"Yeni klasör\",\n  \"No prompts.\": \"Prompt yok.\",\n  \"Search prompts...\": \"Prompt'ları ara...\",\n  \"Name\": \"İsim\",\n  \"Description\": \"Açıklama\",\n  \"A description for your prompt.\": \"Prompt'unuz için bir açıklama.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Prompt içeriği. Değişken belirtmek için {{}} kullanın. Örn: {{ad}} bir {{sıfat}} {{isim}}\",\n  \"Save\": \"Kaydet\"\n}\n"
  },
  {
    "path": "ui/public/locales/tr/sidebar.json",
    "content": "{\n  \"New folder\": \"Yeni klasör\",\n  \"New chat\": \"Yeni sohbet\",\n  \"No conversations.\": \"Hiçbir konuşma yok.\",\n  \"Search conversations...\": \"Sohbetleri ara...\",\n  \"OpenAI API Key\": \"OpenAI API Anahtarı\",\n  \"Import data\": \"Veri içe aktar\",\n  \"Are you sure?\": \"Emin misiniz?\",\n  \"Clear conversations\": \"Konuşmaları temizle\",\n  \"Export data\": \"Veri dışa aktar\",\n  \"Dark mode\": \"Karanlık mod\",\n  \"Light mode\": \"Aydınlık mod\",\n  \"Plugin Keys\": \"Plugin Anahtarları\"\n}\n"
  },
  {
    "path": "ui/public/locales/vi/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"Yêu cầu nhập API Key từ tài khoản OpenAI\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"Vui lòng nhập API Key từ tài khoản OpenAI của bạn vào ô dưới cùng của thanh bên trái.\",\n  \"Stop Generating\": \"Dừng tạo\",\n  \"Prompt limit is {{maxLength}} characters\": \"Giới hạn Prompt là {{maxLength}} ký tự\",\n  \"System Prompt\": \"Prompt hệ thống\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"Bạn là ChatGPT, một mô hình ngôn ngữ lớn được đào tạo bởi OpenAI. Hãy tuân theo hướng dẫn của người dùng một cách cẩn thận. Phản hồi bằng cách sử dụng định dạng markdown.\",\n  \"Enter a prompt\": \"Nhập một Prompt\",\n  \"Regenerate response\": \"Tạo lại phản hồi\",\n  \"Sorry, there was an error.\": \"Xin lỗi, đã xảy ra lỗi.\",\n  \"Model\": \"Mô hình\",\n  \"Conversation\": \"Cuộc trò chuyện\",\n  \"OR\": \"HOẶC\",\n  \"Loading...\": \"Đang tải...\",\n  \"Type a message...\": \"Nhập một tin nhắn...\",\n  \"Error fetching models.\": \"Lỗi khi truy xuất mô hình.\",\n  \"AI\": \"AI\",\n  \"You\": \"Bạn\",\n  \"Cancel\": \"Hủy\",\n  \"Save & Submit\": \"Lưu & Gửi\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"Hãy đảm bảo rằng khóa API từ tài khoản OpenAI của bạn đã được nhập vào ô dưới cùng của thanh bên trái.\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"Nếu bạn đã hoàn thành bước này, OpenAI có thể đang gặp sự cố.\",\n  \"click if using a .env.local file\": \"Bấm vào đây nếu dùng tệp .env.local\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"Giới hạn tin nhắn là {{maxLength}} ký tự. Bạn đã nhập {{valueLength}} ký tự.\",\n  \"Please enter a message\": \"Vui lòng nhập một tin nhắn\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI là một bộ công cụ chatbot tiên tiến cho các mô hình chat của OpenAI nhằm mô phỏng giao diện và chức năng của ChatGPT.\",\n  \"Are you sure you want to clear all messages?\": \"Bạn có chắc chắn muốn xóa tất cả tin nhắn không?\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"Các giá trị cao hơn như 0,8 sẽ làm cho đầu ra ngẫu nhiên hơn, trong khi các giá trị thấp hơn như 0,2 sẽ làm cho đầu ra tập trung và xác định hơn.\"\n}\n"
  },
  {
    "path": "ui/public/locales/vi/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/vi/markdown.json",
    "content": "{\n  \"Copy code\": \"Sao chép mã\",\n  \"Copied!\": \"Đã sao chép!\",\n  \"Enter file name\": \"Nhập tên file\"\n}\n"
  },
  {
    "path": "ui/public/locales/vi/promptbar.json",
    "content": "{\n  \"New prompt\": \"Prompt mới\",\n  \"New folder\": \"Thư mục mới\",\n  \"No prompts.\": \"Không có Prompt nào.\",\n  \"Search prompts...\": \"Tìm kiếm các Prompt...\",\n  \"Name\": \"Tên\",\n  \"Description\": \"Mô tả\",\n  \"A description for your prompt.\": \"Một mô tả cho Prompt của bạn.\",\n  \"Prompt\": \"Prompt\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"Nội dung Prompt. Sử dụng {{}} để biểu thị một biến. Ví dụ: {{name}} là một {{adjective}} {{noun}}\",\n  \"Save\": \"Lưu\"\n}\n"
  },
  {
    "path": "ui/public/locales/vi/settings.json",
    "content": "{\n  \"Dark mode\": \"Chế độ tối\",\n  \"Light mode\": \"Chế độ sáng\"\n}\n"
  },
  {
    "path": "ui/public/locales/vi/sidebar.json",
    "content": "{\n  \"New folder\": \"Thư mục mới\",\n  \"New chat\": \"Tạo hội thoại mới\",\n  \"No conversations.\": \"Không có hội thoại nào.\",\n  \"Search conversations...\": \"Tìm kiếm các cuộc hội thoại...\",\n  \"OpenAI API Key\": \"OpenAI API Key\",\n  \"Import data\": \"Nhập dữ liệu hội thoại\",\n  \"Are you sure?\": \"Bạn chắc chắn chứ?\",\n  \"Clear conversations\": \"Xoá các đoạn hội thoại\",\n  \"Export data\": \"Xuất dữ liệu hội thoại\"\n}\n"
  },
  {
    "path": "ui/public/locales/zh/chat.json",
    "content": "{\n  \"OpenAI API Key Required\": \"需要 OpenAI API 密钥\",\n  \"Please set your OpenAI API key in the bottom left of the sidebar.\": \"请在侧边栏左下角设置您的 OpenAI API 密钥。\",\n  \"If you don't have an OpenAI API key, you can get one here: \": \"如果你没有 OpenAI API 密钥，你可以在此获取：\",\n  \"Stop Generating\": \"停止生成\",\n  \"Prompt limit is {{maxLength}} characters\": \"提示字数限制为 {{maxLength}} 个字符\",\n  \"New Conversation\": \"新的聊天\",\n  \"System Prompt\": \"系统提示\",\n  \"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.\": \"你是 ChatGPT，一个由 OpenAI 训练的大型语言模型。请仔细遵循用户的指示。使用 Markdown 格式进行回应。\",\n  \"Enter a prompt\": \"输入一个提示\",\n  \"Regenerate response\": \"重新生成回应\",\n  \"Sorry, there was an error.\": \"抱歉，出现了错误。\",\n  \"Model\": \"模型\",\n  \"Conversation\": \"对话\",\n  \"OR\": \"或\",\n  \"Loading...\": \"加载中...\",\n  \"Type a message or type \\\"/\\\" to select a prompt...\": \"输入一条消息或键入 \\\"/\\\" 以选择提示...\",\n  \"Error fetching models.\": \"获取模型时出错。\",\n  \"AI\": \"AI\",\n  \"You\": \"你\",\n  \"Cancel\": \"取消\",\n  \"Save & Submit\": \"保存并提交\",\n  \"Make sure your OpenAI API key is set in the bottom left of the sidebar.\": \"请确保您的 OpenAI API 密钥已在侧边栏左下角设置。\",\n  \"If you completed this step, OpenAI may be experiencing issues.\": \"如果您已完成此步骤，OpenAI 可能遇到了问题。\",\n  \"click if using a .env.local file\": \"click if using a .env.local file\",\n  \"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.\": \"消息字数限制为 {{maxLength}} 个字符。您已输入 {{valueLength}} 个字符。\",\n  \"Please enter a message\": \"请输入一条消息\",\n  \"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.\": \"Chatbot UI 是一个高级聊天机器人工具包，旨在模仿 OpenAI 聊天模型的 ChatGPT 界面和功能。\",\n  \"Are you sure you want to clear all messages?\": \"你确定要清除所有的消息吗？\",\n  \"Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\": \"较高的数值（例如0.8）会使输出更随机，而较低的数值（例如0.2）会使输出更加聚焦和确定性更强。\",\n  \"View Account Usage\": \"查阅账户用量\",\n  \"Temperature\": \"生成温度\",\n  \"Precise\": \"保守\",\n  \"Neutral\": \"中立\",\n  \"Creative\": \"随性\"\n}\n"
  },
  {
    "path": "ui/public/locales/zh/common.json",
    "content": "{}\n"
  },
  {
    "path": "ui/public/locales/zh/markdown.json",
    "content": "{\n  \"Copy code\": \"复制代码\",\n  \"Copied!\": \"已复制！\",\n  \"Enter file name\": \"输入文件名\"\n}\n"
  },
  {
    "path": "ui/public/locales/zh/promptbar.json",
    "content": "{\n  \"New prompt\": \"新建提示\",\n  \"New folder\": \"新建文件夹\",\n  \"No prompts.\": \"无提示词\",\n  \"Search prompts...\": \"搜索提示...\",\n  \"Name\": \"名称\",\n  \"A name for your prompt.\": \"提示词名称\",\n  \"Description\": \"描述\",\n  \"A description for your prompt.\": \"提示词描述\",\n  \"Prompt\": \"提示词\",\n  \"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}\": \"提示内容。使用 {{}} 表示一个变量。例如：{{name}} 是一个 {{adjective}} {{noun}}\",\n  \"Save\": \"保存\"\n}\n"
  },
  {
    "path": "ui/public/locales/zh/settings.json",
    "content": "{\n  \"Settings\": \"设置\",\n  \"Theme\": \"主题\",\n  \"Dark mode\": \"深色模式\",\n  \"Light mode\": \"浅色模式\",\n  \"Save\": \"保存\"\n}\n"
  },
  {
    "path": "ui/public/locales/zh/sidebar.json",
    "content": "{\n  \"New folder\": \"新建文件夹\",\n  \"New chat\": \"新建聊天\",\n  \"New Conversation\": \"新的聊天\",\n  \"No conversations.\": \"无对话\",\n  \"Search conversations...\": \"搜索对话...\",\n  \"OpenAI API Key\": \"OpenAI API 密钥\",\n  \"Import data\": \"导入对话\",\n  \"Are you sure?\": \"确定吗？\",\n  \"Clear conversations\": \"清空对话\",\n  \"Settings\": \"设置\",\n  \"Export data\": \"导出对话\",\n  \"Plugin Keys\": \"插件密钥\"\n}\n"
  },
  {
    "path": "ui/services/errorService.ts",
    "content": "import { useMemo } from 'react';\n\nimport { useTranslation } from 'next-i18next';\n\nimport { ErrorMessage } from '@/types/error';\n\nconst useErrorService = () => {\n  const { t } = useTranslation('chat');\n\n  return {\n    getModelsError: useMemo(\n      () => (error: any) => {\n        return !error\n          ? null\n          : ({\n              title: t('Error fetching models.'),\n              code: error.status || 'unknown',\n              messageLines: error.statusText\n                ? [error.statusText]\n                : [\n                    t(\n                      'Make sure your OpenAI API key is set in the bottom left of the sidebar.',\n                    ),\n                    t(\n                      'If you completed this step, OpenAI may be experiencing issues.',\n                    ),\n                  ],\n            } as ErrorMessage);\n      },\n      [t],\n    ),\n  };\n};\n\nexport default useErrorService;\n"
  },
  {
    "path": "ui/services/useApiService.ts",
    "content": "import { useCallback } from 'react';\n\nimport { useFetch } from '@/hooks/useFetch';\n\nexport interface GetModelsRequestProps {\n  key: string;\n}\n\nconst useApiService = () => {\n  const fetchService = useFetch();\n\n  // const getModels = useCallback(\n  // \t(\n  // \t\tparams: GetManagementRoutineInstanceDetailedParams,\n  // \t\tsignal?: AbortSignal\n  // \t) => {\n  // \t\treturn fetchService.get<GetManagementRoutineInstanceDetailed>(\n  // \t\t\t`/v1/ManagementRoutines/${params.managementRoutineId}/instances/${params.instanceId\n  // \t\t\t}?sensorGroupIds=${params.sensorGroupId ?? ''}`,\n  // \t\t\t{\n  // \t\t\t\tsignal,\n  // \t\t\t}\n  // \t\t);\n  // \t},\n  // \t[fetchService]\n  // );\n\n  const getModels = useCallback(\n    (params: GetModelsRequestProps, signal?: AbortSignal) => {\n      return fetchService.post<GetModelsRequestProps>(`/api/models`, {\n        body: { key: params.key },\n        headers: {\n          'Content-Type': 'application/json',\n        },\n        signal,\n      });\n    },\n    [fetchService],\n  );\n\n  return {\n    getModels,\n  };\n};\n\nexport default useApiService;\n"
  },
  {
    "path": "ui/styles/globals.css",
    "content": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n::-webkit-scrollbar-track {\n  background-color: transparent;\n}\n\n::-webkit-scrollbar-thumb {\n  background-color: #ccc;\n  border-radius: 10px;\n}\n\n::-webkit-scrollbar-thumb:hover {\n  background-color: #aaa;\n}\n\n::-webkit-scrollbar-track:hover {\n  background-color: #f2f2f2;\n}\n\n::-webkit-scrollbar-corner {\n  background-color: transparent;\n}\n\n::-webkit-scrollbar {\n  width: 6px;\n  height: 6px;\n}\n\nhtml {\n  background: #202123;\n}\n\n@media (max-width: 720px) {\n  pre {\n    width: calc(100vw - 110px);\n  }\n}\n\npre:has(div.codeblock) {\n  padding: 0;\n}\n"
  },
  {
    "path": "ui/tailwind.config.js",
    "content": "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  content: [\n    './app/**/*.{js,ts,jsx,tsx}',\n    './pages/**/*.{js,ts,jsx,tsx}',\n    './components/**/*.{js,ts,jsx,tsx}',\n  ],\n  darkMode: 'class',\n  theme: {\n    extend: {},\n  },\n  variants: {\n    extend: {\n      visibility: ['group-hover'],\n    },\n  },\n  plugins: [require('@tailwindcss/typography')],\n};\n"
  },
  {
    "path": "ui/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"es5\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"allowJs\": true,\n    \"skipLibCheck\": true,\n    \"strict\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"noEmit\": true,\n    \"esModuleInterop\": true,\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"jsx\": \"preserve\",\n    \"incremental\": true,\n    \"types\": [\"vitest/globals\"],\n    \"paths\": {\n      \"@/*\": [\"./*\"]\n    }\n  },\n  \"include\": [\"next-env.d.ts\", \"**/*.ts\", \"**/*.tsx\"],\n  \"exclude\": [\"node_modules\"]\n}\n"
  },
  {
    "path": "ui/types/chat.ts",
    "content": "import { OpenAIModel } from './openai';\n\nexport interface Message {\n  role: Role;\n  content: string;\n}\n\nexport type Role = 'assistant' | 'user';\n\nexport interface ChatBody {\n  model: OpenAIModel;\n  messages: Message[];\n  key: string;\n  prompt: string;\n  temperature: number;\n}\n\nexport interface Conversation {\n  id: string;\n  name: string;\n  messages: Message[];\n  model: OpenAIModel;\n  prompt: string;\n  temperature: number;\n  folderId: string | null;\n}\n"
  },
  {
    "path": "ui/types/data.ts",
    "content": "export interface KeyValuePair {\n  key: string;\n  value: any;\n}\n"
  },
  {
    "path": "ui/types/env.ts",
    "content": "export interface ProcessEnv {\n  OPENAI_API_KEY: string;\n  OPENAI_API_HOST?: string;\n  OPENAI_API_TYPE?: 'openai' | 'azure';\n  OPENAI_API_VERSION?: string;\n  OPENAI_ORGANIZATION?: string;\n}\n"
  },
  {
    "path": "ui/types/error.ts",
    "content": "export interface ErrorMessage {\n  code: String | null;\n  title: String;\n  messageLines: String[];\n}\n"
  },
  {
    "path": "ui/types/export.ts",
    "content": "import { Conversation, Message } from './chat';\nimport { FolderInterface } from './folder';\nimport { OpenAIModel } from './openai';\nimport { Prompt } from './prompt';\n\nexport type SupportedExportFormats =\n  | ExportFormatV1\n  | ExportFormatV2\n  | ExportFormatV3\n  | ExportFormatV4;\nexport type LatestExportFormat = ExportFormatV4;\n\n////////////////////////////////////////////////////////////////////////////////////////////\ninterface ConversationV1 {\n  id: number;\n  name: string;\n  messages: Message[];\n}\n\nexport type ExportFormatV1 = ConversationV1[];\n\n////////////////////////////////////////////////////////////////////////////////////////////\ninterface ChatFolder {\n  id: number;\n  name: string;\n}\n\nexport interface ExportFormatV2 {\n  history: Conversation[] | null;\n  folders: ChatFolder[] | null;\n}\n\n////////////////////////////////////////////////////////////////////////////////////////////\nexport interface ExportFormatV3 {\n  version: 3;\n  history: Conversation[];\n  folders: FolderInterface[];\n}\n\nexport interface ExportFormatV4 {\n  version: 4;\n  history: Conversation[];\n  folders: FolderInterface[];\n  prompts: Prompt[];\n}\n"
  },
  {
    "path": "ui/types/folder.ts",
    "content": "export interface FolderInterface {\n  id: string;\n  name: string;\n  type: FolderType;\n}\n\nexport type FolderType = 'chat' | 'prompt';\n"
  },
  {
    "path": "ui/types/google.ts",
    "content": "import { ChatBody, Message } from './chat';\n\nexport interface GoogleBody extends ChatBody {\n  googleAPIKey: string;\n  googleCSEId: string;\n}\n\nexport interface GoogleResponse {\n  message: Message;\n}\n\nexport interface GoogleSource {\n  title: string;\n  link: string;\n  displayLink: string;\n  snippet: string;\n  image: string;\n  text: string;\n}\n"
  },
  {
    "path": "ui/types/index.ts",
    "content": "export {};\n"
  },
  {
    "path": "ui/types/openai.ts",
    "content": "import { OPENAI_API_TYPE } from '../utils/app/const';\n\nexport interface OpenAIModel {\n  id: string;\n  name: string;\n  maxLength: number; // maximum length of a message\n  tokenLimit: number;\n}\n\nexport enum OpenAIModelID {\n  GPT_3_5 = 'gpt-3.5-turbo',\n  GPT_3_5_AZ = 'gpt-35-turbo',\n  GPT_4 = 'gpt-4',\n  GPT_4_32K = 'gpt-4-32k',\n\n  LLAMA_7B_CHAT_GGMLV3_Q4_0 = '/models/llama-2-7b-chat.bin',\n  LLAMA_13B_CHAT_GGMLV3_Q4_0 = '/models/llama-2-13b-chat.bin',\n  LLAMA_70B_CHAT_GGMLV3_Q4_0 = '/models/llama-2-70b-chat.bin',\n  \n  LLAMA_7B_CHAT_GGMLV3_Q4_0_MAC = './models/llama-2-7b-chat.bin',\n  LLAMA_13B_CHAT_GGMLV3_Q4_0_MAC = './models/llama-2-13b-chat.bin',\n  LLAMA_70B_CHAT_GGMLV3_Q4_0_MAC = './models/llama-2-70b-chat.bin',\n  \n  CODE_LLAMA_7B_CHAT_GGUF_Q4_K_M = '/models/code-llama-7b-chat.gguf',\n  CODE_LLAMA_13B_CHAT_GGUF_Q4_K_M = '/models/code-llama-13b-chat.gguf',\n  CODE_LLAMA_34B_CHAT_GGUF_Q4_K_M = '/models/code-llama-34b-chat.gguf',\n  \n  CODE_LLAMA_7B_CHAT_GGUF_Q4_K_M_MAC = './models/code-llama-7b-chat.gguf',\n  CODE_LLAMA_13B_CHAT_GGUF_Q4_K_M_MAC = './models/code-llama-13b-chat.gguf',\n  CODE_LLAMA_34B_CHAT_GGUF_Q4_K_M_MAC = './models/code-llama-34b-chat.gguf',\n}\n\n// in case the `DEFAULT_MODEL` environment variable is not set or set to an unsupported model\nexport const fallbackModelID = OpenAIModelID.LLAMA_7B_CHAT_GGMLV3_Q4_0;\n\nexport const OpenAIModels: Record<OpenAIModelID, OpenAIModel> = {\n  [OpenAIModelID.GPT_3_5]: {\n    id: OpenAIModelID.GPT_3_5,\n    name: 'GPT-3.5',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.GPT_3_5_AZ]: {\n    id: OpenAIModelID.GPT_3_5_AZ,\n    name: 'GPT-3.5',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.GPT_4]: {\n    id: OpenAIModelID.GPT_4,\n    name: 'GPT-4',\n    maxLength: 24000,\n    tokenLimit: 8000,\n  },\n  [OpenAIModelID.GPT_4_32K]: {\n    id: OpenAIModelID.GPT_4_32K,\n    name: 'GPT-4-32K',\n    maxLength: 96000,\n    tokenLimit: 32000,\n  },\n  [OpenAIModelID.LLAMA_7B_CHAT_GGMLV3_Q4_0]: {\n    id: OpenAIModelID.LLAMA_7B_CHAT_GGMLV3_Q4_0,\n    name: 'Llama 2 7B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.LLAMA_13B_CHAT_GGMLV3_Q4_0]: {\n    id: OpenAIModelID.LLAMA_13B_CHAT_GGMLV3_Q4_0,\n    name: 'Llama 2 13B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.LLAMA_70B_CHAT_GGMLV3_Q4_0]: {\n    id: OpenAIModelID.LLAMA_70B_CHAT_GGMLV3_Q4_0,\n    name: 'Llama 2 70B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.LLAMA_7B_CHAT_GGMLV3_Q4_0_MAC]: {\n    id: OpenAIModelID.LLAMA_7B_CHAT_GGMLV3_Q4_0_MAC,\n    name: 'Llama 2 7B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.LLAMA_13B_CHAT_GGMLV3_Q4_0_MAC]: {\n    id: OpenAIModelID.LLAMA_13B_CHAT_GGMLV3_Q4_0_MAC,\n    name: 'Llama 2 13B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.LLAMA_70B_CHAT_GGMLV3_Q4_0_MAC]: {\n    id: OpenAIModelID.LLAMA_70B_CHAT_GGMLV3_Q4_0_MAC,\n    name: 'Llama 2 70B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.CODE_LLAMA_7B_CHAT_GGUF_Q4_K_M]: {\n    id: OpenAIModelID.CODE_LLAMA_7B_CHAT_GGUF_Q4_K_M_MAC,\n    name: 'Code Llama 7B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.CODE_LLAMA_13B_CHAT_GGUF_Q4_K_M]: {\n    id: OpenAIModelID.CODE_LLAMA_13B_CHAT_GGUF_Q4_K_M_MAC,\n    name: 'Code Llama 13B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.CODE_LLAMA_34B_CHAT_GGUF_Q4_K_M]: {\n    id: OpenAIModelID.CODE_LLAMA_34B_CHAT_GGUF_Q4_K_M_MAC,\n    name: 'Code Llama 34B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.CODE_LLAMA_7B_CHAT_GGUF_Q4_K_M_MAC]: {\n    id: OpenAIModelID.CODE_LLAMA_7B_CHAT_GGUF_Q4_K_M_MAC,\n    name: 'Code Llama 7B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.CODE_LLAMA_13B_CHAT_GGUF_Q4_K_M_MAC]: {\n    id: OpenAIModelID.CODE_LLAMA_13B_CHAT_GGUF_Q4_K_M_MAC,\n    name: 'Code Llama 13B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n  [OpenAIModelID.CODE_LLAMA_34B_CHAT_GGUF_Q4_K_M_MAC]: {\n    id: OpenAIModelID.CODE_LLAMA_34B_CHAT_GGUF_Q4_K_M_MAC,\n    name: 'Code Llama 34B',\n    maxLength: 12000,\n    tokenLimit: 4000,\n  },\n};\n"
  },
  {
    "path": "ui/types/plugin.ts",
    "content": "import { KeyValuePair } from './data';\n\nexport interface Plugin {\n  id: PluginID;\n  name: PluginName;\n  requiredKeys: KeyValuePair[];\n}\n\nexport interface PluginKey {\n  pluginId: PluginID;\n  requiredKeys: KeyValuePair[];\n}\n\nexport enum PluginID {\n  GOOGLE_SEARCH = 'google-search',\n}\n\nexport enum PluginName {\n  GOOGLE_SEARCH = 'Google Search',\n}\n\nexport const Plugins: Record<PluginID, Plugin> = {\n  [PluginID.GOOGLE_SEARCH]: {\n    id: PluginID.GOOGLE_SEARCH,\n    name: PluginName.GOOGLE_SEARCH,\n    requiredKeys: [\n      {\n        key: 'GOOGLE_API_KEY',\n        value: '',\n      },\n      {\n        key: 'GOOGLE_CSE_ID',\n        value: '',\n      },\n    ],\n  },\n};\n\nexport const PluginList = Object.values(Plugins);\n"
  },
  {
    "path": "ui/types/prompt.ts",
    "content": "import { OpenAIModel } from './openai';\n\nexport interface Prompt {\n  id: string;\n  name: string;\n  description: string;\n  content: string;\n  model: OpenAIModel;\n  folderId: string | null;\n}\n"
  },
  {
    "path": "ui/types/settings.ts",
    "content": "export interface Settings {\n  theme: 'light' | 'dark';\n}\n"
  },
  {
    "path": "ui/types/storage.ts",
    "content": "import { Conversation } from './chat';\nimport { FolderInterface } from './folder';\nimport { PluginKey } from './plugin';\nimport { Prompt } from './prompt';\n\n// keep track of local storage schema\nexport interface LocalStorage {\n  apiKey: string;\n  conversationHistory: Conversation[];\n  selectedConversation: Conversation;\n  theme: 'light' | 'dark';\n  // added folders (3/23/23)\n  folders: FolderInterface[];\n  // added prompts (3/26/23)\n  prompts: Prompt[];\n  // added showChatbar and showPromptbar (3/26/23)\n  showChatbar: boolean;\n  showPromptbar: boolean;\n  // added plugin keys (4/3/23)\n  pluginKeys: PluginKey[];\n}\n"
  },
  {
    "path": "ui/utils/app/api.ts",
    "content": "import { Plugin, PluginID } from '@/types/plugin';\n\nexport const getEndpoint = (plugin: Plugin | null) => {\n  if (!plugin) {\n    return 'api/chat';\n  }\n\n  if (plugin.id === PluginID.GOOGLE_SEARCH) {\n    return 'api/google';\n  }\n\n  return 'api/chat';\n};\n"
  },
  {
    "path": "ui/utils/app/clean.ts",
    "content": "import { Conversation } from '@/types/chat';\nimport { OpenAIModelID, OpenAIModels } from '@/types/openai';\n\nimport { DEFAULT_SYSTEM_PROMPT, DEFAULT_TEMPERATURE } from './const';\n\nexport const cleanSelectedConversation = (conversation: Conversation) => {\n  // added model for each conversation (3/20/23)\n  // added system prompt for each conversation (3/21/23)\n  // added folders (3/23/23)\n  // added prompts (3/26/23)\n  // added messages (4/16/23)\n\n  let updatedConversation = conversation;\n\n  // check for model on each conversation\n  if (!updatedConversation.model) {\n    updatedConversation = {\n      ...updatedConversation,\n      model: updatedConversation.model || OpenAIModels[OpenAIModelID.GPT_3_5],\n    };\n  }\n\n  // check for system prompt on each conversation\n  if (!updatedConversation.prompt) {\n    updatedConversation = {\n      ...updatedConversation,\n      prompt: updatedConversation.prompt || DEFAULT_SYSTEM_PROMPT,\n    };\n  }\n\n  if (!updatedConversation.temperature) {\n    updatedConversation = {\n      ...updatedConversation,\n      temperature: updatedConversation.temperature || DEFAULT_TEMPERATURE,\n    };\n  }\n\n  if (!updatedConversation.folderId) {\n    updatedConversation = {\n      ...updatedConversation,\n      folderId: updatedConversation.folderId || null,\n    };\n  }\n\n  if (!updatedConversation.messages) {\n    updatedConversation = {\n      ...updatedConversation,\n      messages: updatedConversation.messages || [],\n    };\n  }\n\n  return updatedConversation;\n};\n\nexport const cleanConversationHistory = (history: any[]): Conversation[] => {\n  // added model for each conversation (3/20/23)\n  // added system prompt for each conversation (3/21/23)\n  // added folders (3/23/23)\n  // added prompts (3/26/23)\n  // added messages (4/16/23)\n\n  if (!Array.isArray(history)) {\n    console.warn('history is not an array. Returning an empty array.');\n    return [];\n  }\n\n  return history.reduce((acc: any[], conversation) => {\n    try {\n      if (!conversation.model) {\n        conversation.model = OpenAIModels[OpenAIModelID.GPT_3_5];\n      }\n\n      if (!conversation.prompt) {\n        conversation.prompt = DEFAULT_SYSTEM_PROMPT;\n      }\n\n      if (!conversation.temperature) {\n        conversation.temperature = DEFAULT_TEMPERATURE;\n      }\n\n      if (!conversation.folderId) {\n        conversation.folderId = null;\n      }\n\n      if (!conversation.messages) {\n        conversation.messages = [];\n      }\n\n      acc.push(conversation);\n      return acc;\n    } catch (error) {\n      console.warn(\n        `error while cleaning conversations' history. Removing culprit`,\n        error,\n      );\n    }\n    return acc;\n  }, []);\n};\n"
  },
  {
    "path": "ui/utils/app/codeblock.ts",
    "content": "interface languageMap {\n  [key: string]: string | undefined;\n}\n\nexport const programmingLanguages: languageMap = {\n  javascript: '.js',\n  python: '.py',\n  java: '.java',\n  c: '.c',\n  cpp: '.cpp',\n  'c++': '.cpp',\n  'c#': '.cs',\n  ruby: '.rb',\n  php: '.php',\n  swift: '.swift',\n  'objective-c': '.m',\n  kotlin: '.kt',\n  typescript: '.ts',\n  go: '.go',\n  perl: '.pl',\n  rust: '.rs',\n  scala: '.scala',\n  haskell: '.hs',\n  lua: '.lua',\n  shell: '.sh',\n  sql: '.sql',\n  html: '.html',\n  css: '.css',\n  // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component\n};\n\nexport const generateRandomString = (length: number, lowercase = false) => {\n  const chars = 'ABCDEFGHJKLMNPQRSTUVWXY3456789'; // excluding similar looking characters like Z, 2, I, 1, O, 0\n  let result = '';\n  for (let i = 0; i < length; i++) {\n    result += chars.charAt(Math.floor(Math.random() * chars.length));\n  }\n  return lowercase ? result.toLowerCase() : result;\n};\n"
  },
  {
    "path": "ui/utils/app/const.ts",
    "content": "export const DEFAULT_SYSTEM_PROMPT =\n  process.env.NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT ||\n  \"You are a helpful and friendly AI assistant. Respond very concisely.\"\n\nexport const OPENAI_API_HOST =\n  process.env.OPENAI_API_HOST || 'https://api.openai.com';\n\nexport const DEFAULT_TEMPERATURE = \n  parseFloat(process.env.NEXT_PUBLIC_DEFAULT_TEMPERATURE || \"1\");\n\nexport const OPENAI_API_TYPE =\n  process.env.OPENAI_API_TYPE || 'openai';\n\nexport const OPENAI_API_VERSION =\n  process.env.OPENAI_API_VERSION || '2023-03-15-preview';\n\nexport const OPENAI_ORGANIZATION =\n  process.env.OPENAI_ORGANIZATION || '';\n\nexport const AZURE_DEPLOYMENT_ID =\n  process.env.AZURE_DEPLOYMENT_ID || '';\n"
  },
  {
    "path": "ui/utils/app/conversation.ts",
    "content": "import { Conversation } from '@/types/chat';\n\nexport const updateConversation = (\n  updatedConversation: Conversation,\n  allConversations: Conversation[],\n) => {\n  const updatedConversations = allConversations.map((c) => {\n    if (c.id === updatedConversation.id) {\n      return updatedConversation;\n    }\n\n    return c;\n  });\n\n  saveConversation(updatedConversation);\n  saveConversations(updatedConversations);\n\n  return {\n    single: updatedConversation,\n    all: updatedConversations,\n  };\n};\n\nexport const saveConversation = (conversation: Conversation) => {\n  localStorage.setItem('selectedConversation', JSON.stringify(conversation));\n};\n\nexport const saveConversations = (conversations: Conversation[]) => {\n  localStorage.setItem('conversationHistory', JSON.stringify(conversations));\n};\n"
  },
  {
    "path": "ui/utils/app/folders.ts",
    "content": "import { FolderInterface } from '@/types/folder';\n\nexport const saveFolders = (folders: FolderInterface[]) => {\n  localStorage.setItem('folders', JSON.stringify(folders));\n};\n"
  },
  {
    "path": "ui/utils/app/importExport.ts",
    "content": "import { Conversation } from '@/types/chat';\nimport {\n  ExportFormatV1,\n  ExportFormatV2,\n  ExportFormatV3,\n  ExportFormatV4,\n  LatestExportFormat,\n  SupportedExportFormats,\n} from '@/types/export';\nimport { FolderInterface } from '@/types/folder';\nimport { Prompt } from '@/types/prompt';\n\nimport { cleanConversationHistory } from './clean';\n\nexport function isExportFormatV1(obj: any): obj is ExportFormatV1 {\n  return Array.isArray(obj);\n}\n\nexport function isExportFormatV2(obj: any): obj is ExportFormatV2 {\n  return !('version' in obj) && 'folders' in obj && 'history' in obj;\n}\n\nexport function isExportFormatV3(obj: any): obj is ExportFormatV3 {\n  return obj.version === 3;\n}\n\nexport function isExportFormatV4(obj: any): obj is ExportFormatV4 {\n  return obj.version === 4;\n}\n\nexport const isLatestExportFormat = isExportFormatV4;\n\nexport function cleanData(data: SupportedExportFormats): LatestExportFormat {\n  if (isExportFormatV1(data)) {\n    return {\n      version: 4,\n      history: cleanConversationHistory(data),\n      folders: [],\n      prompts: [],\n    };\n  }\n\n  if (isExportFormatV2(data)) {\n    return {\n      version: 4,\n      history: cleanConversationHistory(data.history || []),\n      folders: (data.folders || []).map((chatFolder) => ({\n        id: chatFolder.id.toString(),\n        name: chatFolder.name,\n        type: 'chat',\n      })),\n      prompts: [],\n    };\n  }\n\n  if (isExportFormatV3(data)) {\n    return { ...data, version: 4, prompts: [] };\n  }\n\n  if (isExportFormatV4(data)) {\n    return data;\n  }\n\n  throw new Error('Unsupported data format');\n}\n\nfunction currentDate() {\n  const date = new Date();\n  const month = date.getMonth() + 1;\n  const day = date.getDate();\n  return `${month}-${day}`;\n}\n\nexport const exportData = () => {\n  let history = localStorage.getItem('conversationHistory');\n  let folders = localStorage.getItem('folders');\n  let prompts = localStorage.getItem('prompts');\n\n  if (history) {\n    history = JSON.parse(history);\n  }\n\n  if (folders) {\n    folders = JSON.parse(folders);\n  }\n\n  if (prompts) {\n    prompts = JSON.parse(prompts);\n  }\n\n  const data = {\n    version: 4,\n    history: history || [],\n    folders: folders || [],\n    prompts: prompts || [],\n  } as LatestExportFormat;\n\n  const blob = new Blob([JSON.stringify(data, null, 2)], {\n    type: 'application/json',\n  });\n  const url = URL.createObjectURL(blob);\n  const link = document.createElement('a');\n  link.download = `chatbot_ui_history_${currentDate()}.json`;\n  link.href = url;\n  link.style.display = 'none';\n  document.body.appendChild(link);\n  link.click();\n  document.body.removeChild(link);\n  URL.revokeObjectURL(url);\n};\n\nexport const importData = (\n  data: SupportedExportFormats,\n): LatestExportFormat => {\n  const { history, folders, prompts } = cleanData(data);\n\n  const oldConversations = localStorage.getItem('conversationHistory');\n  const oldConversationsParsed = oldConversations\n    ? JSON.parse(oldConversations)\n    : [];\n\n  const newHistory: Conversation[] = [\n    ...oldConversationsParsed,\n    ...history,\n  ].filter(\n    (conversation, index, self) =>\n      index === self.findIndex((c) => c.id === conversation.id),\n  );\n  localStorage.setItem('conversationHistory', JSON.stringify(newHistory));\n  if (newHistory.length > 0) {\n    localStorage.setItem(\n      'selectedConversation',\n      JSON.stringify(newHistory[newHistory.length - 1]),\n    );\n  } else {\n    localStorage.removeItem('selectedConversation');\n  }\n\n  const oldFolders = localStorage.getItem('folders');\n  const oldFoldersParsed = oldFolders ? JSON.parse(oldFolders) : [];\n  const newFolders: FolderInterface[] = [\n    ...oldFoldersParsed,\n    ...folders,\n  ].filter(\n    (folder, index, self) =>\n      index === self.findIndex((f) => f.id === folder.id),\n  );\n  localStorage.setItem('folders', JSON.stringify(newFolders));\n\n  const oldPrompts = localStorage.getItem('prompts');\n  const oldPromptsParsed = oldPrompts ? JSON.parse(oldPrompts) : [];\n  const newPrompts: Prompt[] = [...oldPromptsParsed, ...prompts].filter(\n    (prompt, index, self) =>\n      index === self.findIndex((p) => p.id === prompt.id),\n  );\n  localStorage.setItem('prompts', JSON.stringify(newPrompts));\n\n  return {\n    version: 4,\n    history: newHistory,\n    folders: newFolders,\n    prompts: newPrompts,\n  };\n};\n"
  },
  {
    "path": "ui/utils/app/prompts.ts",
    "content": "import { Prompt } from '@/types/prompt';\n\nexport const updatePrompt = (updatedPrompt: Prompt, allPrompts: Prompt[]) => {\n  const updatedPrompts = allPrompts.map((c) => {\n    if (c.id === updatedPrompt.id) {\n      return updatedPrompt;\n    }\n\n    return c;\n  });\n\n  savePrompts(updatedPrompts);\n\n  return {\n    single: updatedPrompt,\n    all: updatedPrompts,\n  };\n};\n\nexport const savePrompts = (prompts: Prompt[]) => {\n  localStorage.setItem('prompts', JSON.stringify(prompts));\n};\n"
  },
  {
    "path": "ui/utils/app/settings.ts",
    "content": "import { Settings } from '@/types/settings';\n\nconst STORAGE_KEY = 'settings';\n\nexport const getSettings = (): Settings => {\n  let settings: Settings = {\n    theme: 'dark',\n  };\n  const settingsJson = localStorage.getItem(STORAGE_KEY);\n  if (settingsJson) {\n    try {\n      let savedSettings = JSON.parse(settingsJson) as Settings;\n      settings = Object.assign(settings, savedSettings);\n    } catch (e) {\n      console.error(e);\n    }\n  }\n  return settings;\n};\n\nexport const saveSettings = (settings: Settings) => {\n  localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));\n};\n"
  },
  {
    "path": "ui/utils/data/throttle.ts",
    "content": "export function throttle<T extends (...args: any[]) => any>(\n  func: T,\n  limit: number,\n): T {\n  let lastFunc: ReturnType<typeof setTimeout>;\n  let lastRan: number;\n\n  return ((...args) => {\n    if (!lastRan) {\n      func(...args);\n      lastRan = Date.now();\n    } else {\n      clearTimeout(lastFunc);\n      lastFunc = setTimeout(() => {\n        if (Date.now() - lastRan >= limit) {\n          func(...args);\n          lastRan = Date.now();\n        }\n      }, limit - (Date.now() - lastRan));\n    }\n  }) as T;\n}\n"
  },
  {
    "path": "ui/utils/server/google.ts",
    "content": "export const cleanSourceText = (text: string) => {\n  return text\n    .trim()\n    .replace(/(\\n){4,}/g, '\\n\\n\\n')\n    .replace(/\\n\\n/g, ' ')\n    .replace(/ {3,}/g, '  ')\n    .replace(/\\t/g, '')\n    .replace(/\\n+(\\s*\\n)*/g, '\\n');\n};\n"
  },
  {
    "path": "ui/utils/server/index.ts",
    "content": "import { Message } from '@/types/chat';\nimport { OpenAIModel } from '@/types/openai';\n\nimport { AZURE_DEPLOYMENT_ID, OPENAI_API_HOST, OPENAI_API_TYPE, OPENAI_API_VERSION, OPENAI_ORGANIZATION } from '../app/const';\n\nimport {\n  ParsedEvent,\n  ReconnectInterval,\n  createParser,\n} from 'eventsource-parser';\n\nexport class OpenAIError extends Error {\n  type: string;\n  param: string;\n  code: string;\n\n  constructor(message: string, type: string, param: string, code: string) {\n    super(message);\n    this.name = 'OpenAIError';\n    this.type = type;\n    this.param = param;\n    this.code = code;\n  }\n}\n\nexport const OpenAIStream = async (\n  model: OpenAIModel,\n  systemPrompt: string,\n  temperature : number,\n  key: string,\n  messages: Message[],\n) => {\n  let url = `${OPENAI_API_HOST}/v1/chat/completions`;\n  if (OPENAI_API_TYPE === 'azure') {\n    url = `${OPENAI_API_HOST}/openai/deployments/${AZURE_DEPLOYMENT_ID}/chat/completions?api-version=${OPENAI_API_VERSION}`;\n  }\n  const res = await fetch(url, {\n    headers: {\n      'Content-Type': 'application/json',\n      ...(OPENAI_API_TYPE === 'openai' && {\n        Authorization: `Bearer ${key ? key : process.env.OPENAI_API_KEY}`\n      }),\n      ...(OPENAI_API_TYPE === 'azure' && {\n        'api-key': `${key ? key : process.env.OPENAI_API_KEY}`\n      }),\n      ...((OPENAI_API_TYPE === 'openai' && OPENAI_ORGANIZATION) && {\n        'OpenAI-Organization': OPENAI_ORGANIZATION,\n      }),\n    },\n    method: 'POST',\n    body: JSON.stringify({\n      ...(OPENAI_API_TYPE === 'openai' && {model: model.id}),\n      messages: [\n        {\n          role: 'system',\n          content: systemPrompt,\n        },\n        ...messages,\n      ],\n      max_tokens: 1000,\n      temperature: temperature,\n      stream: true,\n    }),\n  });\n\n  const encoder = new TextEncoder();\n  const decoder = new TextDecoder();\n\n  if (res.status !== 200) {\n    const result = await res.json();\n    if (result.error) {\n      throw new OpenAIError(\n        result.error.message,\n        result.error.type,\n        result.error.param,\n        result.error.code,\n      );\n    } else {\n      throw new Error(\n        `OpenAI API returned an error: ${\n          decoder.decode(result?.value) || result.statusText\n        }`,\n      );\n    }\n  }\n\n  const stream = new ReadableStream({\n    async start(controller) {\n      const onParse = (event: ParsedEvent | ReconnectInterval) => {\n        if (event.type === 'event') {\n          const data = event.data;\n\n          try {\n            const json = JSON.parse(data);\n            if (json.choices[0].finish_reason != null) {\n              controller.close();\n              return;\n            }\n            const text = json.choices[0].delta.content;\n            const queue = encoder.encode(text);\n            controller.enqueue(queue);\n          } catch (e) {\n            controller.error(e);\n          }\n        }\n      };\n\n      const parser = createParser(onParse);\n\n      for await (const chunk of res.body as any) {\n        parser.feed(decoder.decode(chunk));\n      }\n    },\n  });\n\n  return stream;\n};\n"
  },
  {
    "path": "ui/vitest.config.ts",
    "content": "import path from 'path';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  resolve: {\n    alias: {\n      '@': path.resolve(__dirname, './'),\n    },\n  },\n});\n"
  }
]