345 Commits

Author SHA1 Message Date
Saifeddine ALOUI
eb5a10676d Refactor: Update API routes, data stores, and admin templates
This commit updates several API routes, data store definitions, and related templates for the admin section.

Changes include:
- Refactoring in `admin.py`, `datastores.py`, `evaluations.py`, and `proxy.py`.
- Updates to schema settings and static assets.
- Modifications to various admin templates (`base.html`, `dashboard.html`, etc.).
- Updates to agent management logic (`agentManager.ts`, `extensionState.ts`) and UI components.
2026-04-23 03:45:25 +02:00
Saifeddine ALOUI
712319e929 feat(admin): improve instance lifecycle and datastore ingestion
- Refactor instance state checking in admin toggle endpoint
- Add AI processing option to document ingestion pipeline
- Enhance instance manager with cross-platform signal handling
- Fix node registry path resolution for robust module loading
- Update admin templates with CSRF protection and UI polish
2026-04-21 05:07:05 +02:00
Saifeddine ALOUI
c779ae922f Update admin.py 2026-04-20 14:27:26 +02:00
Saifeddine ALOUI
e0e3a21d44 Update pyproject.toml 2026-04-20 09:17:19 +02:00
Saifeddine ALOUI
865080c249 Update requirements.txt 2026-04-20 09:12:57 +02:00
Saifeddine ALOUI
b0e28f1e42 <<<<<<< SEARCH
async def admin_export_run_pdf(run_id: int, request: Request, db: AsyncSession = Depends(get_db), admin_user: User = Depends(require_admin_user)):
     from xhtml2pdf import pisa
     import io
     import os
