Run local, uncensored LLMs with automatic Wikipedia tool calling right from your CLI or web browser.
Running models locally on your own machine is fantastic for privacy, customizability, and escaping subscription fees. But local models are stuck in a sandbox—they cannot look up facts, verify details, or correct spelling mistakes in real time.
Lexi gives your local models a window to the outer world. It connects LM Studio to a web interface or a terminal screen, letting the model automatically search Wikipedia, extract the exact introduction of the correct article, and use it to form a response. It does this with a minimal footprint: no massive vector stores, no complex agent orchestration libraries. Just a lightweight Django backend, standard Python library calls, and clean OpenAI-compatible tool definitions.
- Connects directly to LM Studio's local server API.
- Employs function calling to auto-retrieve Wikipedia abstracts for real-time grounding.
- Streams model outputs token-by-token directly to the UI.
- Keeps track of chat history per user session using Django’s built-in session storage and SQLite.
- Customizes model behavior with custom system prompts built directly into the UI.
- LM Studio: Download and install it.
- Download a Model: Get an LLM (like
llama-3.1-8b-lexi-uncensored-v2or similar). - Start the Local Server: Toggle the local server option on in LM Studio (usually runs on port
1234).
If you just want a terminal-based chatbot with spinner effects and Wikipedia searching:
- Install the OpenAI Python SDK:
pip install openai
- Open
code.pyand set your local server base URL and the model name:client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio") MODEL = "llama-3.1-8b-lexi-uncensored-v2"
- Run the script:
python code.py
To run the full Django interface with session logging and system prompt controls:
- Install Django and the OpenAI SDK:
pip install django openai
- Open
chatai/views.pyand adjust the API URL and model:client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio") model = "llama-3.1-8b-lexi-uncensored-v2"
- Run migrations to initialize the SQLite database:
python manage.py migrate
- Start the Django development server:
python manage.py runserver
- Open your browser and navigate to
http://127.0.0.1:8000/.
Got ideas to make Lexi smarter or want to add more tools (like duckduckgo search, local file reading, or math solver)? Pull requests are incredibly welcome!
- Fork the repository.
- Create your feature branch (
git checkout -b feature/cool-new-tool). - Commit your changes (
git commit -m 'Add duckduckgo tool'). - Push to the branch (
git push origin feature/cool-new-tool). - Open a Pull Request and let's talk about it!