├── .gitignore ├── .gitmodules ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── MANIFEST.in ├── README.md ├── assets └── logo.png ├── configs ├── .gitignore └── config.yaml ├── docker-compose.yaml ├── docs ├── LLMBinding_doc.md ├── Lollms-server.md ├── index.html └── server_endpoints.md ├── elf_docker_cfg ├── config_paths.yaml └── personal │ └── configs │ └── lollms_elf_config.yaml ├── elf_test_cfg ├── config_paths.yaml └── personal │ └── configs │ ├── lollms_elf_config.yaml │ └── lollms_elf_local_config.yaml ├── installer └── installer.bat ├── lollms ├── .gitignore ├── __init__.py ├── app.py ├── assets │ ├── logo.png │ └── logo_old.png ├── binding.py ├── client_session.py ├── code_modifier.py ├── code_parser.py ├── com.py ├── config.py ├── configs │ ├── .gitignore │ └── config.yaml ├── data.py ├── databases │ ├── discussions_database.py │ ├── models_database.py │ ├── remote_databases │ │ ├── __init__.py │ │ ├── light_rag_database.py │ │ └── lollms_database.py │ └── skills_database.py ├── function_call.py ├── functions │ ├── __init__.py │ ├── analyze_code │ │ ├── __init__.py │ │ ├── add_code_to_file.py │ │ ├── add_function_to_file.py │ │ ├── create_project_database.py │ │ ├── git_commit.py │ │ ├── git_pull.py │ │ ├── list_classes.py │ │ ├── list_files.py │ │ ├── retreive_information_for_task.py │ │ ├── retrieve_classes_from_project.py │ │ ├── search_class_in_project.py │ │ ├── update_class_in_file.py │ │ └── update_function_in_file.py │ ├── bibliography.py │ ├── calculator.py │ ├── file_manipulation.py │ ├── generate_music.py │ ├── image_management │ │ └── draw_bounding_boxes.py │ ├── knowledge │ │ └── build_knowledge_db.py │ ├── list_personalities.py │ ├── luma_ai_dream_machine │ │ ├── build_video_using_luma_ai.py │ │ ├── input_section_image.png │ │ ├── sign_in.png │ │ └── try_now.png │ ├── markdown2latex.py │ ├── memes │ │ └── memes_builder.py │ ├── music_gen.py │ ├── peripherals.py │ ├── prompting │ │ ├── image_gen_prompts.py │ │ └── system_prompts.py │ ├── roll_a_dice.py │ ├── runway_ml_gen_2 │ │ ├── build_video_using_luma_ai.py │ │ └── try_gen2.png │ ├── search.py │ ├── select_image_file.py │ ├── story_writing.py │ ├── summary.py │ ├── summon_personality.py │ ├── take_a_photo.py │ ├── take_screen_shot.py │ ├── timers.py │ ├── tts │ │ ├── __init__.py │ │ ├── read_text.py │ │ └── read_text_from_file.py │ ├── web │ │ ├── __init__.py │ │ └── google_search.py │ ├── writing │ │ └── create_text_file.py │ └── youtube │ │ ├── __init__.py │ │ ├── download_transcript.py │ │ ├── download_transcript_by_channel.py │ │ ├── search.py │ │ ├── search_and_show.py │ │ └── search_query.png ├── generation.py ├── helpers.py ├── image_gen_modules │ ├── blip_vqa.py │ └── clip_interrogator.py ├── internet.py ├── main_config.py ├── media.py ├── paths.py ├── personality.py ├── prompting.py ├── security.py ├── server │ ├── .gitignore │ ├── assets │ │ └── thinking_methods.yaml │ ├── configs │ │ ├── .gitignore │ │ └── config.yaml │ ├── elf.py │ ├── elf_server.py │ ├── endpoints │ │ ├── chat_bar.py │ │ ├── docs │ │ │ ├── lollms_anything_to_markdown │ │ │ │ ├── DOC.md │ │ │ │ └── README.md │ │ │ ├── lollms_client_js │ │ │ │ ├── DOC.md │ │ │ │ └── README.md │ │ │ ├── lollms_flow │ │ │ │ ├── DOC.md │ │ │ │ └── README.md │ │ │ ├── lollms_markdown_renderer │ │ │ │ ├── DOC.md │ │ │ │ └── README.md │ │ │ ├── lollms_theme │ │ │ │ └── doc.md │ │ │ ├── lollms_tti │ │ │ │ └── DOC.md │ │ │ ├── lollms_webscraper │ │ │ │ ├── DOC.md │ │ │ │ └── README.md │ │ │ ├── lollmsclient_py.md │ │ │ └── web.app.localizer │ │ │ │ ├── DOC.md │ │ │ │ └── README.md │ │ ├── libraries │ │ │ ├── axios.min.js │ │ │ ├── full.calendar.min.js │ │ │ ├── jszip.min.js │ │ │ ├── leaflet.js │ │ │ ├── lollms_anything_to_markdown.js │ │ │ ├── lollms_client_js.js │ │ │ ├── lollms_flow.js │ │ │ ├── lollms_markdown2PDF.js │ │ │ ├── lollms_markdown_renderer.js │ │ │ ├── lollms_tti.js │ │ │ ├── lollms_webscraper.js │ │ │ ├── marked.min.js │ │ │ ├── mermaid.min.js │ │ │ ├── tailwindcss.js │ │ │ └── web.app.localizer.js │ │ ├── lollms_advanced.py │ │ ├── lollms_apps.py │ │ ├── lollms_binding_infos.py │ │ ├── lollms_configuration_infos.py │ │ ├── lollms_discussion.py │ │ ├── lollms_file_system.py │ │ ├── lollms_files_server.py │ │ ├── lollms_function_calls.py │ │ ├── lollms_generator.py │ │ ├── lollms_hardware_infos.py │ │ ├── lollms_help.py │ │ ├── lollms_infos.py │ │ ├── lollms_message.py │ │ ├── lollms_models_infos.py │ │ ├── lollms_personalities_infos.py │ │ ├── lollms_playground.py │ │ ├── lollms_rag.py │ │ ├── lollms_skills_library.py │ │ ├── lollms_stt.py │ │ ├── lollms_thinking.py │ │ ├── lollms_tti.py │ │ ├── lollms_ttm.py │ │ ├── lollms_tts.py │ │ ├── lollms_ttv.py │ │ ├── lollms_uploads_infos.py │ │ ├── lollms_user.py │ │ ├── lollms_webui_infos.py │ │ ├── news │ │ │ ├── changelog.html │ │ │ ├── current.html │ │ │ └── latest_video.json │ │ └── styles │ │ │ ├── full.calendar.min.css │ │ │ ├── hilight.js.default.min.css │ │ │ ├── leaflet.css │ │ │ ├── lollms_markdown_renderer.css │ │ │ ├── lollms_styles.css │ │ │ └── tailwind.min.css │ └── events │ │ ├── lollms_files_events.py │ │ ├── lollms_generation_events.py │ │ ├── lollms_model_events.py │ │ ├── lollms_personality_events.py │ │ └── lollms_rag_events.py ├── service.py ├── stt.py ├── tasks.py ├── templating.py ├── terminal.py ├── tti.py ├── ttm.py ├── tts.py ├── ttv.py ├── types.py ├── utilities.py └── utilities │ └── outlook.py ├── notebooks ├── lollms_discord.ipynb └── lollms_service.ipynb ├── personal_data └── configs │ └── lollms_discord_local_config.yaml ├── requirements.txt ├── requirements_dev.txt ├── scripts ├── linux │ ├── linux_conda_session.sh │ ├── linux_install.sh │ ├── linux_lollms_server.sh │ ├── linux_lollms_settings.sh │ ├── linux_update.sh │ ├── linux_update_models.sh │ └── uninstall.sh ├── macos │ ├── macos_conda_session.sh │ ├── macos_install.sh │ ├── macos_lollms_server.sh │ ├── macos_lollms_settings.sh │ └── macos_update.sh ├── utilities │ └── text2csv.py └── windows │ ├── uninstall.bat │ ├── win_conda_session.bat │ ├── win_install.bat │ ├── win_lollms_server.bat │ ├── win_lollms_settings.bat │ ├── win_update.bat │ └── win_update_models.bat ├── setup.py ├── tests └── endoints_unit_tests │ ├── components_test │ └── whisper_test.py │ ├── cpp │ ├── makefile │ └── test_generation.cpp │ ├── node │ ├── README.md │ └── test_generation.html │ └── python │ ├── example_text_gen.txt │ └── test_generation.py └── train ├── .gitignore ├── configs ├── deepspeed │ └── ds_config.yaml └── train │ ├── finetune.yaml │ ├── finetune_lora.yaml │ └── finetune_lora_ airoboros-7b-gpt4.yaml ├── requirements.txt └── train.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | 162 | # Custom stuff 163 | .installed 164 | 165 | shared/* 166 | *.ckpt 167 | *.safetensors 168 | 169 | models 170 | 171 | # rest tests 172 | *.http 173 | 174 | # shared resources 175 | shared 176 | src 177 | temp 178 | outputs 179 | 180 | # Global path configuration 181 | global_paths_cfg.yaml 182 | 183 | .vscode 184 | 185 | offload 186 | 187 | 188 | zoos/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/.gitmodules -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | 3 | Our chatbot is an inclusive community that values respect, collaboration, and innovation. We welcome contributors of all backgrounds and skill levels to join us in building a positive and productive community. To ensure that our community remains safe, respectful, and welcoming, we ask all contributors to abide by this code of conduct. 4 | 5 | ### 1. Respectful Communication 6 | 7 | We value open communication and encourage contributors to express themselves in a respectful and constructive manner. We do not tolerate discrimination, harassment, or abuse of any kind, including but not limited to: 8 | 9 | - Offensive comments related to gender, gender identity and expression, sexual orientation, disability, mental illness, race, ethnicity, age, nationality, religion, or physical appearance 10 | - Threats, intimidation, or bullying 11 | - Inappropriate sexual advances or imagery 12 | 13 | ### 2. Collaborative Development 14 | 15 | We encourage collaboration and teamwork among contributors and ask that everyone work together in a constructive and positive manner. We do not tolerate disruptive behavior, including but not limited to: 16 | 17 | - Spamming, trolling, or flaming 18 | - Hijacking discussions or derailing conversations 19 | - Refusal to consider alternative viewpoints or approaches 20 | 21 | ### 3. Innovative Contributions 22 | 23 | We welcome contributions of all kinds and encourage innovation and experimentation. However, we do not tolerate the use of our chatbot for any form of misinformation, including but not limited to: 24 | 25 | - The dissemination of false information, rumors, or hoaxes 26 | - The promotion of conspiracy theories or fake news 27 | - The use of our chatbot for malicious purposes, including but not limited to fraud, scams, or phishing 28 | 29 | ### 4. Consequences of Unacceptable Behavior 30 | 31 | We take all reports of unacceptable behavior seriously and will investigate all incidents promptly and thoroughly. We reserve the right to take any action deemed necessary, including but not limited to: 32 | 33 | - Warning the individual responsible for the unacceptable behavior 34 | - Temporarily or permanently revoking their access to the chatbot 35 | - Banning them from future participation in the community 36 | 37 | ### 5. Reporting Unacceptable Behavior 38 | 39 | If you experience or witness behavior that violates this code of conduct, please report it immediately to the chatbot administrator. All reports will be kept confidential and will be investigated promptly and thoroughly. 40 | 41 | ### 6. Acknowledgment of Code of Conduct 42 | 43 | By contributing to our chatbot, you acknowledge that you have read and agree to abide by this code of conduct. You also acknowledge that you have the responsibility to report any violations of this code of conduct. 44 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to lollms-webui 2 | 3 | Thank you for your interest in contributing to [Your Repository Name]! We appreciate your efforts to help make our project better. 4 | 5 | ## Contributing Guidelines 6 | 7 | Before you start contributing, please take a moment to review our guidelines: 8 | 9 | 1. Please do not include links directly to your own repositories or external websites. Instead, please use a code tag to display any code snippets or examples. 10 | 11 | 2. Please ensure that your contributions are well-documented and include comments where necessary. 12 | 13 | 3. Please follow our coding standards and best practices, as outlined in our [style guide](link-to-style-guide). 14 | 15 | 4. If you have any questions or need assistance, please feel free to reach out to the project maintainers. 16 | 17 | ## Submitting Contributions 18 | 19 | To submit a contribution, please follow these steps: 20 | 21 | 1. Fork the repository and create a new branch for your changes. 22 | 23 | 2. Make your changes and ensure that all tests pass. 24 | 25 | 3. Commit your changes and push them to your fork. 26 | 27 | 4. Submit a pull request to the main repository. 28 | 29 | 5. Wait for feedback from the project maintainers. 30 | 31 | Once your pull request is approved, your changes will be merged into the main repository. 32 | 33 | Thank you for your contributions to lollms-webui! 34 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Use an official Python runtime as a parent image 2 | #FROM ai_ticket 3 | ARG BASE_IMAGE 4 | FROM ${BASE_IMAGE} 5 | 6 | # Set the working directory to /app 7 | WORKDIR /app 8 | 9 | # Copy the current directory contents into the container at /app 10 | COPY requirements.txt /app/requirements.txt 11 | 12 | # Install any needed packages specified in requirements.txt 13 | RUN apt update 14 | RUN apt install -y git 15 | RUN pip install --trusted-host pypi.python.org -r requirements.txt 16 | 17 | 18 | COPY ./elf_docker_cfg /app/elf_docker_cfg 19 | COPY ./lollms /app/lollms 20 | COPY ./README.md /app/README.md 21 | COPY ./MANIFEST.in /app/MANIFEST.in 22 | COPY ./LICENSE /app/LICENSE 23 | COPY ./requirements_dev.txt /app/requirements_dev.txt 24 | COPY ./requirements.txt /app/requirements.txt 25 | COPY ./setup.py /app/setup.py 26 | COPY ./zoos /app/zoos 27 | COPY ./configs /app/configs 28 | RUN pip install -e . 29 | 30 | # Run app.py when the container launches 31 | CMD ["lollms-elf","--host","0.0.0.0", "--port", "9601", "--default_cfg_path", "/app/elf_docker_cfg/config_paths.yaml"] 32 | 33 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include lollms/configs * 2 | recursive-include lollms/apps/playground/dist * 3 | recursive-include lollms/apps/playground/public * 4 | recursive-include lollms/apps/playground/presets * 5 | global-exclude *.bin 6 | global-exclude *.bin 7 | global-exclude *.pyc 8 | global-exclude local_config.yaml 9 | global-exclude global_paths_cfg.yaml 10 | global-exclude .installed 11 | global-exclude .git 12 | global-exclude .gitignore -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/assets/logo.png -------------------------------------------------------------------------------- /configs/.gitignore: -------------------------------------------------------------------------------- 1 | local_config.yaml -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.10' 2 | services: 3 | lollms: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile 7 | args: 8 | - BASE_IMAGE=python:3.11 9 | ports: 10 | - 9601:9601 11 | volumes: 12 | - ./data:/app/data 13 | 14 | -------------------------------------------------------------------------------- /docs/LLMBinding_doc.md: -------------------------------------------------------------------------------- 1 | # LLMBinding 2 | 3 | The LLMBinding class is an interface class that serves as a template for implementing bindings with different large language models (LLMs) frameworks. It provides a set of methods that need to be implemented by specific bindings to enable interaction with LLMs. 4 | 5 | Here's a breakdown of the important components and methods in the LLMBinding class: 6 | 7 | 1. **Constructor (`__init__`):** 8 | - Parameters: 9 | - `binding_dir` (Path): The path to the binding directory. 10 | - `lollms_paths` (LollmsPaths): An instance of the LollmsPaths class that provides paths to different directories. 11 | - `config` (LOLLMSConfig): The global configuration object for LOLLMS. 12 | - `binding_config` (TypedConfig): The configuration object specific to the binding. 13 | - `installation_option` (InstallOption, optional): The installation option for the binding. Defaults to `InstallOption.INSTALL_IF_NECESSARY`. 14 | - `SAFE_STORE_SUPPORTED_FILE_EXTENSIONS` (str, optional): The file extension for models supported by the binding. Defaults to `"*.bin"`. 15 | - Description: The constructor initializes the LLMBinding object and sets up various properties based on the provided parameters. It also handles the installation of the binding if necessary. 16 | 17 | 2. **Installation Methods:** 18 | - `install()`: This method handles the installation procedure for the binding and should be implemented by each specific binding. It can perform tasks like downloading and installing the necessary dependencies or models. This method is called during object initialization if the binding is not already installed or if the installation is forced. 19 | 20 | 3. **Model Methods:** 21 | - `build_model()`: This method is responsible for constructing the model specific to the binding. It needs to be implemented by each binding and should return the constructed model object. 22 | - `get_model_path()`: This method retrieves the path of the model based on the configuration. It handles different scenarios, such as reading the model path from a file or constructing it based on the configuration. 23 | 24 | 4. **Text Generation Methods:** 25 | - `generate(prompt, n_predict, callback, verbose, **gpt_params)`: This method generates text based on the provided prompt using the LLM model. It should be implemented by each binding and handle the generation process specific to the underlying LLM framework. 26 | - `tokenize(prompt)`: This method tokenizes the given prompt using the model's tokenizer. It needs to be implemented to provide tokenization functionality. 27 | - `detokenize(tokens_list)`: This method detokenizes the given list of tokens using the model's tokenizer. It should be implemented to provide detokenization functionality. 28 | 29 | 5. **Utility Methods:** 30 | - `load_binding_config()`: This method loads the content of the binding's local configuration file. It reads the configuration data and syncs it with the binding_config object. 31 | - `save_config_file(path)`: This method saves the binding's configuration file to the specified path. 32 | - `list_models(config)`: This method lists the available models for the binding. It should return a list of model names that match the specified file extension. 33 | 34 | The LLMBinding class also includes a few other utility methods, such as `get_current_seed()` and `reinstall_pytorch_with_cuda()`, which provide additional functionality specific to the LOLLMS tool. 35 | 36 | To create a new binding for a different LLM framework, you need to subclass the LLMBinding class and implement the required methods based on the framework's API and functionality. Each method should be customized to work with the specific LLM framework you're integrating. 37 | 38 | Additionally, there are two builder classes, `BindingBuilder` and `ModelBuilder`, provided for convenience. These classes assist in building LLMBinding objects and LLM models, respectively. 39 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to LOLLMs documentation 5 | 6 | 7 |

