2.6 KiB
Text-Based LLM Interaction System
A Python-based system for interacting with an LLM running on LM Studio through a text-based interface.
Setup Guide
For detailed instructions on setting up pyenv and virtual environments, see setup_guide.md.
Project Structure
text_adventure/
├── main.py # Entry point
├── config.py # Configuration settings
├── llm_client.py # LLM communication
├── interface.py # Text input/output
├── conversation.py # Conversation history management
├── test_interface.py # Test script for interface
└── README.md # This file
Setup
Option 1: Traditional Setup
- Ensure you have Python 3.6+ installed
- Install required dependencies:
pip install -r requirements.txt - Make sure LM Studio is running on 10.0.0.200:1234
Option 2: Docker Setup (Recommended)
- Install Docker and Docker Compose
- Build and run the application:
docker-compose up --build - Make sure LM Studio is running on 10.0.0.200:1234 and accessible from the Docker container
Option 3: Portainer Deployment
- Ensure you have a Portainer instance running at 10.0.0.199:9000
- Configure your
.envfile with Portainer credentials (see.env.example) - Run the deployment script:
python deploy_to_portainer.py - Or set environment variables and run:
export PORTAINER_URL=http://10.0.0.199:9000 export PORTAINER_USERNAME=admin export PORTAINER_PASSWORD=yourpassword python deploy_to_portainer.py
Usage
To run the main application:
python main.py
Testing
To test the complete system:
python test_system.py
To test just the interface:
python test_interface.py
To test connection to LM Studio:
python test_llm_connection.py
To test message exchange with LLM:
python test_llm_exchange.py
Configuration
The system is configured to connect to LM Studio at http://10.0.0.200:1234. You can modify the config.py file to change this setting.
Components
Main Application (main.py)
The entry point that ties all components together.
Configuration (config.py)
Contains settings for connecting to LM Studio.
LLM Client (llm_client.py)
Handles communication with the LM Studio API.
Interface (interface.py)
Manages text input and output with the user.
Conversation Manager (conversation.py)
Keeps track of the conversation history between user and LLM.
Testing
Run the test_interface.py script to verify the text input/output functionality works correctly.