Getting Started

Before starting you need to be authenticated, since the package is hosted within a private npm registry, the authentication steps are described before.

Authentication chevron-right

First, you need to install the package using the following command:

npm i @tradinos/cms-backend-ai

Second in your module you need to import AIModuleand provide the appropriate configuration depending on your use case

import { Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { AIModule } from '@tradinos/cms-backend-ai';
import { AIController } from 'src/domain/ai/ai.controller';

@Module({
  imports: [
    AIModule.configureAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => {
        return {
          operations: {
            articleGeneration: {
              promptFactory: (topic, length, tone, language, eventDetails) => "Your Prompt Here"
            },
            postGeneration: {
              promptFactory: (platform, language, platformLimit, article, notes) => "Your Prompt Here"
            }
          },
          openai: { apiKey:  /** Your API Key Here */ },
        };
      },
    }),
  ],
  controllers: [AIController],
})
export class LocalAIModule { }

For articleGenerationPromptFactory(...) => string

  • topic: What the article should be about — the main subject or idea.

  • length: How long the article should be (like short, medium, or long).

  • tone: The style or mood of the writing (e.g., professional, friendly, inspiring).

  • language: The language you want the article to be written in.

  • eventDetails: Any extra information or context the article should include, like details about a specific event.

For postGenerationPromptFactory(...) => string

  • platform: The social media platform you’re writing the post for (like Instagram or Facebook).

  • language: The language the post should be in.

  • platformLimit: The word or character limit for that platform.

  • article: The article content you want to turn into a post.

  • notes: Any extra instructions or context to help shape the post’s message.

Okay, and now we have AI!

Last updated