Welcome to LOLLMs documentation

8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /elf_docker_cfg/config_paths.yaml: -------------------------------------------------------------------------------- 1 | lollms_path: /app/ 2 | lollms_personal_path: /app/elf_docker_cfg/personal -------------------------------------------------------------------------------- /elf_test_cfg/config_paths.yaml: -------------------------------------------------------------------------------- 1 | lollms_path: . 2 | lollms_personal_path: elf_test_cfg/personal -------------------------------------------------------------------------------- /installer/installer.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/installer/installer.bat -------------------------------------------------------------------------------- /lollms/.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | uploads -------------------------------------------------------------------------------- /lollms/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | __author__ = "ParisNeo" 4 | __github__ = "https://github.com/ParisNeo/lollms" 5 | __copyright__ = "Copyright 2023, " 6 | __license__ = "Apache 2.0" 7 | 8 | -------------------------------------------------------------------------------- /lollms/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/assets/logo.png -------------------------------------------------------------------------------- /lollms/assets/logo_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/assets/logo_old.png -------------------------------------------------------------------------------- /lollms/client_session.py: -------------------------------------------------------------------------------- 1 | from lollms.generation import RECEPTION_MANAGER, ROLE_CHANGE_DECISION, ROLE_CHANGE_OURTPUT 2 | from lollms.databases.discussions_database import Discussion, DiscussionsDB 3 | from lollms.paths import LollmsPaths 4 | from threading import Thread 5 | 6 | class Client: 7 | def __init__(self, lollms_paths:LollmsPaths, client_id:str, discussion:Discussion, db:DiscussionsDB): 8 | self.client_id = client_id 9 | self.discussion = discussion 10 | self.lollms_paths = lollms_paths 11 | 12 | if discussion: 13 | self.discussion_path = lollms_paths.personal_discussions_path/db.discussion_db_name/f"{discussion.discussion_id}" 14 | else: 15 | self.discussion_path = None 16 | self.db_name = db 17 | self.rooms = set() 18 | 19 | self.rag_databases = [] 20 | self.generated_text = "" 21 | self.cancel_generation = False 22 | self.generation_routine:Thread = None 23 | self.processing = False 24 | self.schedule_for_deletion = False 25 | self.continuing = False 26 | self.first_chunk = True 27 | self.reception_manager = RECEPTION_MANAGER() # Assuming RECEPTION_MANAGER is a global class 28 | 29 | def join_room(self, room_id:str): 30 | self.rooms.add(room_id) 31 | 32 | def leave_room(self, room_id:str): 33 | if room_id in self.rooms: 34 | self.rooms.remove(room_id) 35 | 36 | 37 | class Session: 38 | def __init__(self, lollms_paths:LollmsPaths): 39 | self.clients = {} 40 | self.lollms_paths = lollms_paths 41 | 42 | def add_client(self, client_id, room_id:str, discussion:Discussion, db:DiscussionsDB): 43 | if client_id not in self.clients: 44 | self.clients[client_id] = Client(self.lollms_paths, client_id, discussion, db) 45 | 46 | self.clients[client_id].join_room(room_id) 47 | 48 | def get_client(self, client_id)->Client: 49 | return self.clients.get(client_id) 50 | 51 | def remove_client(self, client_id, room_id): 52 | client = self.get_client(client_id) 53 | if client: 54 | client.leave_room(room_id) 55 | if not client.rooms: 56 | del self.clients[client_id] 57 | -------------------------------------------------------------------------------- /lollms/configs/.gitignore: -------------------------------------------------------------------------------- 1 | local_config.yaml -------------------------------------------------------------------------------- /lollms/databases/remote_databases/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/databases/remote_databases/__init__.py -------------------------------------------------------------------------------- /lollms/databases/remote_databases/light_rag_database.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from typing import Optional, Any, List, Dict 3 | from enum import Enum 4 | from lollms.databases.datalakes.lollms_database import LollmsDatabase 5 | 6 | class SearchMode(str, Enum): 7 | naive = "naive" 8 | local = "local" 9 | global_ = "global" 10 | hybrid = "hybrid" 11 | 12 | class LollmsLightRag(LollmsDatabase): 13 | def __init__(self, server_url: str, name: str, description: Optional[str] = None): 14 | """ 15 | Initialize LightRAG client 16 | 17 | Args: 18 | server_url (str): Full URL of the LightRAG server 19 | name (str): Name of the database 20 | description (Optional[str]): Description of the database 21 | """ 22 | super().__init__(name, description) 23 | self.server_url = server_url.rstrip('/') 24 | 25 | def add_document(self, content: str, metadata: Optional[Dict[str, Any]] = None) -> bool: 26 | try: 27 | response = requests.post( 28 | f"{self.server_url}/documents/text", 29 | json={"text": content} 30 | ) 31 | response.raise_for_status() 32 | self.update_last_modified() 33 | return True 34 | except requests.RequestException: 35 | return False 36 | 37 | def query(self, text: str, **kwargs) -> str: 38 | try: 39 | response = requests.post( 40 | f"{self.server_url}/query", 41 | json={ 42 | "query": text, 43 | **kwargs 44 | } 45 | ) 46 | response.raise_for_status() 47 | return response.json()["response"] 48 | except requests.RequestException as e: 49 | raise ConnectionError(f"Failed to query: {str(e)}") 50 | 51 | def clear(self) -> bool: 52 | try: 53 | response = requests.delete(f"{self.server_url}/documents") 54 | response.raise_for_status() 55 | self.update_last_modified() 56 | return True 57 | except requests.RequestException: 58 | return False 59 | 60 | def get_stats(self) -> Dict[str, Any]: 61 | health_info = self.health_check() 62 | return { 63 | "indexed_files": health_info.get("indexed_files", 0), 64 | "configuration": health_info.get("configuration", {}) 65 | } 66 | 67 | def health_check(self) -> Dict[str, Any]: 68 | try: 69 | response = requests.get(f"{self.server_url}/health") 70 | response.raise_for_status() 71 | return response.json() 72 | except requests.RequestException as e: 73 | raise ConnectionError(f"Failed to check health: {str(e)}") 74 | 75 | def backup(self, path: str) -> bool: 76 | # Implementation would depend on LightRAG backup capabilities 77 | raise NotImplementedError("Backup not implemented for LightRAG") 78 | 79 | def restore(self, path: str) -> bool: 80 | # Implementation would depend on LightRAG restore capabilities 81 | raise NotImplementedError("Restore not implemented for LightRAG") -------------------------------------------------------------------------------- /lollms/databases/remote_databases/lollms_database.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Optional, Any, List, Dict 3 | from datetime import datetime 4 | 5 | class LollmsDatabase(ABC): 6 | """ 7 | Base class for all Lollms database implementations 8 | """ 9 | def __init__(self, name: str, description: Optional[str] = None): 10 | """ 11 | Initialize the database 12 | 13 | Args: 14 | name (str): Name of the database 15 | description (Optional[str]): Description of the database 16 | """ 17 | self.name = name 18 | self.description = description 19 | self.created_at = datetime.now() 20 | self.last_modified = datetime.now() 21 | 22 | @abstractmethod 23 | def add_document(self, content: str, metadata: Optional[Dict[str, Any]] = None) -> bool: 24 | """ 25 | Add a document to the database 26 | 27 | Args: 28 | content (str): The content to add 29 | metadata (Optional[Dict[str, Any]]): Additional metadata about the document 30 | 31 | Returns: 32 | bool: True if successful, False otherwise 33 | """ 34 | pass 35 | 36 | @abstractmethod 37 | def query(self, text: str, **kwargs) -> str: 38 | """ 39 | Query the database 40 | 41 | Args: 42 | text (str): Query text 43 | **kwargs: Additional query parameters 44 | 45 | Returns: 46 | str: Query response 47 | """ 48 | pass 49 | 50 | @abstractmethod 51 | def clear(self) -> bool: 52 | """ 53 | Clear all documents from the database 54 | 55 | Returns: 56 | bool: True if successful, False otherwise 57 | """ 58 | pass 59 | 60 | @abstractmethod 61 | def get_stats(self) -> Dict[str, Any]: 62 | """ 63 | Get database statistics 64 | 65 | Returns: 66 | Dict[str, Any]: Database statistics 67 | """ 68 | pass 69 | 70 | @abstractmethod 71 | def health_check(self) -> Dict[str, Any]: 72 | """ 73 | Check database health 74 | 75 | Returns: 76 | Dict[str, Any]: Health status information 77 | """ 78 | pass 79 | 80 | def get_info(self) -> Dict[str, Any]: 81 | """ 82 | Get database information 83 | 84 | Returns: 85 | Dict[str, Any]: Database information 86 | """ 87 | return { 88 | "name": self.name, 89 | "description": self.description, 90 | "created_at": self.created_at, 91 | "last_modified": self.last_modified, 92 | "type": self.__class__.__name__ 93 | } 94 | 95 | @abstractmethod 96 | def backup(self, path: str) -> bool: 97 | """ 98 | Backup the database 99 | 100 | Args: 101 | path (str): Backup destination path 102 | 103 | Returns: 104 | bool: True if successful, False otherwise 105 | """ 106 | pass 107 | 108 | @abstractmethod 109 | def restore(self, path: str) -> bool: 110 | """ 111 | Restore the database from backup 112 | 113 | Args: 114 | path (str): Backup source path 115 | 116 | Returns: 117 | bool: True if successful, False otherwise 118 | """ 119 | pass 120 | 121 | def update_last_modified(self): 122 | """Update the last modified timestamp""" 123 | self.last_modified = datetime.now() -------------------------------------------------------------------------------- /lollms/function_call.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | from typing import Dict, Any, List 3 | from enum import Enum, auto 4 | from lollms.client_session import Client 5 | from lollms.com import LoLLMsCom 6 | from lollms.config import TypedConfig, ConfigTemplate, BaseConfig 7 | 8 | # Step 1: Define the FunctionType enum 9 | class FunctionType(Enum): 10 | CONTEXT_UPDATE = auto() # Adds information to the context 11 | AI_FIRST_CALL = auto() # Called by the AI first, returns output, AI continues 12 | CLASSIC = auto() # A classic function call with prompt 13 | 14 | # Step 2: Update the FunctionCall base class 15 | class FunctionCall: 16 | def __init__(self, function_name:str, app:LoLLMsCom, function_type: FunctionType, client: Client, static_parameters:TypedConfig=None, description=""): 17 | self.function_name = function_name 18 | self.app = app 19 | self.function_type = function_type 20 | self.client = client 21 | self.description = description 22 | if static_parameters is not None: 23 | self.static_parameters = static_parameters 24 | self.sync_configuration() 25 | self.personality = app.personality 26 | 27 | def sync_configuration(self): 28 | self.configuration_file_path = self.app.lollms_paths.personal_configuration_path/"services"/self.function_name/f"config.yaml" 29 | self.configuration_file_path.parent.mkdir(parents=True, exist_ok=True) 30 | self.static_parameters.config.file_path = self.configuration_file_path 31 | try: 32 | self.static_parameters.config.load_config() 33 | except: 34 | self.static_parameters.config.save_config() 35 | self.static_parameters.sync() 36 | 37 | def settings_updated(self): 38 | pass 39 | 40 | def execute(self, context, *args, **kwargs): 41 | """ 42 | Execute the function based on its type. 43 | This method should be overridden by subclasses. 44 | """ 45 | raise NotImplementedError("Subclasses must implement the execute method.") 46 | 47 | def update_context(self, context, constructed_context:List[str]): 48 | """ 49 | Update the context if needed. 50 | This method should be overridden by subclasses. 51 | """ 52 | return constructed_context 53 | 54 | def process_output(self, context, llm_output:str): 55 | return llm_output -------------------------------------------------------------------------------- /lollms/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/__init__.py -------------------------------------------------------------------------------- /lollms/functions/analyze_code/__init__.py: -------------------------------------------------------------------------------- 1 | from lollms.functions.analyze_code.create_project_database import create_project_database, create_project_database_function 2 | from lollms.functions.analyze_code.retreive_information_for_task import retrieve_information_for_task, retrieve_information_for_task_function 3 | from lollms.functions.analyze_code.retrieve_classes_from_project import retrieve_classes_from_project, retrieve_classes_from_project_function 4 | from lollms.functions.analyze_code.update_class_in_file import update_class_in_file, update_class_in_file_function 5 | from lollms.functions.analyze_code.update_function_in_file import update_function_in_file, update_function_in_file_function 6 | from lollms.functions.analyze_code.add_function_to_file import add_function_to_file, add_function_to_file_function 7 | 8 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/add_code_to_file.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: add_code_to_file.py 3 | # Author: ParisNeo 4 | # Description: This function adds given code to a specified Python file in a project directory. 5 | 6 | # Import necessary modules 7 | from functools import partial 8 | from ascii_colors import trace_exception 9 | from typing import Union 10 | from pathlib import Path 11 | 12 | # Function to add code to a file 13 | def add_code_to_file(file_name: str, code_content: str, project_path: Union[str, Path] = "") -> str: 14 | """ 15 | Adds the specified code content to the given file in the project path. 16 | 17 | Args: 18 | file_name (str): The name of the file to add code to. 19 | code_content (str): The code content to be added. 20 | project_path (Union[str, Path]): The path to the Python project directory. 21 | 22 | Returns: 23 | str: Success message or error message. 24 | """ 25 | try: 26 | project_path = Path(project_path) 27 | 28 | # Validate the project path 29 | if not project_path.exists() or not project_path.is_dir(): 30 | return "Invalid project path." 31 | 32 | file_path = project_path / file_name 33 | 34 | # Check if the file exists 35 | if not file_path.exists(): 36 | return f"File {file_name} does not exist in the specified project." 37 | 38 | # Read the current content of the file 39 | with open(file_path, "r", encoding="utf-8") as file: 40 | current_content = file.read() 41 | 42 | # Add the new code content 43 | updated_content = current_content + "\n\n" + code_content 44 | 45 | # Write the updated content back to the file 46 | with open(file_path, "w", encoding="utf-8") as file: 47 | file.write(updated_content) 48 | 49 | return f"Code added successfully to file {file_name}." 50 | 51 | except Exception as e: 52 | return trace_exception(e) 53 | 54 | 55 | # Metadata function 56 | def add_code_to_file_function(project_path: str): 57 | return { 58 | "function_name": "add_code_to_file", # The function name in string 59 | "function": partial(add_code_to_file, project_path=project_path), # The function to be called 60 | "function_description": "Adds the specified code content to the given file in the project path.", # Description of the function 61 | "function_parameters": [ # The set of parameters 62 | {"name": "file_name", "type": "str"}, 63 | {"name": "code_content", "type": "str"}, 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/add_function_to_file.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | from ascii_colors import trace_exception 3 | from typing import List, Union 4 | from pathlib import Path 5 | import ast 6 | 7 | def add_function_to_file(file_path: Union[str, Path], function_name: str, function_content: str) -> str: 8 | """ 9 | Adds a new function to the specified file. 10 | 11 | Args: 12 | file_path (Union[str, Path]): The path to the Python file. 13 | function_name (str): The name of the function to add. 14 | function_content (str): The content of the function to add. 15 | 16 | Returns: 17 | str: Success message or error message. 18 | """ 19 | try: 20 | file_path = Path(file_path) 21 | 22 | # Validate the file path 23 | if not file_path.exists() or not file_path.is_file(): 24 | return "Invalid file path." 25 | 26 | with open(file_path, "r", encoding="utf-8") as file: 27 | content = file.read() 28 | tree = ast.parse(content) 29 | 30 | # Check if function already exists 31 | for node in ast.walk(tree): 32 | if isinstance(node, ast.FunctionDef) and node.name == function_name: 33 | return f"Function {function_name} already exists in the file." 34 | 35 | # Add the new function content at the end of the file 36 | with open(file_path, "a", encoding="utf-8") as file: 37 | file.write("\n\n" + function_content) 38 | 39 | return f"Function {function_name} added successfully to file {file_path}." 40 | 41 | except Exception as e: 42 | return trace_exception(e) 43 | 44 | 45 | # Metadata function 46 | def add_function_to_file_function(): 47 | return { 48 | "function_name": "add_function_to_file", # The function name in string 49 | "function": add_function_to_file, # The function to be called 50 | "function_description": "Adds a new function to the specified file.", # Description of the function 51 | "function_parameters": [ # The set of parameters 52 | {"name": "file_path", "type": "str"}, 53 | {"name": "function_name", "type": "str"}, 54 | {"name": "function_content", "type": "str"}, 55 | ] 56 | } -------------------------------------------------------------------------------- /lollms/functions/analyze_code/git_commit.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: git_commit.py 3 | # Author: ParisNeo 4 | # Description: This function commits changes to a Git repository with a specified commit message. 5 | 6 | # Import necessary libraries 7 | from functools import partial 8 | from typing import Union 9 | from pathlib import Path 10 | import subprocess 11 | from ascii_colors import trace_exception 12 | 13 | # Ensure Git is installed 14 | from lollms.utilities import PackageManager 15 | 16 | if not PackageManager.check_package_installed("git"): 17 | PackageManager.install_package("gitpython") 18 | 19 | import git 20 | 21 | def git_commit(commit_message: str, repo_path: Union[str, Path]) -> str: 22 | """ 23 | Commits changes to a Git repository with a specified commit message. 24 | 25 | Args: 26 | repo_path (Union[str, Path]): The path to the Git repository. 27 | commit_message (str): The commit message. 28 | 29 | Returns: 30 | str: Success or error message. 31 | """ 32 | try: 33 | repo_path = Path(repo_path) 34 | if not repo_path.exists(): 35 | return "Repository path does not exist." 36 | 37 | repo = git.Repo(repo_path) 38 | 39 | # Stage all changes 40 | repo.git.add(A=True) 41 | 42 | # Commit changes 43 | repo.index.commit(commit_message) 44 | 45 | return "Changes committed successfully." 46 | 47 | except Exception as e: 48 | return trace_exception(e) 49 | 50 | def git_commit_function(repo_path:Path|str): 51 | return { 52 | "function_name": "git_commit", 53 | "function": partial(git_commit, repo_path=repo_path), 54 | "function_description": "Commits changes to a Git repository with a specified commit message.", 55 | "function_parameters": [ 56 | {"name": "commit_message", "type": "str"} 57 | ] 58 | } 59 | 60 | if __name__ == "__main__": 61 | # Example usage 62 | repo_path = "path/to/repo" 63 | commit_message = "Your commit message" 64 | print(git_commit(repo_path, commit_message)) 65 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/git_pull.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: git_pull.py 3 | # Author: ParisNeo 4 | # Description: This function pulls the latest changes from the remote repository to the local Git repository. 5 | 6 | # Import necessary libraries 7 | from functools import partial 8 | from typing import Union 9 | from pathlib import Path 10 | import subprocess 11 | from ascii_colors import trace_exception 12 | 13 | # Ensure Git is installed 14 | from lollms.utilities import PackageManager 15 | 16 | if not PackageManager.check_package_installed("git"): 17 | PackageManager.install_package("gitpython") 18 | 19 | import git 20 | 21 | def git_pull(repo_path: Union[str, Path]) -> str: 22 | """ 23 | Pulls the latest changes from the remote repository to the local Git repository. 24 | 25 | Args: 26 | repo_path (Union[str, Path]): The path to the Git repository. 27 | 28 | Returns: 29 | str: Success or error message. 30 | """ 31 | try: 32 | repo_path = Path(repo_path) 33 | if not repo_path.exists(): 34 | return "Repository path does not exist." 35 | 36 | repo = git.Repo(repo_path) 37 | 38 | # Pull latest changes 39 | repo.remotes.origin.pull() 40 | 41 | return "Latest changes pulled successfully." 42 | 43 | except Exception as e: 44 | return trace_exception(e) 45 | 46 | def git_pull_function(repo_path:Path|str): 47 | return { 48 | "function_name": "git_pull", 49 | "function": partial(git_pull, repo_path=repo_path), 50 | "function_description": "Pulls the latest changes from the remote repository to the local Git repository.", 51 | "function_parameters": [ 52 | {"name": "repo_path", "type": "str"} 53 | ] 54 | } 55 | 56 | if __name__ == "__main__": 57 | # Example usage 58 | repo_path = "path/to/repo" 59 | print(git_pull(repo_path)) 60 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/list_classes.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: list_project_classes.py 3 | # Author: Saif 4 | # Description: This script defines a function to list all classes in a given Python project. 5 | 6 | # Import necessary libraries 7 | from functools import partial 8 | from pathlib import Path 9 | from typing import Union, List 10 | import ast 11 | import sqlite3 12 | 13 | # Import PackageManager if there are potential libraries that need to be installed 14 | from lollms.utilities import PackageManager 15 | 16 | # ascii_colors offers advanced console coloring and bug tracing 17 | from ascii_colors import trace_exception 18 | 19 | # Here is the core of the function to be built 20 | def list_project_classes(project_path: Union[str, Path]) -> List[str]: 21 | """ 22 | Lists all classes in a given Python project. 23 | 24 | Args: 25 | project_path (Union[str, Path]): The path to the Python project directory. 26 | 27 | Returns: 28 | List[str]: A list of class names found in the project. 29 | """ 30 | try: 31 | project_path = Path(project_path) 32 | 33 | # Validate the project path 34 | if not project_path.exists() or not project_path.is_dir(): 35 | return ["Invalid project path."] 36 | 37 | class_names = [] 38 | 39 | # Traverse the project directory and extract class names 40 | for py_file in project_path.rglob("*.py"): 41 | with open(py_file, "r", encoding="utf-8") as file: 42 | content = file.read() 43 | tree = ast.parse(content) 44 | 45 | for node in ast.walk(tree): 46 | if isinstance(node, ast.ClassDef): 47 | class_names.append(node.name) 48 | 49 | return class_names 50 | 51 | except Exception as e: 52 | return [trace_exception(e)] 53 | 54 | # Metadata function 55 | def list_project_classes_function(project_path): 56 | return { 57 | "function_name": "list_project_classes", 58 | "function": partial(list_project_classes, project_path=project_path), 59 | "function_description": "Lists all classes in a given Python project.", 60 | "function_parameters": [] 61 | } 62 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/list_files.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: list_project_structure.py 3 | # Author: ParisNeo 4 | # Description: This function lists and displays the structure of the project directory. 5 | 6 | from functools import partial 7 | from pathlib import Path 8 | from typing import Union, List 9 | from ascii_colors import trace_exception 10 | 11 | def list_project_structure(project_path: Union[str, Path]) -> str: 12 | """ 13 | Lists and displays the structure of the project directory, excluding certain directories. 14 | 15 | Args: 16 | project_path (Union[str, Path]): The path to the project directory. 17 | 18 | Returns: 19 | str: A string representation of the project directory structure. 20 | """ 21 | try: 22 | project_path = Path(project_path) 23 | 24 | # Validate the project path 25 | if not project_path.exists() or not project_path.is_dir(): 26 | return "Invalid project path." 27 | 28 | # Directories to exclude 29 | exclude_dirs = {'.git', '.vscode', '__pycache__'} 30 | 31 | structure = [] 32 | for file in project_path.rglob("*"): 33 | # Skip excluded directories 34 | if any(part in exclude_dirs or part.endswith('.egg-info') for part in file.parts): 35 | continue 36 | 37 | indent_level = len(file.relative_to(project_path).parts) - 1 38 | structure.append(f"{' ' * indent_level}{file.name}") 39 | 40 | return "\n".join(structure) 41 | 42 | except Exception as e: 43 | return trace_exception(e) 44 | 45 | def list_project_structure_function(project_path: Union[str, Path]): 46 | return { 47 | "function_name": "list_project_structure", 48 | "function": partial(list_project_structure, project_path=project_path), 49 | "function_description": "Lists and displays the structure of the project directory.", 50 | "function_parameters": [] 51 | } 52 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/retrieve_classes_from_project.py: -------------------------------------------------------------------------------- 1 | # Import necessary libraries 2 | from pathlib import Path 3 | from functools import partial 4 | 5 | from typing import List, Union 6 | import ast 7 | 8 | # ascii_colors offers advanced console coloring and bug tracing 9 | from ascii_colors import trace_exception 10 | 11 | # Function to retrieve classes from the project files 12 | def retrieve_classes_from_project(class_names: List[str], project_path: Union[str, Path]) -> str: 13 | """ 14 | Retrieves the code of specified classes from the given project path. 15 | 16 | Args: 17 | project_path (Union[str, Path]): The path to the Python project directory. 18 | class_names (List[str]): List of class names to retrieve. 19 | 20 | Returns: 21 | str: The code of the specified classes as a string. 22 | """ 23 | try: 24 | project_path = Path(project_path) 25 | 26 | # Validate the project path 27 | if not project_path.exists() or not project_path.is_dir(): 28 | return "Invalid project path." 29 | 30 | class_code = "\n" 31 | 32 | # Traverse the project directory and extract class code 33 | for py_file in project_path.rglob("*.py"): 34 | with open(py_file, "r", encoding="utf-8") as file: 35 | content = file.read() 36 | tree = ast.parse(content) 37 | 38 | for node in ast.walk(tree): 39 | if isinstance(node, ast.ClassDef) and node.name in class_names: 40 | class_code += f"\n\n# Class: {node.name} in file: {py_file.relative_to(project_path)}\n" 41 | class_code += "```python\n" 42 | class_code += "\n".join(content.split("\n")[node.lineno-1:node.end_lineno]) 43 | class_code += "\n```\n" 44 | 45 | return class_code if class_code else "No specified classes found." 46 | 47 | except Exception as e: 48 | return trace_exception(e) 49 | 50 | # Metadata function 51 | def retrieve_classes_from_project_function(project_path:str): 52 | return { 53 | "function_name": "retrieve_classes_from_project", 54 | "function": partial(retrieve_classes_from_project,project_path = project_path), 55 | "function_description": "Retrieves the code of specified classes from the given project path.", 56 | "function_parameters": [ 57 | {"name": "class_names", "type": "list", "description": "List of class names to retrieve."} 58 | ] 59 | } -------------------------------------------------------------------------------- /lollms/functions/analyze_code/search_class_in_project.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, Union 2 | from pathlib import Path 3 | import sqlite3 4 | import difflib 5 | import json 6 | 7 | from ascii_colors import trace_exception 8 | from functools import partial 9 | 10 | def search_class_in_project(class_name: str, db_path: Union[str, Path]) -> Optional[str]: 11 | """ 12 | Searches for a specific class by name in the project database and returns detailed information. 13 | 14 | Args: 15 | db_path (Union[str, Path]): The path to the project database file. 16 | class_name (str): The name of the class to search for. 17 | 18 | Returns: 19 | Optional[str]: A string with detailed information about the class, or None if not found. 20 | """ 21 | try: 22 | db_path = Path(db_path) 23 | if not db_path.exists(): 24 | return "Database file does not exist." 25 | 26 | conn = sqlite3.connect(db_path) 27 | cursor = conn.cursor() 28 | 29 | # Fetch all class names to find the closest match 30 | cursor.execute("SELECT id, name FROM classes") 31 | classes = cursor.fetchall() 32 | class_names = [name for _, name in classes] 33 | closest_matches = difflib.get_close_matches(class_name, class_names, n=1, cutoff=0.1) 34 | 35 | if not closest_matches: 36 | return f"No class found with a name similar to '{class_name}'." 37 | 38 | closest_class_name = closest_matches[0] 39 | cursor.execute("SELECT id, file_id, name, docstring, core FROM classes WHERE name = ?", (closest_class_name,)) 40 | class_info = cursor.fetchone() 41 | 42 | if not class_info: 43 | return f"No class found with the name '{closest_class_name}'." 44 | 45 | class_id, file_id, name, docstring, core = class_info 46 | 47 | # Fetch the file path 48 | cursor.execute("SELECT path FROM files WHERE id = ?", (file_id,)) 49 | file_path = cursor.fetchone()[0] 50 | 51 | # Fetch methods of the class 52 | cursor.execute("SELECT name, docstring, parameters FROM methods WHERE class_id = ?", (class_id,)) 53 | methods = cursor.fetchall() 54 | 55 | # Construct the detailed information string 56 | details = f"Class: {name}\n" 57 | details += f"File: {file_path}\n" 58 | details += f"Description: {docstring}\n\n" 59 | details += "Methods:\n" 60 | for method_name, method_docstring, method_parameters in methods: 61 | details += f" - {method_name}({', '.join([f'{param[0]}: {param[1]}' for param in json.loads(method_parameters)])})\n" 62 | details += f" Description: {method_docstring}\n" 63 | 64 | conn.close() 65 | return details 66 | 67 | except Exception as e: 68 | return trace_exception(e) 69 | 70 | 71 | def search_class_in_project_function(project_path): 72 | return { 73 | "function_name": "create_project_database", 74 | "function": partial(search_class_in_project, project_path=project_path), 75 | "function_description": "Searches for a specific class by name in the project database and returns detailed information.", 76 | "function_parameters": [{"name":"class_name", "type":"str", "description":"Name of the class to search"}] 77 | } 78 | 79 | 80 | if __name__ == "__main__": 81 | # Example usage 82 | db_path = "path/to/project_info.db" 83 | class_name = "MyClass" 84 | print(search_class_in_project(db_path, class_name)) 85 | -------------------------------------------------------------------------------- /lollms/functions/analyze_code/update_function_in_file.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | from functools import partial 3 | from lollms.utilities import PackageManager 4 | from ascii_colors import trace_exception 5 | from typing import List, Union 6 | from pathlib import Path 7 | import ast 8 | 9 | def update_function_in_file(function_name: str, new_content: str, project_path: Union[str, Path] = "") -> str: 10 | """ 11 | Updates the specified function with new content in the given project path. 12 | 13 | Args: 14 | function_name (str): The name of the function to update. 15 | new_content (str): The new content to replace the function with. 16 | project_path (Union[str, Path]): The path to the Python project directory. 17 | 18 | Returns: 19 | str: Success message or error message. 20 | """ 21 | try: 22 | project_path = Path(project_path) 23 | 24 | # Validate the project path 25 | if not project_path.exists() or not project_path.is_dir(): 26 | return "Invalid project path." 27 | 28 | # Traverse the project directory and update function content 29 | for py_file in project_path.rglob("*.py"): 30 | with open(py_file, "r", encoding="utf-8") as file: 31 | content = file.read() 32 | tree = ast.parse(content) 33 | 34 | function_found = False 35 | updated_content = [] 36 | lines = content.split("\n") 37 | 38 | for node in ast.walk(tree): 39 | if isinstance(node, ast.FunctionDef) and node.name == function_name: 40 | function_found = True 41 | # Calculate the indentation level 42 | indent_level = len(lines[node.lineno-1]) - len(lines[node.lineno-1].lstrip()) 43 | indented_new_content = "\n".join(" " * indent_level + line for line in new_content.split("\n")) 44 | updated_content.extend(lines[:node.lineno-1]) 45 | updated_content.append(indented_new_content) 46 | updated_content.extend(lines[node.end_lineno:]) 47 | break 48 | 49 | if function_found: 50 | with open(py_file, "w", encoding="utf-8") as file: 51 | file.write("\n".join(updated_content)) 52 | return f"Function {function_name} updated successfully in file {py_file.relative_to(project_path)}." 53 | 54 | return "Function not found in the specified project." 55 | 56 | except Exception as e: 57 | return trace_exception(e) 58 | 59 | 60 | # Metadata function 61 | def update_function_in_file_function(project_path:str ): 62 | return { 63 | "function_name": "update_function_in_file", # The function name in string 64 | "function": partial(update_function_in_file, project_path=project_path), # The function to be called 65 | "function_description": "Updates the specified function with new content in the given project path.", # Description of the function 66 | "function_parameters": [ # The set of parameters 67 | {"name": "function_name", "type": "str"}, 68 | {"name": "new_content", "type": "str"}, 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /lollms/functions/file_manipulation.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # Here you need to import any necessary imports depending on the function requested by the user 3 | from functools import partial 4 | from typing import List 5 | from ascii_colors import trace_exception 6 | 7 | # Importing pathlib 8 | from pathlib import Path 9 | 10 | # Function to change the file extension 11 | def change_file_extension(file_path: str, new_extension: str) -> str: 12 | """ 13 | Change the extension of a given file path. 14 | 15 | Parameters: 16 | file_path (str): The original file path. 17 | new_extension (str): The new extension, including the leading dot (e.g., '.txt'). 18 | 19 | Returns: 20 | str: The new file path with the changed extension. 21 | 22 | Example: 23 | >>> change_file_extension("example.docx", ".txt") 24 | 'example.txt' 25 | """ 26 | try: 27 | # Create a Path object from the file path 28 | path = Path(file_path) 29 | 30 | # Change the extension 31 | new_path = path.with_suffix(new_extension) 32 | 33 | # Return the new path as a string 34 | return str(new_path) 35 | except Exception as e: 36 | return trace_exception(e) 37 | 38 | # Metadata function 39 | def change_file_extension_function(): 40 | return { 41 | "function_name": "change_file_extension", # The function name in string 42 | "function": change_file_extension, # The function to be called 43 | "function_description": "Takes a file path and a new extension, then returns the new path with the changed extension.", # Description of the function 44 | "function_parameters": [ 45 | {"name": "file_path", "type": "str"}, 46 | {"name": "new_extension", "type": "str"} 47 | ] # The set of parameters 48 | } 49 | -------------------------------------------------------------------------------- /lollms/functions/generate_music.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: music_generator.py 3 | # Author: ParisNeo 4 | # Description: This function generates music based on a given prompt and duration, saving the output to a unique file in the discussion folder. 5 | 6 | # Import necessary libraries 7 | try: 8 | import pipmaster as pm 9 | pm.ensure_packages({"torch":"","torchaudio":"","audiocraft":""}) 10 | 11 | import torchaudio 12 | from audiocraft.models import musicgen 13 | from ascii_colors import trace_exception 14 | from functools import partial 15 | 16 | # Function to generate music 17 | def generate_music(processor, client, generation_prompt: str, duration: int, model_name: str = "facebook/musicgen-melody", device: str="cuda:0") -> str: 18 | """ 19 | Generates music based on the given prompt and duration, saving it to a unique file in the discussion folder. 20 | 21 | Parameters: 22 | - processor: The processor object used for managing the generation process. 23 | - client: The client object containing discussion information. 24 | - generation_prompt: The prompt for music generation. 25 | - duration: The duration of the music in seconds. 26 | - model_name: The name of the pretrained music generation model. 27 | - device: The device to run the model on (e.g., 'cpu' or 'cuda'). 28 | 29 | Returns: 30 | - The path of the saved music file. 31 | """ 32 | 33 | try: 34 | # Load the pretrained music generation model 35 | music_model = musicgen.MusicGen.get_pretrained(model_name, device=device) 36 | 37 | # Set generation parameters 38 | music_model.set_generation_params(duration=duration) 39 | 40 | # Generate music 41 | res = music_model.generate([generation_prompt]) 42 | 43 | # Create output folder if it doesn't exist 44 | output_folder = client.discussion.discussion_folder / "generated_music" 45 | output_folder.mkdir(parents=True, exist_ok=True) 46 | 47 | # Generate a unique file name 48 | output_file = output_folder / f"music_generation_{len(list(output_folder.glob('*.wav')))}.wav" 49 | 50 | # Save the generated music to the specified file 51 | torchaudio.save(output_file, res.reshape(1, -1).cpu(), 32000) 52 | 53 | # Return the path of the saved file 54 | return str(output_file) 55 | except Exception as e: 56 | return trace_exception(e) 57 | 58 | # Metadata function for the music generation function 59 | def generate_music_function(processor, client): 60 | return { 61 | "function_name": "generate_music", # The function name in string 62 | "function": partial(generate_music, processor=processor, client=client), # The function to be called with preset parameters 63 | "function_description": "Generates music based on a prompt and duration, saving it to a unique file in the discussion folder.", # Description of the function 64 | "function_parameters": [ # Parameters needed for the function 65 | {"name": "generation_prompt", "type": "str"}, 66 | {"name": "duration", "type": "int"}, 67 | {"name": "model_name", "type": "str"}, 68 | {"name": "device", "type": "str"} 69 | ] 70 | } 71 | except: 72 | from functools import partial 73 | 74 | def generate_music(processor, client, generation_prompt: str, duration: int, model_name: str = "facebook/musicgen-melody", device: str="cuda:0") -> str: 75 | pass 76 | def generate_music_function(processor, client): 77 | return { 78 | "function_name": "generate music is not available", # The function name in string 79 | "function": partial(generate_music,processor, client), # The function to be called with preset parameters 80 | "function_description": "This function is not availabe.", # Description of the function 81 | "function_parameters":[] 82 | } 83 | -------------------------------------------------------------------------------- /lollms/functions/image_management/draw_bounding_boxes.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: draw_bounding_boxes.py 3 | # Author: Saif (ParisNeo) 4 | # Description: This script defines a function that takes an image file path and a list of bounding boxes in the form of x, y, w, h in normalized mode along with the labels, and returns the bounding boxes placed on top of the images with the labels. 5 | 6 | # Lollms function call definition file 7 | from functools import partial 8 | from typing import List, Tuple 9 | from lollms.utilities import PackageManager 10 | from ascii_colors import trace_exception 11 | from pathlib import Path 12 | 13 | # Ensure necessary packages are installed 14 | if not PackageManager.check_package_installed("Pillow"): 15 | PackageManager.install_package("Pillow") 16 | 17 | from PIL import Image, ImageDraw, ImageFont 18 | 19 | def draw_bounding_boxes(image_path: str, bounding_boxes: List[Tuple[float, float, float, float, str]]) -> str: 20 | """ 21 | Draws bounding boxes on an image and saves the result. 22 | 23 | Args: 24 | image_path (str): Path to the input image file. 25 | bounding_boxes (List[Tuple[float, float, float, float, str]]): List of bounding boxes in normalized coordinates (x, y, w, h) along with labels. 26 | 27 | Returns: 28 | str: Path to the output image file with bounding boxes drawn. 29 | """ 30 | try: 31 | image_path = Path(image_path) 32 | if not image_path.exists(): 33 | raise FileNotFoundError(f"Image file not found: {image_path}") 34 | 35 | # Load the image 36 | image = Image.open(image_path) 37 | draw = ImageDraw.Draw(image) 38 | width, height = image.size 39 | 40 | # Iterate over bounding boxes and draw them 41 | for bbox in bounding_boxes: 42 | x, y, w, h, label = bbox 43 | left = x * width 44 | top = y * height 45 | right = left + (w * width) 46 | bottom = top + (h * height) 47 | 48 | # Draw rectangle 49 | draw.rectangle([left, top, right, bottom], outline="red", width=2) 50 | 51 | # Draw label 52 | font = ImageFont.load_default() 53 | text_size = draw.textsize(label, font=font) 54 | text_background = [left, top - text_size[1], left + text_size[0], top] 55 | draw.rectangle(text_background, fill="red") 56 | draw.text((left, top - text_size[1]), label, fill="white", font=font) 57 | 58 | # Save the output image 59 | output_path = image_path.with_name(f"{image_path.stem}_with_boxes{image_path.suffix}") 60 | image.save(output_path) 61 | 62 | return str(output_path) 63 | except Exception as e: 64 | return trace_exception(e) 65 | 66 | def draw_bounding_boxes_function(): 67 | return { 68 | "function_name": "draw_bounding_boxes", 69 | "function": draw_bounding_boxes, 70 | "function_description": "Draws bounding boxes on an image and saves the result.", 71 | "function_parameters": [ 72 | {"name": "image_path", "type": "str"}, 73 | {"name": "bounding_boxes", "type": "List[Tuple[float, float, float, float, str]]"} 74 | ] 75 | } 76 | -------------------------------------------------------------------------------- /lollms/functions/list_personalities.py: -------------------------------------------------------------------------------- 1 | from lollms.utilities import find_first_available_file_index, discussion_path_to_url 2 | from lollms.client_session import Client 3 | from lollms.personality import APScript 4 | from ascii_colors import trace_exception 5 | from functools import partial 6 | from lollms.personality import AIPersonality 7 | from typing import List 8 | def list_personalities(processor:APScript, client:Client): 9 | members:List[AIPersonality] = processor.personality.app.mounted_personalities 10 | collective_infos = "Members information:\n" 11 | for i,drone in enumerate(members): 12 | if drone.name!=processor.personality.name: 13 | collective_infos += f"member id: {i}\n" 14 | collective_infos += f"member name: {drone.name}\n" 15 | collective_infos += f"member description: {drone.personality_description[:126]}...\n" 16 | return collective_infos 17 | 18 | 19 | def list_personalities_function(processor, client): 20 | return { 21 | "function_name": "list_personalities", 22 | "function": partial(list_personalities, processor=processor, client=client), 23 | "function_description": "Lists the mounted ersonalities in the current sessions.", 24 | "function_parameters": [] 25 | } 26 | -------------------------------------------------------------------------------- /lollms/functions/luma_ai_dream_machine/input_section_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/luma_ai_dream_machine/input_section_image.png -------------------------------------------------------------------------------- /lollms/functions/luma_ai_dream_machine/sign_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/luma_ai_dream_machine/sign_in.png -------------------------------------------------------------------------------- /lollms/functions/luma_ai_dream_machine/try_now.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/luma_ai_dream_machine/try_now.png -------------------------------------------------------------------------------- /lollms/functions/peripherals.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # Here you need to import any necessary imports depending on the function requested by the user 3 | # exemple import math 4 | 5 | # ascii_colors offers advanced console coloring and bug tracing 6 | from ascii_colors import trace_exception 7 | import pipmaster as pm 8 | pm.ensure_packages({"pyautogui":""}) 9 | 10 | # now we can import the library 11 | import pyautogui 12 | 13 | # here is the core of the function to be built 14 | def move_mouse_to_position(x: int, y: int) -> str: 15 | try: 16 | # Move the mouse to the specified (x, y) position 17 | pyautogui.moveTo(x, y) 18 | 19 | # Return a success message 20 | return f"Mouse moved to position ({x}, {y}) successfully." 21 | except Exception as e: 22 | return trace_exception(e) 23 | 24 | # Here is the metadata function that should have the name in format function_name_function 25 | def move_mouse_to_position_function(): 26 | screen_width, screen_height = pyautogui.size() 27 | return { 28 | "function_name": "move_mouse_to_position", # The function name in string 29 | "function": move_mouse_to_position, # The function to be called 30 | "function_description": f"Moves the mouse to a specific position on the screen. The screen resolution is {screen_width} {screen_height}", # Description of the function 31 | "function_parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}] # The set of parameters 32 | } 33 | 34 | 35 | 36 | # here is the core of the function to be built 37 | def press_mouse_button(button: str) -> str: 38 | try: 39 | # Simulate a mouse button press 40 | pyautogui.mouseDown(button=button) 41 | pyautogui.mouseUp(button=button) 42 | 43 | # Return a success message 44 | return f"Mouse button '{button}' pressed successfully." 45 | except Exception as e: 46 | return trace_exception(e) 47 | 48 | # Here is the metadata function that should have the name in format function_name_function 49 | def press_mouse_button_function(): 50 | return { 51 | "function_name": "press_mouse_button", # The function name in string 52 | "function": press_mouse_button, # The function to be called 53 | "function_description": "Simulates a press of a mouse button.", # Description of the function 54 | "function_parameters": [{"name": "button", "type": "str"}] # The set of parameters 55 | } 56 | 57 | # here is the core of the function to be built 58 | def type_text(text: str) -> str: 59 | try: 60 | # Type the specified text 61 | pyautogui.typewrite(text) 62 | 63 | # Return a success message 64 | return f"Text '{text}' typed successfully." 65 | except Exception as e: 66 | return trace_exception(e) 67 | 68 | # Here is the metadata function that should have the name in format function_name_function 69 | def type_text_function(): 70 | return { 71 | "function_name": "type_text", # The function name in string 72 | "function": type_text, # The function to be called 73 | "function_description": "Types the specified text.", # Description of the function 74 | "function_parameters": [{"name": "text", "type": "str"}] # The set of parameters 75 | } -------------------------------------------------------------------------------- /lollms/functions/roll_a_dice.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # Here you need to import any necessary imports depending on the function requested by the user 3 | import random 4 | 5 | # ascii_colors offers advanced console coloring and bug tracing 6 | from ascii_colors import trace_exception 7 | 8 | # here is the core of the function to be built 9 | def roll_a_dice() -> int: 10 | try: 11 | # handle exceptions 12 | 13 | # Perform dice roll 14 | result = random.randint(1, 6) 15 | 16 | # Return the dice roll result 17 | return result 18 | except Exception as e: 19 | return trace_exception(e) 20 | 21 | 22 | #Here is the metadata function that should have the name in format function_name_function 23 | def roll_a_dice_function(): 24 | return { 25 | "function_name": "roll_a_dice", # The function name in string 26 | "function": roll_a_dice, # The function to be called 27 | "function_description": "Returns a random dice roll result between 1 and 6.", # Description of the function 28 | "function_parameters": [] # No parameters needed for this function 29 | } 30 | -------------------------------------------------------------------------------- /lollms/functions/runway_ml_gen_2/try_gen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/runway_ml_gen_2/try_gen2.png -------------------------------------------------------------------------------- /lollms/functions/search.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # Import necessary libraries 3 | import requests 4 | from typing import List 5 | 6 | from ascii_colors import trace_exception 7 | import pipmaster as pm 8 | pm.ensure_packages({"beautifulsoup4":"", "html2text":""}) 9 | 10 | # Import the libraries 11 | from bs4 import BeautifulSoup 12 | import html2text 13 | 14 | def clean_html_content(html_content: str) -> str: 15 | h = html2text.HTML2Text() 16 | h.ignore_links = True 17 | h.ignore_images = True 18 | clean_text = h.handle(html_content) 19 | return clean_text 20 | 21 | def search_and_clean_content(keywords: List[str], num_pages: int) -> str: 22 | try: 23 | search_query = "+".join(keywords) 24 | base_url = "https://www.google.com/search?q={query}&start={page}" 25 | headers = {'User-Agent': 'Mozilla/5.0'} 26 | 27 | all_cleaned_content = [] 28 | 29 | for page in range(0, num_pages * 10, 10): 30 | url = base_url.format(query=search_query, page=page) 31 | response = requests.get(url, headers=headers) 32 | 33 | if response.status_code != 200: 34 | return "Oops! Google is not cooperating. Try again later." 35 | 36 | soup = BeautifulSoup(response.text, 'html.parser') 37 | results = soup.find_all('div', class_='BNeawe s3v9rd AP7Wnd') 38 | 39 | for result in results: 40 | raw_html = result.get_text() 41 | cleaned_content = clean_html_content(raw_html) 42 | all_cleaned_content.append(cleaned_content) 43 | 44 | formatted_content = "\n\n".join(all_cleaned_content) 45 | return formatted_content 46 | 47 | except Exception as e: 48 | return trace_exception(e) 49 | 50 | def search_and_clean_content_function(): 51 | return { 52 | "function_name": "search_and_clean_content", 53 | "function": search_and_clean_content, 54 | "function_description": "Searches multiple websites for the given keywords, cleans the content, and returns useful information formatted in sections.", 55 | "function_parameters": [ 56 | {"name": "keywords", "type": "List[str]"}, 57 | {"name": "num_pages", "type": "int"} 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /lollms/functions/select_image_file.py: -------------------------------------------------------------------------------- 1 | from lollms.utilities import find_first_available_file_index, discussion_path_to_url 2 | from lollms.client_session import Client 3 | 4 | 5 | 6 | import time 7 | import sys 8 | from functools import partial 9 | import pipmaster as pm 10 | 11 | def select_image_file(processor, client): 12 | pm.ensure_packages({"PyQt5":"", "opencv-python":""}) 13 | import cv2 14 | from PyQt5 import QtWidgets 15 | app = QtWidgets.QApplication(sys.argv) 16 | options = QtWidgets.QFileDialog.Options() 17 | options |= QtWidgets.QFileDialog.ReadOnly 18 | file_name, _ = QtWidgets.QFileDialog.getOpenFileName(None, "Select Image File", "", "Image Files (*.png *.jpg *.jpeg *.bmp);;All Files (*)", options=options) 19 | if file_name: 20 | frame = cv2.imread(file_name) 21 | 22 | if frame is None: 23 | return "Failed to read the image file." 24 | 25 | view_image = client.discussion.discussion_folder/"view_images" 26 | image = client.discussion.discussion_folder/"images" 27 | index = find_first_available_file_index(view_image,"selected_image_",".png") 28 | fn_view = view_image/f"selected_image_{index}.png" 29 | cv2.imwrite(str(fn_view), frame) 30 | fn = image/f"selected_image_{index}.png" 31 | cv2.imwrite(str(fn), frame) 32 | client.discussion.image_files.append(fn) 33 | return f'' 34 | else: 35 | return "No file selected." 36 | 37 | def select_image_file_function(processor, client): 38 | return { 39 | "function_name": "select_image_file", 40 | "function": partial(select_image_file, processor=processor, client=client), 41 | "function_description": "Opens a file dialog to select an image file and displays it.", 42 | "function_parameters": [] 43 | } -------------------------------------------------------------------------------- /lollms/functions/summary.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | 3 | # Import necessary libraries 4 | import requests 5 | from pathlib import Path 6 | 7 | # Partial is useful if we need to preset some parameters 8 | from functools import partial 9 | 10 | # It is advised to import typing elements 11 | from typing import List, Optional, Any, Tuple, Dict 12 | 13 | # Import PackageManager if there are potential libraries that need to be installed 14 | 15 | # ascii_colors offers advanced console coloring and bug tracing 16 | from ascii_colors import trace_exception 17 | 18 | # Import Client from lollms.client_session 19 | from lollms.client_session import Client 20 | 21 | import pipmaster as pm 22 | pm.ensure_packages({"beautifulsoup4":""}) 23 | 24 | # Now we can import the library 25 | from bs4 import BeautifulSoup 26 | 27 | 28 | from lollms.databases.discussions_database import Discussion 29 | 30 | # Core function to search for PDFs on arXiv and download them to a specified directory 31 | def summarize_discussion(summary_request:str,llm, discussion:Discussion) -> str: 32 | messages = discussion.get_messages() 33 | text = "" 34 | for message in messages: 35 | text += message.content 36 | 37 | 38 | summary = llm.summarize_text( 39 | text, 40 | summary_request, 41 | doc_name="discussion" 42 | ) 43 | return summary 44 | 45 | # Metadata function 46 | def summarize_discussion_function(llm, discussion:Discussion): 47 | return { 48 | "function_name": "summarize_discussion", # The function name in string 49 | "function": partial(summarize_discussion, llm=llm, discussion=discussion), # The function to be called with partial to preset client 50 | "function_description": "summarizes the discussion while keeping some key information as requested by the summary_request parameter", # Description of the function 51 | "function_parameters": [ # The set of parameters 52 | {"name": "summary_request", "type": "str", "description": "The desired information to recover while summerizing."}, 53 | ] 54 | } -------------------------------------------------------------------------------- /lollms/functions/summon_personality.py: -------------------------------------------------------------------------------- 1 | from lollms.utilities import PackageManager, find_first_available_file_index, discussion_path_to_url 2 | from lollms.client_session import Client 3 | from lollms.personality import APScript 4 | from ascii_colors import trace_exception 5 | from functools import partial 6 | from lollms.personality import AIPersonality 7 | from typing import List 8 | 9 | def summon_personality(member_id:int, prompt: str, previous_discussion_text:str, context_details, callback, processor:APScript, client:Client): 10 | members:List[AIPersonality] = processor.personality.app.mounted_personalities 11 | processor.personality.app.personality = members[member_id] 12 | members[member_id].callback=callback 13 | processor.personality.app.handle_generate_msg(client.client_id, {"prompt":prompt}, False) 14 | processor.personality.app.personality = processor.personality 15 | return "Execution done" 16 | 17 | 18 | def summon_personality_function(processor, callback, previous_discussion_text, context_details, client): 19 | return { 20 | "function_name": "summon_personality", 21 | "function": partial(summon_personality, previous_discussion_text=previous_discussion_text, callback=callback, processor=processor, context_details=context_details, client=client), 22 | "function_description": "Summon a personality by id and prompting it to do something.", 23 | "function_parameters": [{"name": "member_id", "type": "int"},{"name": "prompt", "type": "str"}] 24 | } 25 | -------------------------------------------------------------------------------- /lollms/functions/take_screen_shot.py: -------------------------------------------------------------------------------- 1 | from lollms.utilities import find_first_available_file_index, discussion_path_to_url 2 | from lollms.client_session import Client 3 | import pipmaster as pm 4 | from functools import partial 5 | 6 | 7 | def take_screenshot(client: Client, use_ui: bool = False, use_a_single_photo_at_a_time= True): 8 | 9 | if not pm.is_installed("pyautogui"): 10 | pm.install("pyautogui") 11 | if not pm.is_installed("PyQt5"): 12 | pm.install("PyQt5") 13 | 14 | import pyautogui 15 | from PyQt5 import QtWidgets, QtGui 16 | import sys 17 | 18 | class ScreenshotWindow(QtWidgets.QWidget): 19 | def __init__(self, client, screenshot, fn_view, fn, use_a_single_photo_at_a_time= True): 20 | super().__init__() 21 | self.client = client 22 | self.screenshot = screenshot 23 | self.fn_view = fn_view 24 | self.fn = fn 25 | self.use_a_single_photo_at_a_time = use_a_single_photo_at_a_time 26 | 27 | self.initUI() 28 | 29 | def initUI(self): 30 | self.setWindowTitle('Screenshot Viewer') 31 | self.layout = QtWidgets.QVBoxLayout() 32 | 33 | self.label = QtWidgets.QLabel(self) 34 | self.pixmap = QtGui.QPixmap(self.screenshot) 35 | self.label.setPixmap(self.pixmap) 36 | self.layout.addWidget(self.label) 37 | 38 | self.ok_button = QtWidgets.QPushButton('OK') 39 | self.ok_button.clicked.connect(self.save_and_close) 40 | self.layout.addWidget(self.ok_button) 41 | 42 | self.setLayout(self.layout) 43 | 44 | def save_and_close(self): 45 | self.screenshot.save(self.fn_view) 46 | self.screenshot.save(self.fn) 47 | self.client.discussion.image_files.append(self.fn) 48 | if self.use_a_single_photo_at_a_time: 49 | self.client.discussion.image_files = [self.client.discussion.image_files[-1]] 50 | 51 | self.close() 52 | 53 | 54 | screenshot = pyautogui.screenshot() 55 | view_image = client.discussion.discussion_folder / "view_images" 56 | image = client.discussion.discussion_folder / "images" 57 | index = find_first_available_file_index(view_image, "screen_shot_", ".png") 58 | fn_view = view_image / f"screen_shot_{index}.png" 59 | fn = image / f"screen_shot_{index}.png" 60 | 61 | if use_ui: 62 | app = QtWidgets.QApplication(sys.argv) 63 | window = ScreenshotWindow(client, screenshot, fn_view, fn, use_a_single_photo_at_a_time) 64 | window.show() 65 | app.exec_() 66 | return f'' 67 | else: 68 | screenshot.save(fn_view) 69 | screenshot.save(fn) 70 | client.discussion.image_files.append(fn) 71 | if use_a_single_photo_at_a_time: 72 | client.discussion.image_files = [client.discussion.image_files[-1]] 73 | 74 | return f'' 75 | 76 | def take_screenshot_function(client, use_ui=True, use_a_single_photo_at_a_time= True): 77 | return { 78 | "function_name": "take_screenshot", 79 | "function": partial(take_screenshot, client=client, use_ui = use_ui, use_a_single_photo_at_a_time= use_a_single_photo_at_a_time), 80 | "function_description": "Takes a screenshot of the current screen.", 81 | "function_parameters": [] 82 | } -------------------------------------------------------------------------------- /lollms/functions/timers.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: set_timer_with_alert.py 3 | # Author: Saif (ParisNeo) 4 | # Description: This function sets a non-blocking timer that shows a PyQt window with a message and makes noise after a specified duration. It works on any operating system by using the pyautogui library for the alert sound. 5 | 6 | # Here you need to import any necessary imports depending on the function requested by the user 7 | # example import math 8 | 9 | # Partial is useful if we need to preset some parameters 10 | from functools import partial 11 | 12 | # It is advised to import typing elements 13 | from typing import Any, Dict 14 | 15 | # Import PackageManager if there are potential libraries that need to be installed 16 | from lollms.utilities import PackageManager 17 | 18 | # ascii_colors offers advanced console coloring and bug tracing 19 | from ascii_colors import trace_exception 20 | 21 | # Here is an example of how we install a non installed library using PackageManager 22 | import pipmaster as pm 23 | # now we can import the libraries 24 | import threading 25 | import time 26 | import sys 27 | 28 | # here is the core of the function to be built 29 | def set_timer_with_alert(duration: int, message: str) -> str: 30 | """ 31 | Sets a non-blocking timer that shows a PyQt window with a message and makes noise after a specified duration. 32 | 33 | Parameters: 34 | duration (int): The duration for the timer in seconds. 35 | message (str): The message to be displayed in the alert window. 36 | 37 | Returns: 38 | str: A success message indicating the timer has been set. 39 | """ 40 | if not pm.is_installed("pyautogui"): 41 | pm.install("pyautogui") 42 | import pyautogui 43 | 44 | def timer_callback(): 45 | try: 46 | time.sleep(duration) 47 | pyautogui.alert(text=message, title="Timer Alert", button='OK') 48 | pyautogui.beep() 49 | except Exception as e: 50 | return trace_exception(e) 51 | 52 | try: 53 | # Start the timer in a new thread to make it non-blocking 54 | timer_thread = threading.Thread(target=timer_callback) 55 | timer_thread.start() 56 | 57 | # Return a success message 58 | return f"Timer set for {duration} seconds with message '{message}'." 59 | except Exception as e: 60 | return trace_exception(e) 61 | 62 | # Here is the metadata function that should have the name in format function_name_function 63 | def set_timer_with_alert_function() -> Dict[str, Any]: 64 | return { 65 | "function_name": "set_timer_with_alert", # The function name in string 66 | "function": set_timer_with_alert, # The function to be called 67 | "function_description": "Sets a non-blocking timer that shows a PyQt window with a message and makes noise after a specified duration.", # Description of the function 68 | "function_parameters": [{"name": "duration", "type": "int"}, {"name": "message", "type": "str"}] # The set of parameters 69 | } 70 | -------------------------------------------------------------------------------- /lollms/functions/tts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/tts/__init__.py -------------------------------------------------------------------------------- /lollms/functions/tts/read_text.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | 3 | # Import necessary modules 4 | from pathlib import Path 5 | from functools import partial 6 | from typing import Union 7 | from lollms.utilities import PackageManager 8 | from lollms.personality import APScript 9 | from lollms.tts import LollmsTTS 10 | from ascii_colors import trace_exception 11 | 12 | # Here is the core of the function to be built 13 | def read_text(text: str, tts_module:LollmsTTS, llm:APScript) -> str: 14 | """ 15 | This function takes a TTS module and a file path as input, reads the text from the file, 16 | and uses the TTS module to generate audio from the text. 17 | 18 | Parameters: 19 | tts_module: The text-to-speech module with a method tts_audio. 20 | text: The text to be read. 21 | 22 | Returns: 23 | str: The path to the generated audio file. 24 | """ 25 | try: 26 | # Generate audio from the text 27 | audio_file_path = tts_module.tts_audio(text) 28 | llm.add_chunk_to_message_content(text) 29 | llm.new_message("") 30 | 31 | # Return the path to the generated audio file 32 | return "Reading text:\n"+text 33 | except Exception as e: 34 | trace_exception(e) 35 | return str(e) 36 | 37 | 38 | # Metadata function 39 | def read_text_function(tts_module:LollmsTTS): 40 | return { 41 | "function_name": "read_text_from_file", # The function name in string 42 | "function": partial(read_text, tts_module=tts_module), # The function to be called 43 | "function_description": "Reads text from a file and uses a TTS module to generate audio from the text.", # Description of the function 44 | "function_parameters": [ 45 | {"name":"text","type":"str","description":"Th text to generate the audio from"} 46 | ] # The set of parameters 47 | } 48 | -------------------------------------------------------------------------------- /lollms/functions/tts/read_text_from_file.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | 3 | # Import necessary modules 4 | from pathlib import Path 5 | from functools import partial 6 | from typing import Union 7 | from lollms.utilities import PackageManager 8 | from lollms.personality import APScript 9 | from lollms.tts import LollmsTTS 10 | from safe_store import parse_document 11 | from ascii_colors import trace_exception 12 | 13 | # Here is the core of the function to be built 14 | def read_text_from_file(file_path: Union[Path, str], tts_module:LollmsTTS, llm:APScript) -> str: 15 | """ 16 | This function takes a TTS module and a file path as input, reads the text from the file, 17 | and uses the TTS module to generate audio from the text. 18 | 19 | Parameters: 20 | tts_module: The text-to-speech module with a method tts_audio. 21 | file_path: The path to the text file containing the text to be read. 22 | 23 | Returns: 24 | str: The path to the generated audio file. 25 | """ 26 | try: 27 | # Ensure file_path is of type Path 28 | file_path = Path(file_path) 29 | 30 | # Read the text from the file 31 | text = parse_document(file_path) 32 | 33 | # Generate audio from the text 34 | audio_file_path = tts_module.tts_audio(text,use_threading=True) 35 | llm.set_message_content(text) 36 | 37 | # Return the path to the generated audio file 38 | return str(audio_file_path) 39 | except Exception as e: 40 | return trace_exception(e) 41 | 42 | 43 | # Metadata function 44 | def read_text_from_file_function(file_path:str,tts_module:LollmsTTS, llm:APScript): 45 | return { 46 | "function_name": "read_text_from_file", # The function name in string 47 | "function": partial(read_text_from_file, file_path=file_path, tts_module=tts_module, llm=llm), # The function to be called 48 | "function_description": "Reads text from the current file and uses a TTS module to generate audio from the text.", # Description of the function 49 | "function_parameters": [] # The set of parameters 50 | } 51 | -------------------------------------------------------------------------------- /lollms/functions/web/__init__.py: -------------------------------------------------------------------------------- 1 | from lollms.functions.web.google_search import google_search, google_search_function -------------------------------------------------------------------------------- /lollms/functions/web/google_search.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | 3 | # Import necessary libraries 4 | from functools import partial 5 | from typing import List 6 | from lollms.utilities import PackageManager 7 | from ascii_colors import trace_exception 8 | 9 | # Ensure the webbrowser package is available 10 | if not PackageManager.check_package_installed("webbrowser"): 11 | PackageManager.install_package("webbrowser") 12 | 13 | # Import the webbrowser library 14 | import webbrowser 15 | 16 | # Define the function to perform a Google search 17 | def google_search(query: str) -> str: 18 | """ 19 | Perform a Google search using the default web browser. 20 | 21 | Parameters: 22 | - query (str): The search query. 23 | 24 | Returns: 25 | - str: A message indicating the search was performed. 26 | """ 27 | try: 28 | # Construct the Google search URL 29 | search_url = f"https://www.google.com/search?q={query}" 30 | 31 | # Open the search URL in the default web browser 32 | webbrowser.open(search_url) 33 | 34 | # Return a success message 35 | return f"Performed Google search for query: {query}" 36 | except Exception as e: 37 | return trace_exception(e) 38 | 39 | # Define the metadata function 40 | def google_search_function(): 41 | return { 42 | "function_name": "google_search", # The function name in string 43 | "function": google_search, # The function to be called 44 | "function_description": "Performs a Google search using the default web browser.", # Description of the function 45 | "function_parameters": [{"name": "query", "type": "str"}] # The set of parameters 46 | } 47 | -------------------------------------------------------------------------------- /lollms/functions/writing/create_text_file.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: create_file.py 3 | # Author: ParisNeo 4 | # Description: This function creates a text file with specified content in the 'text_data' subfolder. 5 | 6 | # Import necessary modules 7 | from functools import partial 8 | from typing import Union 9 | from pathlib import Path 10 | from lollms.utilities import PackageManager 11 | from lollms.client_session import Client 12 | from ascii_colors import trace_exception 13 | 14 | # Core function to create a file 15 | def create_file(file_name: str, content: str, client:Client) -> Union[str, None]: 16 | """ 17 | Creates a text file with the specified content in the 'text_data' subfolder. 18 | 19 | Parameters: 20 | file_name (str): The name of the file to be created. 21 | content (str): The content to be written into the file. 22 | 23 | Returns: 24 | Union[str, None]: Returns None if successful, otherwise returns the exception message. 25 | """ 26 | try: 27 | # Define the path to the 'text_data' subfolder 28 | 29 | # Define the full file path 30 | file_path = client.discussion_path/ 'text_data' / file_name 31 | 32 | # Write the content to the file 33 | file_path.write_text(content, encoding='utf-8') 34 | 35 | # Return None if successful 36 | return None 37 | except Exception as e: 38 | return trace_exception(e) 39 | 40 | # Metadata function 41 | def create_file_function(client:Client): 42 | return { 43 | "function_name": "create_file", # The function name in string 44 | "function": partial(create_file, client=client), # The function to be called 45 | "function_description": "Creates a text file with specified content in the 'text_data' subfolder.", # Description of the function 46 | "function_parameters": [ 47 | {"name": "file_name", "type": "str"}, 48 | {"name": "content", "type": "str"} 49 | ] # The set of parameters 50 | } 51 | -------------------------------------------------------------------------------- /lollms/functions/youtube/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/youtube/__init__.py -------------------------------------------------------------------------------- /lollms/functions/youtube/download_transcript.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: download_youtube_transcript.py 3 | # Author: ParisNeo 4 | # Description: This function goes online to YouTube and downloads the transcript from any video 5 | 6 | # Importing necessary libraries 7 | from functools import partial 8 | from typing import List 9 | from lollms.utilities import PackageManager 10 | from ascii_colors import trace_exception, ASCIIColors 11 | from typing import Any 12 | 13 | # Installing necessary packages 14 | if not PackageManager.check_package_installed("youtube_transcript_api"): 15 | PackageManager.install_package("youtube-transcript-api") 16 | 17 | # Importing the package after installation 18 | from youtube_transcript_api import YouTubeTranscriptApi 19 | 20 | def download_youtube_transcript(video_id: str, language_code: str = 'en') -> str: 21 | """ 22 | This function downloads the transcript of a YouTube video given its video ID. 23 | 24 | Parameters: 25 | video_id (str): The ID of the YouTube video. 26 | languages (tuple): A list of languages to extract. 27 | 28 | Returns: 29 | str: The transcript of the video. 30 | """ 31 | try: 32 | # Fetching the transcript 33 | transcript = YouTubeTranscriptApi.get_transcript(video_id, (language_code,)) 34 | 35 | # Combining the transcript into a single string 36 | transcript_text = " ".join([entry['text'] for entry in transcript]) 37 | ASCIIColors.magenta("---- Transcript ----") 38 | ASCIIColors.magenta(transcript_text) 39 | ASCIIColors.magenta("----") 40 | return transcript_text 41 | except Exception as e: 42 | return trace_exception(e) 43 | 44 | def download_youtube_transcript_function(): 45 | return { 46 | "function_name": "download_youtube_transcript", 47 | "function": download_youtube_transcript, 48 | "function_description": "This function goes online to YouTube and downloads the transcript from any video.", 49 | "function_parameters": [{"name": "video_id", "type": "str"},{"name": "language_code", "type": "str"}] 50 | } 51 | -------------------------------------------------------------------------------- /lollms/functions/youtube/download_transcript_by_channel.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | # File Name: download_channel_transcripts.py 3 | # Author: ParisNeo 4 | # Description: This function takes a YouTube channel name, scans all their videos using web scraping, and downloads the transcripts. Each transcript is saved in a folder as a text file. 5 | 6 | # Importing necessary libraries 7 | from functools import partial 8 | from typing import List 9 | from lollms.utilities import PackageManager 10 | from ascii_colors import trace_exception 11 | import pathlib 12 | import requests 13 | from bs4 import BeautifulSoup 14 | 15 | # Installing necessary packages 16 | if not PackageManager.check_package_installed("youtube_transcript_api"): 17 | PackageManager.install_package("youtube-transcript-api") 18 | 19 | # Importing the package after installation 20 | from youtube_transcript_api import YouTubeTranscriptApi 21 | 22 | def download_channel_transcripts(channel_url: str, output_folder: str) -> str: 23 | """ 24 | This function takes a YouTube channel URL, scans all their videos using web scraping, and downloads the transcripts. 25 | Each transcript is saved in a folder as a text file. 26 | 27 | Parameters: 28 | channel_url (str): The URL of the YouTube channel. 29 | output_folder (str): The folder where transcripts will be saved. 30 | 31 | Returns: 32 | str: A message indicating the status of the download process. 33 | """ 34 | try: 35 | if output_folder=="": 36 | return "Please set the transcription output path in lollmz personality sdettings" 37 | # Create output folder if it doesn't exist 38 | output_folder_path = pathlib.Path(output_folder) 39 | output_folder_path.mkdir(parents=True, exist_ok=True) 40 | 41 | # Get channel page content 42 | response = requests.get(channel_url) 43 | response.raise_for_status() 44 | soup = BeautifulSoup(response.content, "html.parser") 45 | 46 | # Find all video links 47 | video_links = soup.find_all("a", href=True) 48 | video_ids = [link['href'].split('v=')[1] for link in video_links if "watch?v=" in link['href']] 49 | 50 | # Remove duplicates 51 | video_ids = list(set(video_ids)) 52 | 53 | # Download transcripts and save to files 54 | for video_id in video_ids: 55 | try: 56 | transcript = YouTubeTranscriptApi.get_transcript(video_id) 57 | transcript_text = " ".join([entry['text'] for entry in transcript]) 58 | 59 | output_file_path = output_folder_path / f"{video_id}.txt" 60 | output_file_path.write_text(transcript_text, encoding='utf-8') 61 | except Exception as e: 62 | trace_exception(e) 63 | 64 | return "Transcripts downloaded successfully!" 65 | except Exception as e: 66 | return trace_exception(e) 67 | 68 | def download_channel_transcripts_function(output_folder:str): 69 | return { 70 | "function_name": "download_channel_transcripts", 71 | "function": partial(download_channel_transcripts, output_folder=output_folder), 72 | "function_description": "This function takes a YouTube channel name, scans all their videos using web scraping, and downloads the transcripts. Each transcript is saved in a folder as a text file.", 73 | "function_parameters": [ 74 | {"name": "channel_url", "type": "str"}, 75 | ] 76 | } 77 | -------------------------------------------------------------------------------- /lollms/functions/youtube/search.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | 3 | # Partial is useful if we need to preset some parameters 4 | from functools import partial 5 | 6 | # It is advised to import typing elements 7 | from typing import List 8 | 9 | # Import PackageManager if there are potential libraries that need to be installed 10 | from lollms.utilities import PackageManager 11 | 12 | # ascii_colors offers advanced console coloring and bug tracing 13 | from ascii_colors import trace_exception 14 | 15 | # Here is an example of how we install a non installed library using PackageManager 16 | if not PackageManager.check_package_installed("pyautogui"): 17 | PackageManager.install_package("pyautogui") 18 | if not PackageManager.check_package_installed("webbrowser"): 19 | PackageManager.install_package("webbrowser") 20 | if not PackageManager.check_package_installed("time"): 21 | PackageManager.install_package("time") 22 | if not PackageManager.check_package_installed("os"): 23 | PackageManager.install_package("os") 24 | 25 | # now we can import the libraries 26 | import pyautogui 27 | import webbrowser 28 | import time 29 | import os 30 | 31 | # Function to open YouTube, search for a specific video, and play the first one 32 | def search_youtube(video_title: str = "lollms paris neo") -> str: 33 | """ 34 | Opens YouTube, searches for a specific video, and plays the first one in the list. 35 | 36 | Parameters: 37 | video_title (str): The title of the video to search for. 38 | 39 | Returns: 40 | str: Success or error message. 41 | """ 42 | try: 43 | # Open YouTube 44 | webbrowser.open("https://www.youtube.com") 45 | time.sleep(5) # Wait for the browser to open YouTube 46 | 47 | # Click on the search bar (searching for the element named 'search_query') 48 | script_dir = os.path.dirname(__file__) 49 | search_query_path = os.path.join(script_dir, 'search_query.png') 50 | search_bar_position = pyautogui.locateCenterOnScreen(search_query_path, confidence=0.8) 51 | if search_bar_position: 52 | pyautogui.click(search_bar_position) 53 | else: 54 | return "Search bar not found on the screen." 55 | 56 | # Type the video title and press Enter 57 | pyautogui.write(video_title, interval=0.1) 58 | pyautogui.press('enter') 59 | time.sleep(5) # Wait for the search results to load 60 | 61 | return "Video is playing." 62 | 63 | except Exception as e: 64 | return trace_exception(e) 65 | 66 | 67 | # Metadata function 68 | def search_youtube_function(): 69 | return { 70 | "function_name": "search_youtube", # The function name in string 71 | "function": search_youtube, # The function to be called 72 | "function_description": "Opens YouTube, searches for a specific video, and plays the first one in the list.", # Description 73 | "function_parameters": [{"name": "video_title", "type": "str"}] # Parameters 74 | } 75 | 76 | # Add the if __name__ statement for testing 77 | if __name__ == "__main__": 78 | video_title = "lollms paris neo" 79 | result = search_youtube(video_title) 80 | print(result) 81 | -------------------------------------------------------------------------------- /lollms/functions/youtube/search_and_show.py: -------------------------------------------------------------------------------- 1 | # Lollms function call definition file 2 | 3 | # Partial is useful if we need to preset some parameters 4 | from functools import partial 5 | 6 | # It is advised to import typing elements 7 | from typing import List 8 | 9 | # Import PackageManager if there are potential libraries that need to be installed 10 | from lollms.utilities import PackageManager 11 | 12 | # ascii_colors offers advanced console coloring and bug tracing 13 | from ascii_colors import trace_exception 14 | 15 | # Here is an example of how we install a non installed library using PackageManager 16 | if not PackageManager.check_package_installed("pyautogui"): 17 | PackageManager.install_package("pyautogui") 18 | if not PackageManager.check_package_installed("webbrowser"): 19 | PackageManager.install_package("webbrowser") 20 | if not PackageManager.check_package_installed("time"): 21 | PackageManager.install_package("time") 22 | if not PackageManager.check_package_installed("os"): 23 | PackageManager.install_package("os") 24 | 25 | # now we can import the libraries 26 | import pyautogui 27 | import webbrowser 28 | import time 29 | import os 30 | 31 | # Function to open YouTube, search for a specific video, and play the first one 32 | def search_youtube_and_play(video_title: str = "lollms paris neo") -> str: 33 | """ 34 | Opens YouTube, searches for a specific video, and plays the first one in the list. 35 | 36 | Parameters: 37 | video_title (str): The title of the video to search for. 38 | 39 | Returns: 40 | str: Success or error message. 41 | """ 42 | try: 43 | # Open YouTube 44 | webbrowser.open("https://www.youtube.com") 45 | time.sleep(5) # Wait for the browser to open YouTube 46 | 47 | # Click on the search bar (searching for the element named 'search_query') 48 | script_dir = os.path.dirname(__file__) 49 | search_query_path = os.path.join(script_dir, 'search_query.png') 50 | search_bar_position = pyautogui.locateCenterOnScreen(search_query_path, confidence=0.8) 51 | if search_bar_position: 52 | pyautogui.click(search_bar_position) 53 | else: 54 | return "Search bar not found on the screen." 55 | 56 | # Type the video title and press Enter 57 | pyautogui.write(video_title, interval=0.1) 58 | pyautogui.press('enter') 59 | time.sleep(5) # Wait for the search results to load 60 | 61 | # Click on the first video in the search results (assuming it's in a consistent position) 62 | pyautogui.click(500, 400) # Adjust the coordinates as needed 63 | return "Video is playing." 64 | 65 | except Exception as e: 66 | return trace_exception(e) 67 | 68 | 69 | # Metadata function 70 | def search_youtube_and_play_function(): 71 | return { 72 | "function_name": "search_youtube_and_play", # The function name in string 73 | "function": search_youtube_and_play, # The function to be called 74 | "function_description": "Opens YouTube, searches for a specific video, and plays the first one in the list.", # Description 75 | "function_parameters": [{"name": "video_title", "type": "str"}] # Parameters 76 | } 77 | 78 | # Add the if __name__ statement for testing 79 | if __name__ == "__main__": 80 | video_title = "lollms paris neo" 81 | result = search_youtube_and_play(video_title) 82 | print(result) 83 | -------------------------------------------------------------------------------- /lollms/functions/youtube/search_query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParisNeo/lollms/067d4893b64d4945fd3e0c6d2370494043979a67/lollms/functions/youtube/search_query.png -------------------------------------------------------------------------------- /lollms/generation.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from ascii_colors import ASCIIColors 3 | class ROLE_CHANGE_DECISION(Enum): 4 | """Roles change detection.""" 5 | 6 | MOVE_ON = 0 7 | """The received chunk is a normal chunk so move on.""" 8 | 9 | PROGRESSING = 1 10 | """Started receiving Role change.""" 11 | 12 | ROLE_CHANGED = 2 13 | """Role change detected.""" 14 | 15 | FALSE_ALERT = 3 16 | """False alert (didn't detect the full role change).""" 17 | 18 | class ROLE_CHANGE_OURTPUT: 19 | status:ROLE_CHANGE_DECISION 20 | value:str="" 21 | def __init__(self, status, value='') -> None: 22 | self.status = status 23 | self.value = value 24 | 25 | class RECEPTION_MANAGER: 26 | done:bool=False 27 | chunk:str="" 28 | new_role:str="" 29 | reception_buffer:str="" 30 | def new_chunk(self, chunk): 31 | self.chunk = chunk 32 | if chunk=="!" and self.new_role == "": 33 | self.new_role+=chunk 34 | return ROLE_CHANGE_OURTPUT(ROLE_CHANGE_DECISION.PROGRESSING) 35 | elif self.new_role != "": 36 | if self.new_role=="!" and chunk=="@": 37 | self.new_role+=chunk 38 | return ROLE_CHANGE_OURTPUT(ROLE_CHANGE_DECISION.PROGRESSING) 39 | elif self.new_role=="!@" and chunk==">": 40 | self.new_role="" 41 | self.done=True 42 | ASCIIColors.yellow("Delected end of sentence") 43 | return ROLE_CHANGE_OURTPUT(ROLE_CHANGE_DECISION.ROLE_CHANGED, self.reception_buffer) 44 | else: 45 | rc = ROLE_CHANGE_OURTPUT(ROLE_CHANGE_DECISION.FALSE_ALERT, self.reception_buffer) 46 | self.reception_buffer += self.new_role 47 | return rc 48 | self.reception_buffer += chunk 49 | return ROLE_CHANGE_OURTPUT(ROLE_CHANGE_DECISION.MOVE_ON) 50 | 51 | -------------------------------------------------------------------------------- /lollms/helpers.py: -------------------------------------------------------------------------------- 1 | import traceback 2 | from ascii_colors import ASCIIColors 3 | from enum import Enum 4 | from urllib.parse import urlparse 5 | import re # Optional: for more complex validation if needed 6 | 7 | 8 | def is_valid_url(url_string: str) -> bool: 9 | """ 10 | Checks if the given string represents a potentially valid HTTP or HTTPS URL. 11 | 12 | This performs a basic structural check using urllib.parse and ensures 13 | the scheme and network location are present. It doesn't guarantee 14 | the URL is reachable or exists. 15 | 16 | Args: 17 | url_string: The string to validate. 18 | 19 | Returns: 20 | True if the string appears to be a valid HTTP/HTTPS URL, False otherwise. 21 | """ 22 | if not isinstance(url_string, str) or not url_string: 23 | return False 24 | try: 25 | # Parse the URL string 26 | parsed_url = urlparse(url_string) 27 | 28 | # Check for essential components: 29 | # 1. Scheme must be 'http' or 'https'. 30 | # 2. Network location (domain name or IP address) must be present. 31 | if parsed_url.scheme in ['http', 'https'] and parsed_url.netloc: 32 | # Optional additional check: ensure netloc looks like a domain/IP 33 | # This regex is basic and might not cover all edge cases (like IDNs) 34 | # but helps filter out things like 'http:///' 35 | # netloc_pattern = r"^[a-zA-Z0-9.-]+(?::\d+)?$" # Basic domain/IP + optional port 36 | # if re.match(netloc_pattern, parsed_url.netloc): 37 | # return True 38 | return True # Keep it simple for now, scheme + netloc is usually sufficient 39 | 40 | return False 41 | except ValueError: 42 | # urlparse might raise ValueError for severely malformed strings 43 | # (though it's often lenient) 44 | return False 45 | except Exception as e: 46 | # Catch any unexpected errors during parsing 47 | # You might want to log this if it happens unexpectedly 48 | # print(f"Unexpected error validating URL '{url_string}': {e}") 49 | trace_exception(e) # Use existing helper if available 50 | return False 51 | 52 | 53 | def get_trace_exception(ex): 54 | """ 55 | Traces an exception (useful for debug) and returns the full trace of the exception 56 | """ 57 | # Catch the exception and get the traceback as a list of strings 58 | traceback_lines = traceback.format_exception(type(ex), ex, ex.__traceback__) 59 | 60 | # Join the traceback lines into a single string 61 | traceback_text = ''.join(traceback_lines) 62 | return traceback_text 63 | 64 | def trace_exception(ex): 65 | """ 66 | Traces an exception (useful for debug) 67 | """ 68 | ASCIIColors.error(get_trace_exception(ex)) 69 | 70 | -------------------------------------------------------------------------------- /lollms/image_gen_modules/blip_vqa.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import requests 3 | from PIL import Image 4 | from transformers import BlipProcessor, BlipForQuestionAnswering 5 | 6 | class BlipInterrogatorStorer(): 7 | def __init__(self, vqa_model_name="Salesforce/blip-vqa-base"): 8 | self.vqa_model_name = vqa_model_name 9 | self.processor = BlipProcessor.from_pretrained(vqa_model_name) 10 | self.model = BlipForQuestionAnswering.from_pretrained(vqa_model_name, torch_dtype=torch.float16).to("cuda") 11 | 12 | def interrogate(self, raw_image:Image, question:str, max_length:int=256): 13 | inputs = self.processor(raw_image, question, return_tensors="pt").to("cuda", torch.float16) 14 | out = self.model.generate(**inputs, max_length=max_length) 15 | return self.processor.decode(out[0], skip_special_tokens=True) 16 | 17 | -------------------------------------------------------------------------------- /lollms/server/.gitignore: -------------------------------------------------------------------------------- 1 | elf_global_paths_cfg.yaml -------------------------------------------------------------------------------- /lollms/server/configs/.gitignore: -------------------------------------------------------------------------------- 1 | local_config.yaml -------------------------------------------------------------------------------- /lollms/server/elf.py: -------------------------------------------------------------------------------- 1 | """ 2 | File: lollms_web_ui.py 3 | Author: ParisNeo 4 | Description: Singleton class for the LoLLMS web UI. 5 | 6 | This file is the entry point to the webui. 7 | """ 8 | 9 | from fastapi import FastAPI 10 | from fastapi.staticfiles import StaticFiles 11 | from lollms.app import LollmsApplication 12 | from lollms.paths import LollmsPaths 13 | from lollms.main_config import LOLLMSConfig 14 | from lollms.server.elf_server import LOLLMSElfServer 15 | from pathlib import Path 16 | from ascii_colors import ASCIIColors 17 | import socketio 18 | import uvicorn 19 | import argparse 20 | from socketio import ASGIApp 21 | 22 | 23 | sio = socketio.AsyncServer(async_mode="asgi") 24 | app = FastAPI(title="LoLLMS", description="This is the LoLLMS-Elf API documentation") 25 | 26 | def main(): 27 | # Parsong parameters 28 | parser = argparse.ArgumentParser(description="Start the chatbot FastAPI app.") 29 | 30 | parser.add_argument( 31 | "--host", type=str, default=None, help="the hostname to listen on" 32 | ) 33 | parser.add_argument("--port", type=int, default=None, help="the port to listen on") 34 | 35 | args = parser.parse_args() 36 | root_path = Path(__file__).parent 37 | lollms_paths = LollmsPaths.find_paths(tool_prefix="elf_",force_local=True, custom_default_cfg_path="configs/config.yaml") 38 | config = LOLLMSConfig.autoload(lollms_paths) 39 | if args.host: 40 | config.host=args.host 41 | if args.port: 42 | config.port=args.port 43 | 44 | LOLLMSElfServer.build_instance(config=config, lollms_paths=lollms_paths, socketio=sio) 45 | from lollms.server.endpoints.lollms_files_server import router as lollms_binding_files_server_router 46 | from lollms.server.endpoints.lollms_infos import router as lollms_infos_router 47 | from lollms.server.endpoints.lollms_hardware_infos import router as lollms_hardware_infos_router 48 | from lollms.server.endpoints.lollms_binding_infos import router as lollms_binding_infos_router 49 | from lollms.server.endpoints.lollms_models_infos import router as lollms_models_infos_router 50 | from lollms.server.endpoints.lollms_personalities_infos import router as lollms_personalities_infos_router 51 | from lollms.server.endpoints.lollms_file_system import router as lollms_file_system_router 52 | 53 | from lollms.server.endpoints.lollms_configuration_infos import router as lollms_configuration_infos_router 54 | 55 | 56 | 57 | from lollms.server.endpoints.lollms_generator import router as lollms_generator_router 58 | 59 | 60 | from lollms.server.events.lollms_generation_events import add_events as lollms_generation_events_add 61 | from lollms.server.events.lollms_personality_events import add_events as lollms_personality_events_add 62 | from lollms.server.events.lollms_model_events import add_events as lollms_model_events_add 63 | #from lollms.server.events.lollms_rag_events import add_events as lollms_rag_events_add 64 | 65 | 66 | app.include_router(lollms_binding_files_server_router) 67 | app.include_router(lollms_infos_router) 68 | app.include_router(lollms_hardware_infos_router) 69 | app.include_router(lollms_binding_infos_router) 70 | app.include_router(lollms_models_infos_router) 71 | app.include_router(lollms_personalities_infos_router) 72 | 73 | 74 | app.include_router(lollms_generator_router) 75 | 76 | app.include_router(lollms_configuration_infos_router) 77 | app.include_router(lollms_file_system_router) 78 | 79 | 80 | lollms_generation_events_add(sio) 81 | lollms_personality_events_add(sio) 82 | lollms_model_events_add(sio) 83 | #lollms_rag_events_add(sio) 84 | 85 | app = ASGIApp(socketio_server=sio, other_asgi_app=app) 86 | 87 | 88 | uvicorn.run(app, host=config.host, port=config.port) 89 | 90 | if __name__ == "__main__": 91 | main() -------------------------------------------------------------------------------- /lollms/server/endpoints/docs/lollms_anything_to_markdown/DOC.md: -------------------------------------------------------------------------------- 1 | # LoLLMs Anything to Markdown Library 2 | 3 | ## Overview 4 | JavaScript library to convert various file types to Markdown. 5 | 6 | ## Key Features 7 | - Supports: txt, docx, pdf, pptx, and more 8 | - Asynchronous processing 9 | - Object-oriented design 10 | 11 | ## Import 12 | ```html 13 | 14 | 15 | ``` 16 | 17 | ## Core Class: LollmsFileLoader 18 | 19 | ### Methods 20 | - `loadFile(file)`: Main method to process files 21 | - `readTextFile(file)`, `readDocxFile(file)`, `readPdfFile(file)`, `readPptxFile(file)`: Type-specific readers 22 | - `convertToMarkdown(content, fileExtension)`: Converts content to Markdown 23 | 24 | ## Usage 25 | ```javascript 26 | const lollmsFileLoader = new LollmsFileLoader(); 27 | const markdown = await lollmsFileLoader.loadFile(file); 28 | ``` 29 | 30 | ## Extensibility 31 | - Add new file types by creating reader methods 32 | - Enhance Markdown conversion logic 33 | - Implement caching or post-processing 34 | 35 | ## Error Handling 36 | Uses Promise-based approach. Wrap `loadFile` in try-catch. 37 | 38 | ## Dependencies 39 | Requires external libraries for DOCX, PDF, and PPTX processing. 40 | 41 | This concise documentation provides the essential information for an LLM-based developer to understand and work with the library, while saving context tokens. -------------------------------------------------------------------------------- /lollms/server/endpoints/docs/lollms_anything_to_markdown/README.md: -------------------------------------------------------------------------------- 1 | # LoLLMs Anything to Markdown Library 2 | 3 | ## Overview 4 | JavaScript library to convert various file types to Markdown. 5 | 6 | ## Key Features 7 | - Supports: txt, docx, pdf, pptx, and more 8 | - Asynchronous processing 9 | - Object-oriented design 10 | 11 | ## Import 12 | ```html 13 | 14 | 15 | 16 | ``` 17 | 18 | ## Core Class: LollmsFileLoader 19 | 20 | ### Methods 21 | - `loadFile(file)`: Main method to process files 22 | - `readTextFile(file)`, `readDocxFile(file)`, `readPdfFile(file)`, `readPptxFile(file)`: Type-specific readers 23 | - `convertToMarkdown(content, fileExtension)`: Converts content to Markdown 24 | 25 | ## Usage 26 | ```javascript 27 | const lollmsFileLoader = new LollmsFileLoader(); 28 | const markdown = await lollmsFileLoader.loadFile(file); 29 | ``` 30 | 31 | ## Extensibility 32 | - Add new file types by creating reader methods 33 | - Enhance Markdown conversion logic 34 | - Implement caching or post-processing 35 | 36 | ## Error Handling 37 | Uses Promise-based approach. Wrap `loadFile` in try-catch. 38 | 39 | ## Dependencies 40 | Requires external libraries for DOCX, PDF, and PPTX processing. 41 | 42 | This concise documentation provides the essential information for an LLM-based developer to understand and work with the library, while saving context tokens. 43 | -------------------------------------------------------------------------------- /lollms/server/endpoints/docs/lollms_flow/DOC.md: -------------------------------------------------------------------------------- 1 | 2 | # Lollms Flow Library - Quick Reference 3 | 4 | ## Core Classes 5 | 6 | 1. `WorkflowNode`: Represents a single node in the workflow. 7 | - Constructor: `new WorkflowNode(id, name, inputs, outputs, operation, options, x, y)` 8 | - Key methods: `connect()`, `execute()`, `toJSON()`, `fromJSON()` 9 | 10 | 2. `Workflow`: Manages the entire workflow. 11 | - Key methods: `addNode()`, `connectNodes()`, `execute()`, `toJSON()`, `fromJSON()` 12 | 13 | 3. `WorkflowVisualizer`: Handles visualization using SVG. 14 | - Constructor: `new WorkflowVisualizer(containerId)` 15 | - Key methods: `addNode()`, `connectNodes()`, `execute()`, `saveToJSON()`, `loadFromJSON()` 16 | 17 | ## Basic Usage 18 | 19 | 1. Create a visualizer: 20 | ```javascript 21 | const visualizer = new WorkflowVisualizer('container-id'); 22 | ``` 23 | 24 | 2. Define node operations: 25 | ```javascript 26 | const nodeOperations = { 27 | 'OperationName': (inputs, options) => ({ output: result }) 28 | }; 29 | ``` 30 | 31 | 3. Create and add nodes: 32 | ```javascript 33 | const node = new WorkflowNode(id, name, inputs, outputs, operation, options); 34 | visualizer.addNode(node); 35 | ``` 36 | 37 | 4. Connect nodes: 38 | ```javascript 39 | visualizer.connectNodes(sourceId, sourceOutput, targetId, targetInput); 40 | ``` 41 | 42 | 5. Execute workflow: 43 | ```javascript 44 | const results = visualizer.execute(); 45 | ``` 46 | 47 | 6. Save/Load workflow: 48 | ```javascript 49 | const json = visualizer.saveToJSON(); 50 | visualizer.loadFromJSON(json, nodeOperations); 51 | ``` 52 | 53 | ## Key Features 54 | 55 | - SVG-based visualization with drag-and-drop 56 | - Interactive socket connections 57 | - Node options (checkbox, radio, select, file, textarea) 58 | - JSON serialization and local storage integration 59 | - Custom node and socket colors 60 | - Event handling for interactivity 61 | 62 | ## Best Practices 63 | 64 | - Use unique node IDs 65 | - Define clear input/output types 66 | - Implement error handling in operations 67 | - Use descriptive names for nodes and sockets 68 | -------------------------------------------------------------------------------- /lollms/server/endpoints/docs/lollms_markdown_renderer/DOC.md: -------------------------------------------------------------------------------- 1 | Certainly! Here's the updated version of the quick guide using `await` for rendering the Markdown content: 2 | 3 | ## MarkdownRenderer Library - Quick Guide 4 | 5 | The `MarkdownRenderer` library is a JavaScript class for converting Markdown content into HTML with features like code highlighting, LaTeX math rendering, and Mermaid diagrams. 6 | 7 | ### Key Features 8 | 9 | 1. **Mermaid Diagrams**: Render diagrams from Markdown code blocks. 10 | 2. **Code Highlighting**: Use Prism.js for syntax highlighting. 11 | 3. **Math Equations**: Support LaTeX-style math equations. 12 | 4. **Tables**: Convert Markdown tables into HTML. 13 | 5. **Text Formatting**: Handle headers, bold, italic, links, lists, blockquotes, and horizontal rules. 14 | 6. **Copy Code**: Enable copying of code blocks with line numbers. 15 | 16 | ### Integration Steps 17 | 18 | Include the following in your HTML file header (this must be added to the html to allow the rendering): 19 | 20 | ```html 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | ``` 42 | 43 | ### Usage 44 | 45 | ```javascript 46 | const mr = new MarkdownRenderer(); 47 | const markdownText = ` 48 | # Sample Markdown 49 | **Bold** text, *italic* text. 50 | 51 | ## Code Block 52 | \`\`\`javascript 53 | console.log('Hello, World!'); 54 | \`\`\` 55 | 56 | ## Mermaid Diagram 57 | \`\`\`mermaid 58 | graph TD; 59 | A-->B; 60 | A-->C; 61 | B-->D; 62 | C-->D; 63 | \`\`\` 64 | 65 | ## Math Equation 66 | $$E = mc^2$$ 67 | 68 | ## Table 69 | | Name | Age | 70 | |-------|-----| 71 | | Alice | 24 | 72 | | Bob | 30 | 73 | `; 74 | const renderedHtml = await mr.renderMarkdown(markdownText); 75 | document.getElementById('markdown-content').innerHTML = renderedHtml; 76 | ``` 77 | 78 | 79 | - **Code Blocks**: Use Prism.js for syntax highlighting by specifying the language (e.g., `javascript`). 80 | - **Mermaid Diagrams**: Use `mermaid` identifier in code blocks. 81 | - **Math Equations**: Use `$...$` for inline and `$$...$$` for block equations. 82 | - **Tables**: Automatically convert Markdown tables to HTML. 83 | -------------------------------------------------------------------------------- /lollms/server/endpoints/docs/lollms_theme/doc.md: -------------------------------------------------------------------------------- 1 | Lollms theme: 2 | 3 | 1. Use Tailwind CSS for styling: 4 | ```html 5 | 6 | ``` 7 | 8 | 2. Implement a gradient background: 9 | ```html 10 | 11 | ``` 12 | 13 | 3. Create a container with responsive padding: 14 | ```html 15 |
16 | ``` 17 | 18 | 4. Style headers with large, bold text in indigo: 19 | ```html 20 |

Chat with PDFs

21 | ``` 22 | 23 | 5. Use white backgrounds with shadow for content areas: 24 | ```html 25 |
26 | ``` 27 | 28 | 6. Style buttons with indigo background and hover effects: 29 | ```html 30 |