Giter VIP home page Giter VIP logo

llm-workbench's Introduction

LLM Workbench

A RAG-enabled workbench to index files and chat with an LLM about their contents.

How it works

image

Setup

Download and install Ollama, a framework to interact with LLMs.

After installation, run Ollama:

ollama serve

In order to configure the model and the application, in a new terminal, run:

make setup

Running the app

make

A page to load context files and interact with the LLM will open in your browser.

Features

  • One-shot prompts to LLM.
  • File indexing for context querying.
  • Prompt tools to assist with prompt construction and context gathering.
  • Replaying of a set of prompts, either from the current prompt history or a text file.
  • Displaying of all prompts and responses in the chat container.
  • Download of all or only the last chat messages in a chat.txt text file.

Prompt tools

Tools are used directly in the chat message input box.

Tool Usage
:<label> Add a label to a prompt for later reference. Labels should contain only lowercase alphanumeric characters and hyphens.
{response:last} Replaced by the last response in the chat history.
{response:label:<label>} Replaced by the labeled response in the chat history.
/context Query chunks from uploaded files.
/context:<number> Set the number of chunks to return.
/context?file="<file name with extension> Query chunks only from the specified file.
/get:<url> Perform a GET to an endpoint URL.
/echo Echo the prompt without sending it to the LLM. Can have replacements {response*} can be used for replacements.
/template Get the last response as JSON and apply it to a Jinja based template, allowing the custom formatting of response without relying on the LLM. The JSON data is available in the context variable. Refer to the Template usage section for details.

Prompt construction

:<label> /<tool> <prompt text, can contain {response:*} for replacement>

Template usage

Given a previous JSON response, it's possible to use the /template tool to create a template that will be processed using the JSON data.

Using the following JSON as the last response in the prompt history:

{
    "name": "User"
}

The prompt below will generate a response using the JSON as input data in the context variable:

/template Name: {{context.name}}

The response to the prompt will be:

Name: User

Quick Cheat Sheet

Setting a variable

{% set variable_name = context %}

Date/time format (from ISO 8601)

{{context.field_date|parse_date|format_date("%d/%m/%y %H:%M:%S")}}

Conditional

{% if context.field_boolean %}
Value if True
{% else %}
Value if False
{% endif %})

Loop

 {% for item in context.list %}
 {{item.field}}
 {% endfor %}

Documentation

Please refer to Jinja and jinja2_iso8601 documentations for more details on templating.

API mocking

In case you want to use API mocking to test context retrieval from endpoints, it's possible to use the JSON Server package for mocking.

Having Node.js/NPM installed, run the the following command to install dependencies:

make setup/server

Add the JSON you want to use as mock data in the db.json file and run the server in a new terminal with the command below:

make run/server

The server will be accessible in http://localhost:3000/, with the root nodes of the JSON file as URL paths (e.g. in the demo db.json file) there's a data root node, which can be accessible through http://localhost:3000/data.

Changing the model

By default, the workbench uses the LLM model Llama3.1.

To change the LLM model used by the workbench, update the FROM parameter in contextualized_assistant.model file by a model available in the Ollama library.

Known issues

  1. The buttons in the screen are not always disabled during operations. Please be aware that clicking on different buttons during actions may lead to unintended consequences.
  2. The download of chat history may not work during first attempt.
  3. Complex Excel/.xlsx files may not be loadable due to format incompatibility with openpyxl.
  4. During replay, the scrolling may not be automatic.

llm-workbench's People

Contributors

intentor avatar

Stargazers

Alvaro Gabriele avatar

Watchers

 avatar  avatar Kostas Georgiou avatar

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.