Skip to content

Use Cases

Albarqawi edited this page Jun 27, 2023 · 7 revisions

IntelliNode enables easy integration of cutting-edge AI models into your projects tailored to your business use cases.

Ecommerce materials

This code sample demonstrates how to create e-commerce materials (product description, images, and audio) using IntelliNode and different AI models like OpenAI, Google, Stability, and Cohere. You can use the following code functions:

  1. Generate product description: The generateProductDescription() function utilizes the RemoteLanguageModel class, which fetches the product description from an AI model like OpenAI or Cohere. Provide the appropriate apiKey, modelBackend, and modelName.
async function generateProductDescription(textInput, apiKey, modelBackend) {
  // available models: SupportedLangModels.OPENAI or SupportedLangModels.COHERE
  const modelName = (modelBackend === SupportedLangModels.OPENAI) ? 'text-davinci-003' : 'command';
  const langModel = new RemoteLanguageModel(apiKey, modelBackend);
  const results = await langModel.generateText(new LanguageModelInput({
    prompt: textInput,
    model: modelName,
    maxTokens: 300
  }));
  return results[0].trim();
}
  1. Generate image description: The getImageDescription() function uses the Chatbot class to generate tuned image description from user message. The users might not enter a text suitable for image generation models and this layer will ensure the image prompt quality.
async function getImageDescription(textInput, openaiKey) {
  const chatbot = new Chatbot(openaiKey);
  const input = new ChatGPTInput('generate image description from paragraph to use it as prompt to generate image from DALL·E or stable diffusion image model. return only the image description to use it as direct input');
  input.addUserMessage(textInput);
  const responses = await chatbot.chat(input);
  return responses[0].trim();
}
  1. Generate images: The generateImage() function uses the RemoteImageModel class, which generates images from the description text. The generated images use stable diffusion or DALL·E models.
async function generateImage(imageText, apiKey, modelBackend) {
  // modelBackend = SupportedImageModels.STABILITY or SupportedImageModels.OPENAI
  const imgModel = new RemoteImageModel(apiKey, modelBackend);
  const imageInput = new ImageModelInput({
    prompt: imageText,
    numberOfImages: 3,
    width: 512,
    height: 512
  });
  return await imgModel.generateImages(imageInput);
}
  1. Generate speech: The generateSpeech() uses the RemoteSpeechModel and AudioHelper classes, which generate and save audio content based on the text input.
async function generateSpeech(textInput, apiKey, modelBackend) {
  // modelBackend = SupportedSpeechModels.GOOGLE
  const speechModel = new RemoteSpeechModel(apiKey);
  const input = new Text2SpeechInput({ text: textInput, language: 'en-gb' });
  const audioContent = await speechModel.generateSpeech(input);
  return audioHelper.decode(audioContent);
}

HTML Pages

IntelliNode facilitates the creation of dynamic HTML pages from text description. With its generate_html_page() and save_html_page() functions, you can create and store HTML pages with CSS and JavaScript. It is recommended to use GPT4 for this feature.

First import the Gen function

const { Gen } = require("intellinode");

1. Generate HTML Page

Use the generate_html_page() function to create an HTML page based on a specific use case, such as a registration page.

const openaiKey = 'your_openai_api_key';
const modelName = 'gpt-4'; // or 'gpt-3.5-turbo'

const prompt = "Create a registration page with flat modern design.";
const htmlContent = await Gen.generate_html_page(prompt, openaiKey, modelName);

2. Save HTML Page

To save the generated HTML page directly to the file system, use the save_html_page() function instead of the generate html:

const folder = './views';
const file_name = 'registration_page.html';

await Gen.save_html_page(prompt, folder, file_name, openaiKey, modelName);

Clone this wiki locally