Skip to content

WebgateSystems/lm-assistant

Repository files navigation

LibreMedia Assistant

LibreMedia Assistant is a Ruby on Rails microservice that connects the main LibreMedia backend with AI models. It provides REST endpoints for editorial translations, transcript-to-article drafts, comment moderation, and future AI tasks.

🚀 Features

  • Translates post fields from one source language into the remaining supported blog locales.
  • Turns vlog transcripts or subtitles into coherent article drafts.
  • Classifies comments as approved, pending, spam, or deleted.
  • Exposes generated OpenAPI documentation through Swagger UI.

🔧 Requirements

Tool Version
Ruby 3.4.x
Rails 8.0.x
API Token Required

📦 Installation

1️⃣ Clone the repository

git clone git@github.com:WebgateSystems/LM-assistant.git
cd LM-support-assistant

2️⃣ Install Ruby dependencies

bundle install

3️⃣ Set up environment variables

Create a config file config/settings.local.yml:

chat_gpt_api_key: 'you gpt api key'

4. Create an API user and token

The assistant uses Bearer tokens stored in access_tokens. Tokens belong to a local assistant User.

Create or reuse a service user and print a token:

bin/rails runner 'user = User.find_or_create_by!(email: "libremedia@app.local") { |u| u.name = "LibreMedia"; u.password = SecureRandom.hex(24); u.password_confirmation = u.password }; token = user.access_tokens.where(active: true).first || user.access_tokens.create!; puts token.token'

You can also create a session and receive the same active token:

curl -X POST http://127.0.0.1:3000/api/v1/session \
  -H "Content-Type: application/json" \
  -d '{
    "user": {
      "email": "libremedia@app.local",
      "password": "the-password-you-created"
    }
  }'

Use the printed token as Authorization: Bearer <token> in calls from LibreMedia.

5. Configure LibreMedia

In the main LibreMedia application, configure the assistant as an external service:

# config/settings.yml or config/settings/<environment>.yml
services:
  assistant:
    endpoint: http://127.0.0.1:3000
    token: your_api_token_here

Production should provide these values through environment variables:

LM_ASSISTANT_ENDPOINT=https://assistant.libremedia.org
LM_ASSISTANT_TOKEN=your_api_token_here

6. Start the Rails server

rails server

API Documentation

After generating Swagger from request specs, documentation is served at:

https://assistant.libremedia.org/api-docs/

Generate or refresh OpenAPI locally:

bundle exec rake rswag:specs:swaggerize

Headers

Content-Type: application/json
Authorization: Bearer your_api_token_here

Translation Endpoint

POST /api/v1/assistant/translations

Example request:

curl -X POST http://127.0.0.1:3000/api/v1/assistant/translations \
  -H "Authorization: Bearer your_api_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "translation": {
      "source_locale": "pl",
      "target_locales": ["uk", "ru", "en"],
      "content_format": "markdown",
      "content": {
        "title": "Polski tytuł",
        "subtitle": "Krótki podtytuł",
        "lead": "Lead artykułu",
        "content_source": "Treść wpisu",
        "keywords": "media, wolność słowa",
        "meta_description": "Opis SEO"
      },
      "metadata": {
        "post_id": "optional-post-id"
      }
    }
  }'

Example response:

{
  "data": {
    "translations": {
      "en": {
        "title": "English title",
        "content_source": "Translated article body"
      }
    },
    "confidence": 0.94,
    "warnings": []
  },
  "meta": {
    "model": "gpt-5-mini"
  }
}

About

LibreMedia AI-Assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages