Skip to content

brakmic/langchain-experiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangChain + Llamafile Experiments

This repository contains experiments and example code for using LangChain with Llamafile, running local LLMs in Python.

Features

  • Python 3 project with Pipenv for easy dependency management
  • All required libraries for LangChain and Llamafile are specified in the included Pipfile
  • Example code for interacting with a local LLM via LangChain in the src directory
  • Ready-to-use VSCode workspace for convenient development
  • Easily switch between different local LLMs downloaded from HuggingFace, e.g. Mozilla/Llama-3.2-1B-Instruct-llamafile

Getting Started

Prerequisites

  • Python 3.12 (or compatible version)
  • pipenv (recommended, but you can use any Python environment manager)

Installation

  1. Clone the repository:

    git clone https://github.com/brakmic/langchain-experiments.git
    cd langchain-experiments
  2. Install dependencies:

    pipenv install

    Or, if you prefer another environment manager, use the Pipfile as a reference.

  3. Download a Llamafile model:

    • Visit HuggingFace or another LLM provider.
    • Download the .llamafile model and run it locally (see the model's README for instructions).
  4. Set the Llamafile API URL (optional):

    • By default, the code expects the Llamafile server at http://localhost:8080.
    • You can override this by setting the LLAMAFILE_URL environment variable.

Usage

  • Source code is in the src directory. For example, to run a simple prompt:

    python src/llamafile.py
  • You can open the project in VSCode using the included workspace file:

    code langchain.code-workspace

Notes

  • The .venv and local/ directories are excluded via .gitignore.
  • You can use any Python 3 environment manager if you prefer not to use Pipenv.
  • Example models and prompts are provided, but you can adapt them for your own experiments.

License

MIT

Releases

No releases published

Packages

No packages published

Languages