├── Cli
├── __init__.py
└── cli.py
├── localLlama
├── __init__.py
└── server.py
├── litellm_uuid.txt
├── screenshots
├── promo1400.png
├── Screenshots.png
├── animate-use.gif
├── pixel-llama.png
├── Screenshots2.png
├── all screenshots.png
└── llama-eatchrome-real.png
├── chrome-extension
├── images
│ ├── 256.png
│ ├── icon128.png
│ ├── icon16.png
│ ├── icon48.png
│ └── llamalogo.png
├── manifest.json
├── popup.html
├── style.css
└── javascript.js
├── .gitignore
├── setup.py
└── Readme.md
/Cli/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/localLlama/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/litellm_uuid.txt:
--------------------------------------------------------------------------------
1 | 8a5b31f9-9d54-4077-ad9c-626c671f0996
--------------------------------------------------------------------------------
/screenshots/promo1400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/promo1400.png
--------------------------------------------------------------------------------
/screenshots/Screenshots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/Screenshots.png
--------------------------------------------------------------------------------
/screenshots/animate-use.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/animate-use.gif
--------------------------------------------------------------------------------
/screenshots/pixel-llama.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/pixel-llama.png
--------------------------------------------------------------------------------
/screenshots/Screenshots2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/Screenshots2.png
--------------------------------------------------------------------------------
/chrome-extension/images/256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/chrome-extension/images/256.png
--------------------------------------------------------------------------------
/screenshots/all screenshots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/all screenshots.png
--------------------------------------------------------------------------------
/chrome-extension/images/icon128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/chrome-extension/images/icon128.png
--------------------------------------------------------------------------------
/chrome-extension/images/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/chrome-extension/images/icon16.png
--------------------------------------------------------------------------------
/chrome-extension/images/icon48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/chrome-extension/images/icon48.png
--------------------------------------------------------------------------------
/chrome-extension/images/llamalogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/chrome-extension/images/llamalogo.png
--------------------------------------------------------------------------------
/screenshots/llama-eatchrome-real.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdiamonddirt/local-llama-chrome-extension/HEAD/screenshots/llama-eatchrome-real.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /localLlama/__pycache__
2 | build_publish.txt
3 | /tests
4 | .pypirc
5 | /build
6 | /dist
7 | litellm_uuid.txt
8 | local_llama.egg-info
9 | chrome-extension-v*.zip
10 |
--------------------------------------------------------------------------------
/chrome-extension/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 3,
3 | "name": "Local LLama LLM AI Chat Query Tool",
4 | "version": "1.0.6",
5 | "description": "Query a local model from your browser.",
6 | "permissions": [
7 | ],
8 | "action": {
9 | "default_popup": "popup.html",
10 | "default_icon": {
11 | "16": "images/icon16.png",
12 | "48": "images/icon48.png",
13 | "128": "images/icon128.png"
14 | }
15 | },
16 | "icons": {
17 | "16": "images/icon16.png",
18 | "48": "images/icon48.png",
19 | "128": "images/icon128.png"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Cli/cli.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | from localLlama.server import app
3 |
4 |
5 | def start_server(ip='127.0.0.1', port=8000):
6 | print(f"API endpoint available at http://{ip}:{port}/")
7 | app.run(host=ip, port=port)
8 |
9 |
10 | def main():
11 | parser = argparse.ArgumentParser(
12 | description="Start the server with optional IP and port arguments.")
13 | parser.add_argument("--ip", default="127.0.0.1",
14 | help="The IP address to bind to (default: 127.0.0.1)")
15 | parser.add_argument("--port", type=int, default=8000,
16 | help="The port to listen on (default: 8000)")
17 | args = parser.parse_args()
18 |
19 | start_server(ip=args.ip, port=args.port)
20 |
21 |
22 | if __name__ == "__main__":
23 | main()
24 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 |
3 | setup(
4 | name='local-llama',
5 | version='1.0.3',
6 | description='A flask server for a chrome extension that querys llm models',
7 | long_description='A flask server for a chrome extension that querys llm models for use with this chrome extention: https://chrome.google.com/webstore/detail/local-llama-llm-ai-chat-q/ekobbgdgkocdnnjoahoojakmoimfjlbm',
8 | url='https://github.com/mrdiamonddirt/local-llama-chrome-extension',
9 | author='Rowan Wood',
10 | author_email='mrdiamonddirt@gmail.com',
11 | packages=find_packages(),
12 | install_requires=[
13 | 'Flask',
14 | 'flask-cors',
15 | 'rich',
16 | 'llama-cpp-python',
17 | 'typing-extensions',
18 | 'typing',
19 | ],
20 | entry_points={
21 | 'console_scripts': [
22 | 'local-llama = Cli.cli:main',
23 | ],
24 | },
25 | )
26 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # Local LLama Chrome Extension
2 | ## What is this?
3 |
4 | This is a chrome extension and flask server that allows you to query the llama-cpp-python models while in the browser. It uses a local server to handle the queries and display the results in a popup.
5 |
6 | ## Why?
7 |
8 | To learn a little bit about chrome extensions and flask. And make a tool that i can use to query the models while using the browser.
9 |
10 | ## How does it work?
11 |
12 | The extension uses the chrome api to get the selected text and send it to the server. The server then queries the model and returns the results to the extension. The extension then displays the results in a popup. The conversations are stored in local storage.
13 | and can be cleared with the clear button in the popup.
14 |
15 |
16 |
17 | ## Showcase
18 | 
19 |
20 | ## Prerequisites
21 |
22 | llama-cpp-python must be installed and some models must be downloaded. See [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) for more information.
23 | Models available for download from huggingface:
24 | - [TheBlokeAI](
25 | https://huggingface.co/TheBloke/)
26 | i'v been using:
27 | - [TheBlokeAI/Llama-2-7B](https://huggingface.co/TheBloke/Llama-2-7b-Chat-GGUF)
28 | for my testing but most of the gguf models should work.
29 | obviously the bigger the model the slower the query. and the more ram it will use.
30 |
31 |
32 | ## How to use it?
33 |
34 | ### easy mode (download from chrome store)
35 |
36 | 1. Download the extension from the chrome store
37 | 2. Pip install the server with `pip install local-llama`
38 | 3. Start the server with `local-llama`
39 | 4. Go to any page and click on the extension icon
40 | 5. query the model and press enter
41 | 6. The results will be displayed in the popup
42 |
43 | ### pro mode (download from github)
44 |
45 | 1. Clone this repo
46 | 2. Open Chrome and go to `chrome://extensions/`
47 | 3. Enable developer mode
48 | 4. Click on `Load unpacked` and select the folder where you cloned this repo
49 | 5. Go to any page and click on the extension icon
50 | 6. build the package with `python setup.py sdist bdist_wheel`
51 | 7. Install the package with `pip install .`
52 | 8. Start the server with `local-llama`
53 | 9. If this is the first time you are using the extension you will be prompted to enter the path for your default model
54 | 10. Type in the query and press enter
55 | 11. The results will be displayed in the popup
56 |
57 | ## TODO
58 |
59 | - [x] add a server to handle the queries
60 | - [x] add a popup to display the results
61 | - [x] store and retrieve conversations
62 | - [x] clear saved conversations
63 | - [x] add a settings page
64 | - [x] add a way to change the model easily
65 | - [x] turn the server.py into a proper python package, to make it easier to install and use if downloaded from the chrome store
66 | - [x] add a way to change the server address
67 | - [ ] hadle when an html is added to the codeblock
68 | - [ ] add a way to download models from huggingface
69 | - [ ] add a way to start the server from the extension
--------------------------------------------------------------------------------
/chrome-extension/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local Model Query
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Local Llama
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
Settings
27 |
Model Loaded:
28 |
29 |
Check the Server is Live:
30 |
Select Model
31 |
33 |
34 |
35 |
Server IP
36 |
37 |
Server Port
38 |
39 |
40 |
41 |
42 |
43 |
44 |
Help/Instructions
45 |
Thank you for choosing our Chrome extension. Below are step-by-step instructions to get started:
46 |
47 |
48 |
Install the accompanying Flask server using pip:
49 |
pip install local-llama
50 |
51 |
Run the server from the command line:
52 |
local-llama
53 |
54 |
Select your desired default model. If your folder contains multiple models, you can change them in the settings.
55 |
56 |
Use the popup to query the server and harness its capabilities.
57 |
58 |
Check the server's status with the "Check Server" button. Green indicates the server is up, while red indicates it's not.