Code Monkey home page Code Monkey logo

text-generation-webui-code_syntax_highlight's Introduction

Code Syntax Highlight

An extension for oobabooga's text-generation-webui to highlight code snippets

Note

Versions of text-generation-webui released after the 26th of April 2024 support syntax highlighting of code snippets by default without needing this extension

code_syntax_highlight_extension-oobabooga-text-generation-webui

Features

  • Uses highlight.js with the GitHub theme
  • Supports common programming languages
  • Can also highlight inline code snippets
  • Provides an optional button in each code snippet to copy the code to the clipboard
  • Works in all interface modes: default, notebook, and chat
  • Automatically switches between light and dark themes to match the web UI theme
  • Has a performance mode for minimal CPU usage

Installation

The extension can be installed by cloning this repository inside the ../text-generation-webui/extensions folder:

cd text-generation-webui/extensions
git clone https://github.com/DavG25/text-generation-webui-code_syntax_highlight code_syntax_highlight

It's also possible to install the extension by directly downloading the latest version from the releases page and extracting the ZIP archive inside the ../text-generation-webui/extensions folder


Updates

To check for updates, simply compare the currently installed extension version in the web UI with the latest available version in the releases page

If the available version is higher than the installed one, run the following command:

cd text-generation-webui/extensions
git pull

If the extension was installed by downloading the ZIP archive, delete the currently installed version in the ../text-generation-webui/extensions folder and extract the new version ZIP archive in the same location


Configuration and persistent settings

The extension can be enabled directly in the Interface mode tab inside the web UI once installed

To automatically load the extension when starting the web UI, either specify it in the --extensions command-line flag or add it in the settings.yaml file in the ../text-generation-webui folder:

default_extensions: 
- code_syntax_highlight

For settings to persist over web UI restarts and reloads, add the following lines to the settings.yaml file:

code_syntax_highlight-activate: true
code_syntax_highlight-inline_highlight: false
code_syntax_highlight-copy_button: false
code_syntax_highlight-performance_mode: true

Change the values (true / false) according to the preferred settings

text-generation-webui-code_syntax_highlight's People

Contributors

davg25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

text-generation-webui-code_syntax_highlight's Issues

Hope to have copy code button

Frist of all, thank you very much for this extension.
I would like to ask whether you can add a copy button for each code snippets.
Or can you tell me whether it is doable under the webui's extension structure.

highlighting of code snippets blink while text is generated

Hi there!

Found an issue that makes the highlighting of previously generated code snippets blink when text is being generated.

Looks like the "Reduce CPU usage by only highlighting after text generation ends" having no effect or something as the code seems to be highlighted as soon it is generated.
Unchecking "Reduce CPU usage by only highlighting after text generation ends" prevents the blinking.

Please see attached video.
text-generation-webui-code_syntax_highlight_issue.webm

JavaScript error preventing text-generation-webui to launch

Hi there.

Today after a git pull of text-generation-webui (at this commit) i got this error in code_syntax_highlight/script.py:73 that prevented app to launch :

 /whatever/text-generation-webui/server.py:255 in <module>                                      
                                                                                                
   254         # Launch the web UI                                                              
 ❱ 255         create_interface()                                                               
   256         while True:                                                                      
                                                                                                
 /whatever/text-generation-webui/server.py:156 in create_interface                              
                                                                                                
   155         extensions_module.create_extensions_tabs()  # Extensions tabs                    
 ❱ 156         extensions_module.create_extensions_block()  # Extensions block                  
   157                                                                                          
                                                                                                
 /whatever/text-generation-webui/modules/extensions.py:199 in create_extensions_block           
                                                                                                
   198                 extension, _ = row                                                       
 ❱ 199                 extension.ui()                                                           
   200                                                                                          
                                                                                                
 /whatever/text-generation-webui/extensions/code_syntax_highlight/script.py:73 in ui            
                                                                                                
    72         ''', visible=False)                                                              
 ❱  73         interface.load(None, None, None, _js=f'() => {{{js_data_proxy_loader+js_modules} 
    74                                                                                          

TypeError: EventListener._setup.<locals>.event_trigger() got an unexpected keyword argument '_js'

Disabling the extension make app run normally.

Many thanks for this great extension, hope you can fix it soon.

Here is the current requirements of my installation : requirements-DebianAi-20240331.txt

Breaks on newes WebUI update

When pulling the newest state of the WebUI from main, enabling this extension freezes the complete WebUI.

The console in the browser prints the following error:

Screenshot_20231011_130315

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.