IMPORTANT NOTICE: DevLama functionality has been migrated to the
getllm
package. Please usegetllm
instead ofdevlama
for all code generation and model management tasks. See the getllm README for more information.
Project | Description | Links |
---|---|---|
DevLama | Python code generation with Ollama | GitHub · Docs |
GetLLM | LLM model management and code generation | GitHub · PyPI · Docs |
LogLama | Centralized logging and environment management | GitHub · PyPI · Docs |
APILama | API service for code generation | GitHub · Docs |
BEXY | Sandbox for executing generated code | GitHub · Docs |
JSLama | JavaScript code generation | GitHub · NPM · Docs |
JSBox | JavaScript sandbox for executing code | GitHub · NPM · Docs |
SheLLama | Shell command generation | GitHub · PyPI · Docs |
WebLama | Web application generation | GitHub · Docs |
Tom Sapletta — DevOps Engineer & Systems Architect
- 💻 15+ years in DevOps, Software Development, and Systems Architecture
- 🏢 Founder & CEO at Telemonit (Portigen - edge computing power solutions)
- 🌍 Based in Germany | Open to remote collaboration
- 📚 Passionate about edge computing, hypermodularization, and automated SDLC
If you find this project useful, please consider supporting it:
DevLama is a Python tool that leverages Ollama's language models to generate and execute Python code. It simplifies the process of writing and running Python scripts by handling dependency management and code execution automatically. With the template system, it generates higher quality, platform-aware code that's ready to run. DevLama is part of the PyLama ecosystem and integrates with LogLama as the primary service for centralized logging and environment management.
DevLama is part of the PyLama ecosystem, which includes the following related projects:
Project | Description | Repository Link |
---|---|---|
GetLLM | LLM model management and code generation (replaces DevLama) | /getllm |
LogLama | Centralized logging, environment management, and service orchestration | /loglama |
APILama | API service for code generation and LLM operations | /apilama |
BEXY | Sandbox environment for executing generated code | /bexy |
JSLama | JavaScript code generation with LLM | /jslama |
JSBox | JavaScript sandbox for executing generated JS code | /jsbox |
SheLLama | Shell command generation and execution | /shellama |
WebLama | Web application generation and deployment | /weblama |
The devlama
command is the primary interface for generating Python code using LLM models. Below are the main commands and options available.
IMPORTANT: The
devlama
functionality has been migrated to thegetllm
package. All commands shown below should now be used withgetllm
instead ofdevlama
.
devlama [options] "your prompt here"
Option | Description |
---|---|
-r, --run |
Execute the generated code after creation |
-s, --save |
Save the generated code to a file |
-m, --model MODEL |
Specify which Ollama model to use |
-t, --template TYPE |
Specify the code template type |
-d, --dependencies LIST |
Specify allowed dependencies |
--mock |
Use mock mode (no Ollama required) |
-i, --interactive |
Start interactive mode |
Template | Description |
---|---|
basic |
Simple code generation without extra features |
platform_aware |
Generates code with platform-specific optimizations |
dependency_aware |
Manages dependencies automatically |
testable |
Includes test cases with the generated code |
secure |
Focuses on security best practices |
performance |
Optimizes for performance |
pep8 |
Follows PEP 8 style guidelines |
- Real Ollama Integration: Uses real Ollama models to generate high-quality Python code
- Automatic Model Installation: Automatically installs models when requested, including special handling for SpeakLeash/Bielik models
- Mock Mode: Supports a mock mode for testing without requiring Ollama
- Smart Model Selection: Automatically selects the best available model with fallbacks
- Progress Indicator: Shows real-time progress during code generation
- Template System: Generates code with awareness of platform, dependencies, and more
- Interactive Mode: Provides an interactive CLI for model selection and code generation
- Code Execution: Can execute generated code directly
- LogLama Integration: Integrates with LogLama for centralized logging, environment management, and service orchestration
- Structured Logging: All operations are logged with component context for better debugging and monitoring
- Python 3.8+
- Ollama installed and running (unless using mock mode)
- One or more code generation models pulled in Ollama (e.g.,
codellama:7b
,phi3:latest
)
# Clone the repository
git clone https://github.com/py-lama/devlama.git
cd devlama
# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies in development mode
pip install -e . # This is important! Always install in development mode before starting
IMPORTANT: Always run
pip install -e .
before starting any project in the PyLama ecosystem. This ensures all dependencies are properly installed and the package is available in development mode.
IMPORTANT: The following commands should now be used with
getllm
instead ofdevlama
.
# Generate code using the default model
devlama "create a function to calculate fibonacci numbers"
# Generate and run code
devlama -r "create a web server with Flask"
# Save generated code to a file
devlama -s "create a script to download files from URLs"
# Use a specific model
devlama --model codellama:7b "create a binary search tree implementation"
# Use mock mode (no Ollama required)
devlama --mock "print hello world"
# Use a model that will be automatically installed if not available
devlama --model SpeakLeash/bielik-1.5b-v3.0-instruct-gguf "print hello world"
IMPORTANT: The following commands should now be used with
getllm
instead ofdevlama
.
# Start interactive mode
devlama -i
# Start interactive mode with mock implementation
devlama -i --mock
In interactive mode, you can:
- Select models from a list
- Generate code with custom prompts
- Execute generated code
- Save code to files
- Update the model list
The getllm
package includes new features not available in devlama
, such as Hugging Face model search:
# Search for models on Hugging Face
getllm --search bielik
# Update models list from Hugging Face
getllm --update-hf
DevLama works with other components in the PyLama ecosystem:
- GetLLM: Provides the LLM model management backend (DevLama has been migrated to GetLLM)
- LogLama: Handles logging, environment management, and service orchestration
- BEXY: Executes the generated code in a sandbox environment
- APILama: Provides API access to code generation functionality
The devlama
command integrates with Ollama to provide high-quality code generation. When you run a command, it will:
- Connect to the Ollama server running on
localhost:11434
- Check if the requested model is available
- Automatically install the model if it's not available and auto-install is enabled
- Automatically select an available model if the requested one isn't found
- Use the best available model for code generation
- Fall back to alternative models if needed
- Display a progress spinner with elapsed time during code generation
# Install Ollama (if not already installed)
# See https://ollama.ai for installation instructions
# Start the Ollama server
ollama serve
# Pull recommended models for code generation
ollama pull codellama:7b
ollama pull phi3:latest
IMPORTANT: The following commands should now be used with
getllm
instead ofdevlama
.
# List available models
devlama list
# Install a model
devlama install codellama:7b
# Set default model
devlama set-default codellama:7b
# Show default model
devlama default
# Update models list from Ollama
devlama update
PyLama can automatically install models when requested:
# This will automatically download and install the model if not available
devlama --model SpeakLeash/bielik-1.5b-v3.0-instruct-gguf "print hello world"
PyLama has enhanced support for SpeakLeash/Bielik models with the following features:
- Automatic Installation: Downloads and installs the model from Hugging Face when first requested
- Model Reuse: Detects existing Bielik installations to avoid redundant downloads
- Extended Timeouts: Automatically increases API timeout to 120 seconds for these larger models
Example output:
Found existing Bielik model installation: bielik-custom-1747866289:latest
Using existing model instead of downloading again.
Increased API timeout to 120 seconds for Bielik model.
Generated Python code:
----------------------------------------
#!/bin/env python3
import sys, os
# Function to check if the operating system is Linux
def is_linux():
return os.name == 'posix' and sys.platform == 'linux'
if not is_linux():
print("This code requires a Linux operating system to run.")
exit()
# Hello World function
def hello_world():
print("Hello, World!")
if __name__ == "__main__":
# Call the hello_world function
hello_world()
----------------------------------------
PyLama's installation process for SpeakLeash/Bielik models:
- Downloads the model file from Hugging Face
- Creates a custom Modelfile with appropriate parameters
- Creates the model in Ollama with a unique name
- Updates your environment settings to use the new model
- Remembers the model for future use to avoid redundant downloads
For more details on working with Bielik models, see BIELIK.txt.
You can configure PyLama using environment variables:
OLLAMA_PATH
: Path to the Ollama executable (default:ollama
)OLLAMA_MODEL
: Default model to use (default:codellama:7b
)OLLAMA_FALLBACK_MODELS
: Comma-separated list of fallback models (default:codellama:7b,phi3:latest,tinyllama:latest
)OLLAMA_AUTO_SELECT_MODEL
: Whether to automatically select an available model when the specified one isn't found (default:True
)OLLAMA_AUTO_INSTALL_MODEL
: Whether to automatically install a model when it's not found (default:True
)OLLAMA_TIMEOUT
: API timeout in seconds (default:30
, recommended120
for Bielik models)
If you see an error like this:
Model 'your-model-name' not found in Ollama. Available models: ['codellama:7b', 'phi3:latest']
You can either:
-
Pull the model manually:
ollama pull your-model-name
-
Enable automatic model installation (already enabled by default):
export OLLAMA_AUTO_INSTALL_MODEL=true
If you see a timeout error:
Error querying Ollama API: HTTPConnectionPool(host='localhost', port=11434): Read timed out. (read timeout=30)
Make sure Ollama is running:
ollama serve
If Ollama is running but still timing out, try increasing the timeout:
export OLLAMA_TIMEOUT=120 # Recommended for larger models like Bielik
Note: PyLama now automatically increases the timeout to 120 seconds for Bielik models, but you may need to set this manually for other large models.
If you notice that PyLama is downloading the same model multiple times:
- For SpeakLeash/Bielik models, PyLama now automatically detects existing installations
- For other models, ensure you're using the exact same model name each time
- Check your Ollama installation with
ollama list
to see all installed models
PyLama includes a mock mode that doesn't require Ollama to be installed or running. This is useful for testing or when you don't have access to Ollama.
devlama --mock "print hello world"
In mock mode, PyLama will return pre-defined code examples based on the prompt.
If you see an error like this:
Model 'your-model-name' not found in Ollama. Available models: ['codellama:7b', 'phi3:latest']
You need to pull the model first:
ollama pull your-model-name
If you see a timeout error:
Error querying Ollama API: HTTPConnectionPool(host='localhost', port=11434): Read timed out. (read timeout=30)
Make sure Ollama is running:
ollama serve
If Ollama is running but still timing out, the model might be too large for your system. Try using a smaller model:
devlama --model tinyllama:latest "your prompt"
This repository contains a microservices-based architecture for the PyLama ecosystem, consisting of the following components:
- BEXY: Python code execution sandbox
- PyLLM: LLM operations service
- PyLama: Ollama management service
- SheLLama: Shell and filesystem operations service
- APILama: API gateway for all services
- WebLama: Web frontend (JavaScript/HTML/CSS)
The architecture has been refactored to improve maintainability, scalability, and separation of concerns. Each component now exposes a REST API that can be consumed by other services through the APILama gateway.
The PyLama ecosystem is built around a central orchestration service (PyLama) that coordinates all other components. This architecture allows for better integration and simplified deployment.
+------------+
| Ollama |
| (LLM) |
+------------+
^
|
v
+------------+ +------------+ +---------------+ +------------+
| BEXY | | PyLLM |<--->| PyLama |<--->| SheLLama |
| (Sandbox) |<--->| (LLM) | | (Orchestrator)| | (Shell) |
+------------+ +------------+ +---------------+ +------------+
^ ^ ^ ^
| | | |
v v v v
+-----------------------------------------------------------------------+
| APILama |
| (API Gateway) |
+-----------------------------------------------------------------------+
^
|
v
+-----------------------------------------------------------------------+
| WebLama |
| (Frontend) |
+-----------------------------------------------------------------------+
^
|
v
+-----------------------------------------------------------------------+
| Browser |
+-----------------------------------------------------------------------+
Python code execution sandbox service that provides:
- Code execution in isolated environments
- Dependency management
- Code analysis
LLM operations service that provides:
- LLM model queries
- Code fixing functionality
- Alternative fix generation
Shell and filesystem operations service that provides:
- File operations (read, write, list, search)
- Directory management
- Shell command execution
- Git integration for version control
API gateway service that provides:
- Unified API for all services
- Request routing to appropriate services
- Health monitoring
- Logging and error handling
Web frontend that provides:
- User interface for interacting with the services
- Code editor with syntax highlighting
- File explorer
- Execution results display
Ollama management service that provides:
- Model management
- Model inference
- Model fine-tuning
- Docker and Docker Compose (recommended for easy deployment)
- Python 3.8 or higher (for development without Docker)
- Node.js 14 or higher (for WebLama frontend development)
- Git
The easiest way to run the entire PyLama ecosystem is using Docker Compose, which will set up all components with the correct configuration and dependencies.
-
Clone the repository:
git clone https://github.com/py-lama/devlama.git cd py-lama
-
Start all services with Docker Compose:
docker-compose up -d
This will start all components in the correct order with PyLama as the central orchestration point.
-
Access the web interface:
- Open your browser and navigate to
http://localhost:80
- Open your browser and navigate to
-
Monitor the logs:
docker-compose logs -f
-
Stop all services:
docker-compose down
For development purposes, you can set up each component individually.
-
Clone the repository:
git clone https://github.com/py-lama/devlama.git cd py-lama
-
Set up each component:
cd devlama python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e .
cd apilama python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e .
cd shellama python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e .
cd bexy python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e .
cd getllm python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e .
cd weblama npm install
If you're not using Docker, start the services in the following order:
-
BEXY (Sandbox):
cd bexy source venv/bin/activate # On Windows: venv\Scripts\activate python -m bexy.app --port 8000 --host 127.0.0.1
-
PyLLM (LLM Operations):
cd getllm source venv/bin/activate # On Windows: venv\Scripts\activate python -m getllm.app --port 8001 --host 127.0.0.1
-
APILama (API Gateway):
cd apilama source venv/bin/activate # On Windows: venv\Scripts\activate python -m apilama.app --port 8080 --host 127.0.0.1
Note: APILama will automatically use SheLLama as a library.
-
PyLama (Central Orchestration):
cd devlama source venv/bin/activate # On Windows: venv\Scripts\activate python -m devlama.app --port 8003 --host 127.0.0.1
PyLama coordinates all other services and provides a unified interface.
-
WebLama (Frontend):
cd weblama npm start
Or serve the static files with a web server of your choice.
-
Access the web interface:
- Open your browser and navigate to
http://localhost:8080
(or whatever port you configured for the WebLama frontend)
- Open your browser and navigate to
GET /api/health
Returns the health status of the APILama service.
GET /api/devlama/health
POST /api/devlama/execute
GET /api/bexy/health
POST /api/bexy/execute
GET /api/getllm/health
POST /api/getllm/generate
GET /api/shellama/health
GET /api/shellama/files
GET /api/shellama/file
POST /api/shellama/file
DELETE /api/shellama/file
GET /api/shellama/directory
POST /api/shellama/directory
DELETE /api/shellama/directory
POST /api/shellama/shell
To add a new service to the ecosystem:
- Create a new directory for your service
- Implement the service with a REST API
- Add routes to APILama to proxy requests to your service
- Update the WebLama frontend to interact with your service through APILama
Each service has its own test suite. To run the tests for a service:
cd <service-directory>
python -m unittest discover tests
To run the integration tests for the entire ecosystem:
python integration_test.py
- Modularity: Each service can be developed, deployed, and scaled independently
- Scalability: Services can be scaled based on demand
- Maintainability: Clearer separation of concerns
- Deployment Flexibility: Components can be deployed separately or together
- Language Agnostic: Future components could be written in different languages
PyLama includes a Makefile to simplify common development tasks:
# Set up the project (creates a virtual environment and installs dependencies)
make setup
# Run the API server (default port 8002)
make run
# Run the API server on a custom port
make run PORT=8080
# The run-port command is also available for backward compatibility
make run-port PORT=8080
# Run tests
make test
# Format code with black
make format
# Lint code with flake8
make lint
# Clean up project (remove __pycache__, etc.)
make clean
# Show all available commands
make help
The PyLama ecosystem includes a comprehensive Docker testing infrastructure for all components. This allows for isolated testing of individual components as well as integration testing across the entire ecosystem.
Each component (PyLama, BEXY, PyLLM, APILama, WebLama) includes the following Docker testing files:
- Dockerfile.test: Defines the test environment with all necessary dependencies
- docker-compose.test.yml: Configures the test services with proper networking and dependencies
- run_docker_tests.sh: Provides a convenient script to build, run, and manage the Docker test environment
To run tests using the Docker infrastructure:
# Build and run all tests
./run_docker_tests.sh --build --run-tests
# Start in interactive mode
./run_docker_tests.sh --interactive
# Start all services in the PyLama ecosystem
./run_docker_tests.sh --full-stack
# Run integration tests with all services
./run_docker_tests.sh --integration
# Run Ansible tests for comprehensive integration testing
./run_docker_tests.sh --ansible-tests
# Stop containers
./run_docker_tests.sh --stop
# Clean up containers and volumes
./run_docker_tests.sh --clean
The PyLama ecosystem includes Ansible playbooks for comprehensive integration testing:
- ansible_tests/playbooks/: Contains test playbooks for each component
- ansible_tests/inventory/: Defines the inventory for local testing
- ansible_tests/templates/: Includes templates for generating test reports
These tests verify that all components work together correctly, testing endpoints and interactions between services.
- Isolated Environment: Tests run in a clean, isolated environment
- Reproducibility: Tests produce consistent results across different systems
- Integration Testing: Easily test interactions between multiple services
- CI/CD Ready: Docker tests can be integrated into continuous integration pipelines
- Mock Services: Components can use mock implementations for faster testing
PyLama is built on a modular architecture with three main components:
+----------------+ +----------------+ +----------------+
| | | | | |
| PyLama |---->| PyLLM | | BEXY |
| | | | | |
+----------------+ +----------------+ +----------------+
| ^
| |
+--------------------------------------------+
graph TD
A[PyLama] -->|Uses for code generation| B[PyLLM]
A -->|Uses for code execution| C[BEXY]
B -->|Connects to| D[Ollama API]
D -->|Generated Code| B
B -->|Code| A
A -->|Code to Execute| C
C -->|Execution Results| A
A -->|Results| E[User]
-
PyLama Package - Main application
- Provides CLI interface for code generation
- Manages templates for different code generation scenarios
- Coordinates between PyLLM and BEXY
-
PyLLM Package - LLM integration
- Handles communication with Ollama API
- Manages model selection and configuration
- Processes prompts and extracts code from responses
-
BEXY Package - Sandbox for code execution
- Provides safe execution environments (Python and Docker)
- Manages dependencies for generated code
- Analyzes code for security and performance
devlama/
├── devlama/ # Main package directory
│ ├── __init__.py # Package initialization
│ ├── cli.py # Command-line interface
│ ├── devlama.py # Core functionality
│ ├── OllamaRunner.py # Ollama API integration
│ ├── templates.py # Template management
│ ├── dependency_utils.py # Dependency utilities
│ └── examples/ # Example code templates
│ ├── web_server.py
│ ├── file_io.py
│ ├── api_request.py
│ ├── database.py
│ └── default.py
├── tests/ # Test directory
│ ├── __init__.py
│ ├── test_templates.py
│ ├── test_cli.py
│ └── test_devlama.py
├── pyproject.toml # Project configuration
└── setup.py # Installation script
sequenceDiagram
participant User
participant CLI as cli.py
participant Core as devlama.py
participant Templates as templates.py
participant Ollama as OllamaRunner.py
participant BEXY as BEXY Package
participant PyLLM as PyLLM Package
User->>CLI: devlama "create web server"
CLI->>Core: generate_code(prompt)
Core->>Templates: get_template(prompt)
Templates-->>Core: formatted_prompt
Core->>Ollama: generate(formatted_prompt)
Ollama->>PyLLM: get_models()
PyLLM-->>Ollama: available_models
Ollama->>PyLLM: query_model(prompt)
PyLLM-->>Ollama: generated_code
Ollama-->>Core: generated_code
Core->>BEXY: execute_code(code)
BEXY-->>Core: execution_result
Core-->>CLI: execution_result
CLI-->>User: Display result
The core module coordinates all functionality:
- check_ollama(): Verifies Ollama is running
- generate_code(): Generates Python code from prompts
- execute_code(): Executes the generated code
- save_code_to_file(): Saves code to a file
Provides templates for different code generation scenarios:
- basic: Simple code generation
- platform_aware: Adapts code to the current platform
- dependency_aware: Includes necessary dependencies
- testable: Includes unit tests
- secure: Adds security checks
- performance: Optimizes for performance
- pep8: Follows PEP 8 style guidelines
PyLama uses a sophisticated dependency management system:
-
Direct Dependencies:
- PyLama depends on core Python libraries and utilities like
requests
andpython-dotenv
- Development dependencies include
pytest
,black
, andflake8
- PyLama depends on core Python libraries and utilities like
-
External Package Dependencies:
- PyLLM: Used for model management and LLM integration
- BEXY: Used for code execution and sandbox functionality
-
Dynamic Import System:
- PyLama uses dynamic imports to locate and use PyLLM and BEXY
- The system first tries to find packages in the standard Python path
- If not found, it looks for them in the parent directory (development mode)
- This approach allows flexibility in both development and production environments
PyLama can be installed in two ways:
For development, all three packages (PyLama, PyLLM, BEXY) should be installed in development mode:
# Clone the repositories
git clone https://github.com/py-lama/devlama.git
git clone https://github.com/py-lama/getllm.git
git clone https://github.com/py-lama/bexy.git
# Install in development mode
cd py-lama/devlama
pip install -e .
cd ../../getllm
pip install -e .
cd ../bexy
pip install -e .
This setup allows changes in any package to be immediately available to the others.
For end users, PyLama can be installed directly from PyPI:
pip install devlama
This will install PyLama along with its dependencies, including PyLLM and BEXY.
# After installation
devlama "create a simple hello world program"
# Or run directly from the source directory
python -m devlama.cli "create a simple hello world program"
This will generate a Python script that prints "Hello, World!" and execute it.
devlama -i
This launches PyLama in interactive mode, allowing you to:
- Generate code with different prompts
- Switch between models
- Change templates
- Save and run generated code
devlama -t dependency_aware -d "requests,beautifulsoup4" "create a web scraper for news headlines"
This will generate a web scraper using the specified dependencies.
devlama -m "codellama:7b" -t testable -s -r "create a function to calculate fibonacci numbers"
This will:
-
Use the codellama:7b model
-
Generate code with the testable template
-
Save the code to a file (-s)
-
Run the generated code (-r)
-
prompt
: The task description for code generation (can be provided as positional arguments) -
-t, --template
: Choose a template type for code generation (default: platform_aware)- Available templates: basic, platform_aware, dependency_aware, testable, secure, performance, pep8
-
-d, --dependencies
: Specify allowed dependencies (for dependency_aware template) -
-m, --model
: Specify which Ollama model to use (default: llama3)
- AI-Powered Code Generation - Generate Python code using Ollama's language models
- Template System - Use specialized templates for different coding needs (security, performance, testing)
- Platform-Aware Code - Generate code optimized for your specific operating system
- Automatic Dependency Management - Automatically detects and installs required Python packages
- Code Execution - Run generated code in a controlled environment
- Error Handling - Automatic error detection and debugging suggestions with specialized templates
- Modular Architecture - Separated components for better maintainability with independent packages
- Python 3.8+
- Ollama installed and running locally
- At least one Ollama model (e.g., llama3, llama2, mistral)
- Python 3.8 or higher
- Ollama installed and running
-
Clone the repository:
git clone https://github.com/py-lama/devlama.git cd devlama
-
Install the packages in development mode:
# Install the BEXY package cd bexy pip install -e . # Install the getLLM package cd ../getllm pip install -e . # Install the main PyLama application cd ../devlama pip install -e .
Note: If you encounter issues with Poetry, you can install directly with pip:
pip install -e ../bexy pip install -e ../getllm pip install -e .
-
Ensure Ollama is running:
ollama serve
-
Install at least one code generation model:
ollama pull codellama:7b # or a smaller model if you have limited resources ollama pull phi:2.7b
sequenceDiagram
participant User
participant PyLama
participant getLLM
participant Ollama
participant BEXY
User->>PyLama: Enter prompt
PyLama->>getLLM: Request code generation
getLLM->>Ollama: Send prompt with template
Ollama->>getLLM: Return generated code
getLLM->>PyLama: Return processed code
PyLama->>User: Display generated code
User->>PyLama: Request code execution
PyLama->>BEXY: Send code for execution
BEXY->>BEXY: Check dependencies
BEXY->>BEXY: Create sandbox environment
BEXY->>BEXY: Execute code safely
BEXY->>PyLama: Return execution results
PyLama->>User: Display results
Serwer udostępnia następujące endpointy:
Wysyła zapytanie do modelu Ollama.
Żądanie:
{
"prompt": "Co to jest Python?",
"temperature": 0.7,
"max_tokens": 1000
}
Odpowiedź:
{
"response": "Python to wysokopoziomowy, interpretowany język programowania..."
}
Pobiera listę dostępnych modeli Ollama.
Odpowiedź:
{
"models": [
{
"name": "tinyllama:latest",
"size": 1640,
"current": true
},
{
"name": "llama3:latest",
"size": 3827,
"current": false
}
]
}
Proste narzędzie do testowania działania serwera.
Żądanie:
{
"message": "Test"
}
Odpowiedź:
{
"response": "Otrzymano: Test"
}
# Zapytanie do modelu
curl -X POST -H "Content-Type: application/json" \
-d '{"prompt":"Co to jest Python?"}' \
http://localhost:5001/ask
# Pobranie listy modeli
curl http://localhost:5001/models
# Test echo
curl -X POST -H "Content-Type: application/json" \
-d '{"message":"Test"}' \
http://localhost:5001/echo
Skrypt tworzy plik .env
z ustawieniami, które możesz edytować:
# Konfiguracja modelu Ollama
MODEL_NAME="tinyllama:latest"
# Konfiguracja serwera
OLLAMA_URL="http://localhost:11434"
SERVER_PORT=5001
# Parametry generowania
TEMPERATURE=0.7
MAX_TOKENS=1000
Skrypt działa z wszystkimi modelami dostępnymi w Ollama. Oto szczegółowa lista najpopularniejszych modeli:
Model | Rozmiar | Przeznaczenie |
---|---|---|
llama3 | 8B | Ogólnego przeznaczenia, dobry do większości zadań |
phi3 | 3.8B | Szybki, dobry do prostszych zadań, zoptymalizowany pod kątem kodu |
mistral | 7B | Ogólnego przeznaczenia, efektywny energetycznie |
gemma | 7B | Dobry do zadań języka naturalnego i kreatywnego pisania |
tinyllama | 1.1B | Bardzo szybki, idealny dla słabszych urządzeń |
qwen | 7-14B | Dobry w analizie tekstu, wsparcie dla języków azjatyckich |
llava | 7-13B | Multimodalny z obsługą obrazów - pozwala na analizę obrazów i tekstu |
codellama | 7-34B | Wyspecjalizowany model do kodowania - świetny do generowania i analizy kodu |
vicuna | 7-13B | Wytrenowany na konwersacjach, dobry do dialogów |
falcon | 7-40B | Szybki i efektywny, dobry stosunek wydajności do rozmiaru |
orca-mini | 3B | Dobry do podstawowych zadań NLP |
wizardcoder | 13B | Stworzony do zadań związanych z kodem |
llama2 | 7-70B | Poprzednia generacja modelu Meta, sprawdzony w różnych zastosowaniach |
stablelm | 3-7B | Dobry do generowania tekstu i dialogów |
dolphin | 7B | Koncentruje się na naturalności dialogów |
neural-chat | 7-13B | Zoptymalizowany pod kątem urządzeń Intel |
starling | 7B | Mniejszy ale skuteczny, zoptymalizowany pod kątem jakości odpowiedzi |
openhermes | 7B | Dobra dokładność, postępowanie zgodnie z instrukcjami |
yi | 6-34B | Zaawansowany model wielojęzyczny |
Przy wyborze własnego modelu, warto rozważyć różne rozmiary:
- Mini (1-3B): Bardzo małe modele - szybkie, ale ograniczone możliwości
- Small (3-7B): Małe modele - dobry kompromis szybkość/jakość
- Medium (8-13B): Średnie modele - lepsze odpowiedzi, wymaga więcej RAM
- Large (30-70B): Duże modele - najlepsza jakość, wysokie wymagania sprzętowe
Poniżej orientacyjne wymagania sprzętowe dla różnych rozmiarów modeli:
Rozmiar modelu | Minimalna ilość RAM | Zalecana ilość RAM | GPU |
---|---|---|---|
Mini (1-3B) | 4GB | 8GB | Opcjonalnie |
Small (3-7B) | 8GB | 16GB | Zalecany |
Medium (8-13B) | 16GB | 24GB | Zalecany ≥4GB VRAM |
Large (30-70B) | 32GB | 64GB | Wymagany ≥8GB VRAM |
-
Q: How do I update the model list?
- A: Run
devlama update
to update the model list from Ollama.
- A: Run
-
Q: How do I select a different model?
- A: Use
devlama --model MODEL_NAME
or set a default withdevlama set-default MODEL_NAME
.
- A: Use
-
Q: How do I save the generated code to a file?
- A: Use the
-s
or--save
flag:devlama -s "create a function to calculate fibonacci numbers"
.
- A: Use the
-
Q: How do I run the generated code?
- A: Use the
-r
or--run
flag:devlama -r "create a function to calculate fibonacci numbers"
.
- A: Use the
-
Q: How do I use a specific template?
- A: Use the
-t
or--template
flag:devlama -t dependency_aware "create a web server with Flask"
.
- A: Use the
-
Q: How do I specify allowed dependencies?
- A: Use the
-d
or--dependencies
flag:devlama -d "flask,requests" -t dependency_aware "create a web server"
.
- A: Use the
The functionality of DevLama has been migrated to the GetLLM package. To migrate:
- Use
getllm
instead ofdevlama
for all commands - All command options remain the same
- GetLLM provides additional features like Hugging Face model search
Example migration:
# Old command
devlama --model codellama:7b "create a binary search tree implementation"
# New command
getllm --model codellama:7b "create a binary search tree implementation"
See the GetLLM README for more information on the new features.