-
Notifications
You must be signed in to change notification settings - Fork 17
Use Cases
IntelliNode enables easy integration of cutting-edge AI models into your projects tailored to your business use cases.
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:
-
Generate product description: The
generateProductDescription()function utilizes theRemoteLanguageModelclass, which fetches the product description from an AI model like OpenAI or Cohere. Provide the appropriateapiKey,modelBackend, andmodelName.
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();
}-
Generate image description: The
getImageDescription()function uses theChatbotclass 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();
}-
Generate images: The
generateImage()function uses theRemoteImageModelclass, 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);
}-
Generate speech: The
generateSpeech()uses theRemoteSpeechModelandAudioHelperclasses, 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);
}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");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);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);