@@ -669,9 +675,23 @@ async def admin_export_run_pdf(run_id: int, request: Request, db: AsyncSession =
     # 1. Get raw context
     context = await _prepare_report_context(run_id, request, db)
     if not context: raise HTTPException(status_code=404)
+
+    # 1.1 Try to find the associated AI analysis for this run (if any exists)
+    # Benchmark analysis reports are saved as LogAnalysis entries with a specific format
+    # We look for the most recent one containing this run's ID or relevant summary
+    # Since they aren't explicitly linked by FK, we rely on the preparation or a fresh fetch.
+    from app.database.models import LogAnalysis
+    stmt = select(LogAnalysis).filter(LogAnalysis.content.like(f"%Benchmark Report: {context['run'].name}%")).order_by(LogAnalysis.timestamp.desc())
+    res = await db.execute(stmt)
+    latest_analysis = res.scalars().first()
+    if latest_analysis:
+        import markdown
+        md = markdown.Markdown(extensions=['fenced_code', 'tables'])
+        context["ai_analysis_html"] = md.convert(latest_analysis.content)
+
     # 2. Add PDF-specific flags
     context["is_pdf"] = True
-    context["report_format"] = format # 'full' or 'summary'
+    context["report_format"] = format # 'full' or 'summary'

     # 3. Pre-parse Markdown content for results (PDF engine needs pre-rendered HTML)
     import markdown
2026-04-20 01:33:34 +02:00
Saifeddine ALOUI
ab51fcbbb8 Subject: Implement evaluation report generation and update evaluation route
Body:
This commit introduces the necessary logic for handling the evaluation report generation endpoint and updates the template for displaying the report.

Changes include:
- Modifying `app/api/v1/routes/evaluations.py` to handle multi-dataset generation tasks.
- Updating `app/templates/admin/evaluation_report.html` to align with the new report structure.
2026-04-20 01:29:50 +02:00
Saifeddine ALOUI
494a86088f feat(pdf_export): Enhance PDF export rendering with Markdown support and improved code highlighting
Implements Markdown parsing for AI-generated content before PDF export and updates CSS for better inline code styling.

Specifically:
- Updates `app/api/v1/routes/evaluations.py` to use the `markdown` library to convert AI output to HTML for PDF generation, and modifies the template to conditionally render either raw answers or HTML content based on the PDF flag.
- Updates `app/static/css/styles.css` to refine the styling for inline code blocks (`.prose code`) to provide a more modern, high-contrast look.
- Adds `markdown` to `requirements.txt` to support this functionality.
- Integrates `highlight.js` in the frontend to automatically highlight code within the rendered output.
2026-04-20 01:09:26 +02:00
Saifeddine ALOUI
c602ae2cf1 feat(api/core): Refactor workflow engine and agent structure for enhanced evaluation reporting
This commit updates the core workflow engine, refactors API routes for administration, evaluation processing, and proxy handling, and updates related agent and template files.

Key changes include:
- Refactoring `workflow_engine.py` to unify workflow execution blocks.
- Updates to API routes (`admin`, `evaluations`, `importer`, `proxy`) to align with new logic.
- Adjustments to agent files (`agent.js`, `agent.py`) and associated templates for improved reporting UI.
2026-04-20 01:00:10 +02:00
Saifeddine ALOUI
c133532971 Feat: Improve node sizing and add regex import
This commit introduces two changes:
1. In `agent.py`, imports the `re` module, which is necessary for future agent logic.
2. In `conception.html`, fixes a UX issue by dynamically setting a minimum width of 280px for all graph nodes immediately after loading to ensure a consistent visual layout.
2026-04-19 19:24:40 +02:00
Saifeddine ALOUI
2a5e6b4cd6 feat(api/core): Implement admin settings and enhance proxy vectorization caching
This commit updates several core components related to administration, proxy handling, bot management, and application startup sequence.

**Changes include:**
*   **`app/api/v1/routes/admin.py`**: Added handling for Redis password updates in the admin settings endpoint.
*   **`app/api/v1/routes/proxy.py`**: Updated the shared vectorizer function to cache model description embeddings for performance.
*   **`app/core/bot_manager.py`**: Refined the logic for generating unique request IDs for bots.
*   **`app/main.py`**: Adjusted the application lifespan hook to ensure necessary directories are created during startup.
2026-04-19 19:17:25 +02:00
Saifeddine ALOUI
71b25bcefb feat(admin): Implement memory management and agent context handling
This commit introduces foundational changes related to memory management for the admin system and agent interaction.

Specifically:
- Updates `memory_manager.py` to include a static method for processing tags.
- Modifies `routes/admin.py` to incorporate memory system calls within the admin route.
- Updates `dependencies.py` to ensure secure handling of API keys related to memory operations.
- Updates `main.py` to include instructions for the Lollms agent regarding context prioritization.
- Adjusts template files (`base.html`, `memory_systems.html`) to accommodate memory history display.
2026-04-19 04:21:57 +02:00
Saifeddine ALOUI
7b6233349e feat: Implement core bot management, admin routes, and model metadata CRUD
This commit introduces several related updates across the application, focusing on establishing core functionality for bot management, admin routing, and metadata handling.

Key changes include:
- Updating API routes for admin and proxy functionality.
- Refactoring the `BotManager` to handle the starting of active bots.
- Implementing necessary CRUD operations for model metadata and server information.
- Updating database migration and session management files.
- Adjusting relevant template files for the admin dashboard display.
2026-04-19 04:05:00 +02:00
Saifeddine ALOUI
5625f4c793 Refactor: Update routing, core logic, and UI templates for server management features
This commit updates several components related to server management, data store handling, and bot manager permissions.

Specifically, it includes:
- Updates to routing definitions in `datastores.py` and `proxy.py`.
- Adjustments to permission handling in `bot_manager.py`.
- Modifications to server CRUD operations in `server_crud.py`.
- Schema updates in `server.py`.
- Updates to admin template views (`manage_datastore.html`, `servers.html`).
2026-04-18 10:19:03 +02:00
Saifeddine ALOUI
cae71eecd6 Refactor: Improve token tracking response wrapping in proxy route
Modified the response wrapping logic within `_wrap_response_for_token_tracking` in `proxy.py` to ensure accurate token tracking duration calculation.
2026-04-17 22:28:07 +02:00
Saifeddine ALOUI
3e925a3b94 Refactor and update administrative settings, data store management, and memory handling
This commit updates several core components related to administrative settings, data store management, and memory management within the application.

Specifically, it includes:
- Updates to API routes for managing data stores and proxy response wrapping.
- Refinements in the memory management system.
- Adjustments to database migration logic related to settings.
- Updates to relevant schema and template files.
2026-04-17 22:15:06 +02:00
Saifeddine ALOUI
7d7aa20de5 feat: Update API proxy, model metadata CRUD, and admin template views
This commit updates the backend routing for proxy operations, refines the CRUD logic for model metadata, and makes necessary adjustments to the admin dashboard templates.

Changes include:
- Updating the proxy route logic in `app/api/v1/routes/proxy.py`.
- Refining the metadata fetching and creation logic in `app/crud/model_metadata_crud.py`.
- Adjusting the structure and content of admin template files: `app/templates/admin/base.html`, `app/templates/admin/dashboard.html`, and `app/templates/admin/models_manager.html`.
2026-04-17 22:06:48 +02:00
Saifeddine ALOUI
b3f26a7376 from sqlalchemy.future import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import update
from typing import List, Optional
import re
from app.database.models import ModelMetadata

async def get_metadata_by_model_name(db: AsyncSession, model_name: str) -> Optional[ModelMetadata]:
2026-04-17 21:30:43 +02:00
Saifeddine ALOUI
d27671cc0b feat(admin): Enhance instance and server administration views
Updates the administration interface to better reflect and manage instance and server details.

Specifically, this change involves:
- Updating `app/core/instance_manager.py` to include instance checking logic.
- Modifying `app/crud/server_crud.py` to define default server URLs.
- Refactoring `app/schema/server.py` to adjust server model definitions.
- Updating template files (`app/templates/admin/instances.html` and `app/templates/admin/servers.html`) to display new status information.
2026-04-17 20:14:58 +02:00
Saifeddine ALOUI
b506c6141d feat(proxy/crud/database): Enhance context filtering, model matching, and database pooling
This commit introduces several improvements related to context handling, server/model association logic, and database connection pooling safety.

### Changes Implemented:

In `app/api/v1/routes/proxy.py`:
*   **Context Filtering with Exception**: Implemented conditional filtering of available metadata based on required context tokens. A specific exception is added to bypass this filter for system tasks (e.g., `sys_build_` requests) to prevent deadlocks during large context operations.

In `app/crud/server_crud.py`:
*   **Flexible Model Matching**: Updated the logic for matching servers to models to allow flexible matching, supporting scenarios where `model` can match `model:latest` and vice versa, and explicitly handling Ollama naming conventions.

In `app/database/session.py`:
*   **Safe Connection Pooling**: Removed specific pool configuration parameters (`pool_size`, `max_overflow`, `pool_timeout`, `pool_recycle`) from `create_async_engine` initialization to rely on safer defaults, particularly when using SQLite/aiosqlite, improving robustness in high-concurrency scenarios.
2026-04-17 20:08:44 +02:00
Saifeddine ALOUI
a27a041eeb feat(system): Improve background task handling, database pooling, and graceful shutdown
This commit addresses several areas to improve the stability, performance, and graceful shutdown procedure of the application:

### Changes:
*   **Refine Background Task Handling (`app/api/v1/routes/proxy.py`):** Enhanced the background memory processing task to include specific error handling for `asyncio.CancelledError` and general exceptions, ensuring that background tasks are suppressed gracefully during shutdown or failure.
*   **Optimize Database Connection Pooling (`app/database/session.py`):** Tuned the SQLAlchemy engine configuration for better performance and SQLite compatibility by setting explicit pool sizes (`pool_size`, `max_overflow`, `pool_recycle`) and adjusting connection arguments (`check_same_thread: False`).
*   **Implement Graceful Shutdown (`app/main.py`):** Updated the `lifespan` hook to implement a more robust shutdown sequence. This now explicitly cancels background tasks, waits for pending tasks to settle, and explicitly disposes of the database engine, preventing potential connection warnings on exit.
2026-04-17 19:29:47 +02:00
Saifeddine ALOUI
7a06c8556f Refactor: Update argument passing in reverse proxy logic
Updates the signature and argument passing within _reverse_proxy and _wrap_response_for_token_tracking to correctly pass the request object for improved token tracking and context handling during the reverse proxy operation.
2026-04-17 19:26:15 +02:00
Saifeddine ALOUI
2d2bc728c0 feat: enhance system architecture, introduce space_hunter, and update admin interfaces
Summary of Changes:
- [INFRA] Added `space_hunter.py` to the project root for new system utilities.
- [CONFIG] Updated `.gitignore` to include `*.db-wal` files and exclude `docs/article` directory.
- [UI] Refreshed admin templates (`models_manager.html`, `settings.html`) to reflect new architectural capabilities.
- [CORE] Modified `architect_manager.py` to support image generation capabilities (`supports_images`).
- [CORE] Updated `memory_manager.py` to improve context formatting and category handling.
- [API] Implemented new route logic and rate limiting dependencies in `proxy.py` and `admin.py`.
- [MODELS] Updated `models.py` to support new fields and `migrations.py` to handle schema evolution.

Technical Notes:
- The `architect_manager` now manages assets including image nodes.
- Memory formatting has been streamlined to handle multiple titles per category.
- Admin settings and model management pages have been updated to visualize these new capabilities.

BREAKING CHANGE: None.
2026-04-17 19:22:34 +02:00
Saifeddine ALOUI
baa8938c5f feat(api): enhance server selection and retry logic for model routing
Improve auto-mode handling in playground chat, add server filtering by
type in CRUD operations, and implement better server retry tracking
in the proxy layer. Also adds Novita AI binding to bootstrap config.
2026-04-17 03:46:14 +02:00
Saifeddine ALOUI
0267f0da71 feat(security): add multi-tenancy config to agent bootstrap and update proxy error handling
- Extend bootstrap_lollms_agent() with HUB_SECURITY multi-tenancy settings
- Refine HTTP 503 error handling in _process_proxy_logic()
- Update admin base template for agent UI components
2026-04-17 03:06:25 +02:00
Saifeddine ALOUI
2fa3e74f5b feat: add LoLLMs bot agent system with enhanced admin panel
Implement comprehensive bot agent framework including:
- Add agent node components (agent.js, agent.py, composition.py)
- Create LoLLMs bot agent template and specialized tools
- Enhance admin panel with server management, memory systems,
  and model playground interfaces
- Update core systems: bot manager, memory manager, workflow engine
- Extend API routes for admin, proxy, and playground functionality
- Add database migrations and server CRUD operations

Refactor playground chat and proxy routing for improved
server selection and health monitoring.
2026-04-17 02:54:38 +02:00
Saifeddine ALOUI
2eeafc6546 fix: improve error handling in token tracking streams
- Add error logging for token tracking stream failures in proxy
- Add asyncio import to datastores module for async operations
- Minor formatting and cleanup across admin, openai_proxy, and bot_manager
2026-04-16 22:31:44 +02:00
Saifeddine ALOUI
ce7c562aa6 tag 2026-04-16 13:03:19 +02:00
Saifeddine ALOUI
e1a8f77520 fixes 2026-04-16 09:48:10 +02:00
Saifeddine ALOUI
dd09d85020 feat(auth): add admin authentication dependencies across API routes
- Implement API key header authentication in dependencies.py
- Secure admin routes with auth requirements
- Add auth to evaluations, personalities, and skills endpoints
- Update admin evaluations template for auth integration
2026-04-16 00:32:31 +02:00
Saifeddine ALOUI
8650db7c2d feat(run.sh): add automatic system dependency installer for Linux
- Detects and auto-installs Cairo/pkg-config via apt, dnf, or pacman
- Replaces manual-only instructions with interactive installation prompt
- Adds post-install verification to ensure dependencies are available
- Falls back gracefully if user declines or package manager is unsupported
2026-04-15 22:39:35 +02:00
Saifeddine ALOUI
43020763e7 refactor(api): update authentication handling and fix token validation logic
- Enhanced API key validation in dependencies with improved error handling
- Updated datastore configuration management in admin routes
- Improved benchmark task execution flow in evaluations
- Refined proxy message processing logic for chat mode detection
- Synced admin template UI for datastores and evaluations management
- Removed stale SQLite WAL files from datastore directory
- Updated shell scripts (run.sh, run_windows.bat) for environment setup
2026-04-15 22:34:46 +02:00
Saifeddine ALOUI
a10579dd9f fix: align UI datastore naming with internal SafeStore keys
Standardize naming conventions across API routes, database layer, and
templates to ensure UI labels match internal SafeStore identifiers.
Updates affect datastores, proxy authentication, migrations, and
knowledge node configuration.
2026-04-15 20:44:25 +02:00
Saifeddine ALOUI
2bba665f71 chore: Update .gitignore and clean up log files
Refined .gitignore to correctly ignore *.log and *.log.* files, ensuring proper exclusion of log data from version control.
Removed obsolete file lollms_hub.log.1.
2026-04-15 18:23:24 +02:00
Saifeddine ALOUI
71f34dd523 feat: Implement core API routing, proxy logic, and logging configuration
This commit updates several core components across the application to establish foundational routing, proxy handling, robust logging setup, database session management, and server CRUD operations.

Changes include:
- Updating API route definitions for conception and proxy endpoints.
- Enhancing logging configuration with rotating file handlers.
- Adjusting server CRUD logic to incorporate model filtering.
- Refinements in database session management.
- Updating the base HTML template structure.
2026-04-15 18:19:23 +02:00
Saifeddine ALOUI
04afa9b126 feat(evaluations): Add numpy import
Adds the numpy library import to the evaluations route file for potential numerical operations.
2026-04-15 18:01:31 +02:00
Saifeddine ALOUI
ad31152e84 feat(admin: feature): Implement administrative routes, core memory management, and playground interface
This commit introduces the foundational structure and routes for the administrative interface, including necessary API endpoints, core memory management services, database models, agent node logic, and the corresponding admin dashboard templates.

Key changes include:
- Updating API routes for administration, data stores, and playground features.
- Implementing core memory management and asset handling.
- Defining database models, sessions, and migrations.
- Establishing the structure for agent components and administrative templates.
2026-04-15 17:56:36 +02:00
Saifeddine ALOUI
33699e254d feat: enhance admin monitoring, streaming, and proxy handling
- Add server nodes endpoint to admin API for infrastructure visibility
- Improve playground chat streaming with better admin controls
- Extend proxy layer with token-aware request forwarding to Ollama
- Update asset management with additional CDN resources
- Optimize bot manager chat history pruning logic
2026-04-15 01:47:20 +02:00
Saifeddine ALOUI
fca1192519 refactor(api): streamline build endpoint logic across v1 routes
Update internal handling in admin, conception, personalities, and
skills routes for consistency in build workflows. Minor adjustments
to event emissions and parameter resolution.
2026-04-14 23:37:35 +02:00
Saifeddine ALOUI
65a530f1e7 refactor(docker): optimize multi-stage build for production
- Split into dedicated builder and runtime stages
- Move gunicorn install to runtime stage
- Add python3-dev and libcairo2 to their respective stages
- Use COPY --from=builder for dependencies instead of venv
- Simplify permission setup with recursive chown
- Remove redundant comments and streamline layer ordering
2026-04-14 23:33:13 +02:00
Saifeddine ALOUI
7fdb22e4f3 Merge branch 'main' of https://github.com/ParisNeo/ollama_proxy_server 2026-04-14 23:30:46 +02:00
Saifeddine ALOUI
a9ae396b72 chore(release): integrate v1.2.0 feature batch
- Update binary management endpoints in admin API
- Enhance proxy routing with improved token tracking
- Refactor tool testing API resolution logic
- Improve vLLM installation flow in instance manager
- Add debug tracing to workflow engine execution
- Update admin UI templates and styling for instances and model playground
2026-04-14 23:30:41 +02:00
Saifeddine ALOUI
801fb7fbac Merge pull request #59 from Linutux/patch-1
Update Dockerfile, missing dependencies, fixes #57
2026-04-14 23:30:11 +02:00
Saifeddine ALOUI
95cf7e1df8 feat: add asyncio import support across API routes and nodes
Add missing asyncio imports to multiple route handlers and node implementations
to enable async/await functionality throughout the application.
2026-04-14 22:15:05 +02:00
Saifeddine ALOUI
ab28901b05 refactor: clean up admin templates and simplify proxy routing
Remove legacy admin HTML templates (agents, chains, ensembles, pools,
routers, vision augmenters, and edit pages) in favor of updated
administration patterns.

Streamline proxy.py by removing redundant routing logic and dead code.
Enhance vLLM translator with improved message handling for Ollama
payloads. Update playground chat and admin API routes for consistency.
2026-04-14 19:59:12 +02:00
Saifeddine ALOUI
c2ced01024 Update todo.md 2026-04-14 18:23:10 +02:00
Saifeddine ALOUI
b33caca39d Update proxy.py 2026-04-14 11:18:59 +02:00
Saifeddine ALOUI
e201a9a811 style(admin): improve UI layout and add wizard animations 2026-04-14 09:41:29 +02:00
Simon Zöllner
c28b5f33b2 Update Dockerfile, missing dependencies, fixes #57 2026-04-14 03:07:09 +02:00
Saifeddine ALOUI
9b3462b24c fix(admin): correct HTML structure in help page TOC header
Fix malformed HTML in the table of contents card header by properly
closing the h3 tag. The previous diff showed an unclosed attribute
value that would cause rendering issues in the admin help template.
2026-04-14 02:00:00 +02:00