This Node.js CLI and API gives you the ability to generate content (blog post, landing pages, ...) with a LLM (OpenAI, ...). It can generate text in all languages supported by the available LLMs.
This project is using Langchain JS
Different modes for generating content: automatic, interactive, or with a content template.
? Supported LLMs : OpenAI (stable), Mistral (experimental), Claude (upcoming release), Groq (upcoming release).
? All languages supported by the available LLMs.
SEO friendly : generate post title, description & slug.
✍️ Default or custom prompts.
Fine-tuning with completion parameters.
Publish content on WordPress.
API.
Upcoming features: image generations, RAG, publish on NextJS.
This component can be used in different modes:
In interactive mode, the CLI will ask you for some parameters (topic/title, language, intent, audience, etc.).
In automatic mode, you need to supply all the necessary parameters to the command line. This mode of operation allows you to create a multitude of contents in series (for example, in a shell script).
Both modes will use different predefined prompts to generate the content:
The final result is in Markdown and HTML.
A template contains a document structure within a series of prompts. Each prompt will be executed in a specific order and will be replaced by the answer provided by the AI. It is possible to use different formats: Markdown, HTML, JSON, etc.
The main advantage of the template usage is the customisation of the output. You can use your own prompts. Templates are also interesting if you want to produce different contents based on the same structure (product pages, landing pages, etc.).
One of the problems of AI content generation is the repetition of the main keywords.
This script also uses temperature, frequency_penalty, and presence_penalty parameters to try to minimize this.
See the OpenAI API documentation for more details.
When generating, the CLI gives you the ability to publish the content to your WordPress blog. Other CMS will be supported in the future. We need to support some headless CMS.
This is an experimental project. You are welcome to suggest improvements, like other prompts and other values for the parameters. The cost of the API calls is not included in the price of the CLI. You need to have an OpenAI API key to use this CLI. In all cases, you have to review the final output. AI can provide incorrect information.
Camping-cars écologiques ? Utopie ou réalité en 2024 ?
julius post -fp 1.5 -g -tp "5 reasons to use AI for generating content" -f ./reasons-to-use-ai-contentMarkdown result : 5 Reasons to Use AI for Generating Content
julius template-post -f ./dobermann -t ./template.md -i breed=dobermann -dTemplate : template.md
Markdown result : dobermann.md
julius template-post -f ./dobermann -t ./template.html -i breed=dobermann -dTemplate : template.html
HTML result : dobermann.html
The CLI and API are available as a NPM package.
# for the API
npm install julius-gpt -S
# for the CLI
npm install -g julius-gptThe CLI has 4 groups of commands:
~ julius -h
Usage: julius [options] [command]
Generate and publish your content from the command line ?
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
prompt Prompt related commands
post [options] Generate a post in interactive or automatic mode
template-post [options] Generate a post based on a content template
wp Wordpress related commands. The
You need to have an OpenAI API key to use this CLI.
You can specify your OpenAI API key with the -k option or with the environment variable OPENAI_API_KEY.
See the CLI help to get the list of the different options.
~ julius post -h ~ julius post -tp "5 reasons to use AI for generating content"Use the other parameters to personalize content even further.
A more advanced command
~ julius post -fp 1.5 -g -l french -tp "Emprunter avec un revenu de retraite : quelles sont les options ?" -f ./emprunter-argent-revenu-retraite -c Belgique -dThis command will generate a post in French with a frequency penalty of 1.5 for the audience of the country : Belgium. The topic (tp arg) is written in French.
~ julius post -iIt is not necessary to use the other parameters. The CLI will ask you some questions about the topic, language, ...
The template file can be in the markdown or HTML format. The template extension will be used to determine the final output.
~ julius template-post -t <file>.[md|html]The CLI will execute all prompts mentioned in the template file. Each prompt short-code will be replaced by the output provided by the AI.
Template structure
Here is a simple example for the template file:
{{s:Your are an prompt tester. You have to write your answers in a makrdown block code.}}
{{c:your answer has to be "Content of prompt 1."}}
# Heading 1
{{c:your answer has to be "Content of prompt 2."}}
Prompt "s" is the system prompt Prompt with "c" are content prompt. they will be replaced by the output provided by the AI.
Like in Langchain, you can provide some input variables in the template like this one :
{{s:Your are an prompt tester. You have to write your answers in a makrdown block code in language : {language}.}}
{{c:Quelle est la capitale de la France ?"}}
# Heading 1
{{c: Quelle est la capitale de la Belgique ? "}}
Now, you can execute this template with the following command :
~ julius template-post -t <template-file>.md -i language=frenchThis is an experimental feature and the template syntax will be modified in an upcoming release.
By default, the CLI is using the latest Open AI model. We are working on the support of the following ones :
| Provider | Models | Status | .env variable API KEY |
|---|---|---|---|
| OpenAI | gpt-4, gpt-4-turbo-preview | Stable | OPENAI_API_KEY |
| Mistral | mistral-small-latest, mistral-medium-latest, mistral-large-latest | Experimental | MISTRAL_API_KEY |
| Anthropic | Claude | Next Release | NA |
| Groq | Mistral, Llama | Next Release | NA |
All models require an API Key. You can provide it either in the .env file or with the CLI parameter '-k'
You can choose your model with the -m parameter :
~ julius post -m mistral-large-latest ....Use the help to have the list of the models
~ julius post -h or
~ julius template-post -h Why custom prompts?
Julius uses a set of prompts for content generation that can be customized by creating a new version in a separate directory. Each prompt is stored in a different file.
| File name | Description | Inputs |
|---|---|---|
| system.txt | Can be used as an editorial brief or to add important information such as personas, editorial style, objectives, ... | None |
| audience-intent.txt | Use to generate the audience and intent based on the article's subject. | {language} {topic} |
| outline.txt | Use to generate article structure. | {language} {topic} {country} {audience} {intent} |
| introduction.txt | Use to generate the article's introduction. | {language} {topic} |
| conclusion.txt | Use to generate the article's conclusion. | {language} {topic} |
| heading.txt | Use to generate the content of each heading. | {language} {headingTitle} {keywords} |
1. Make a copy of the default prompts
~ julius prompt create [name] [folder]eg. :
~ julius prompt create discover ./my-promptsThis command will copy the default prompts into the folder : ./my-prompts/discover
2. Modify the prompts
Now, you can modify and/or translate the prompts in this folder
3. Use your prompts in the CLI
In the automatic mode, the cli will ask you the custom prompt path
~ julius -i You can also use a CLI parameter "pf" to specify the folder path
~ julius -pf ./my-prompts/discover ...This command displays the list of all registered Wordpress sites in the local file ~/.julius/wordpress.json.
The domain name or the id of the site can be used for the following commands.
~ julius wp lsThis command adds a new Wordpress site to the local file ~/.julius/wordpress.json.
~ julius wp add www.domain.com:username:passwordThis command displays the list of all registered Wordpress sites in the local file ~/.julius/wordpress.json.
~ julius wp info www.domain.com|idThis command removes a Wordpress site from the local file ~/.julius/wordpress.json.
~ julius wp rm www.domain.com|idThis command exports the list of all registered Wordpress sites in the local file ~/.julius/wordpress.json.
~ julius wp export wordpress_sites.jsonThis command imports the list of all registered Wordpress sites in the local file ~/.julius/wordpress.json.
~ julius wp import wordpress_sites.jsonThis command displays the list of all categories of a Wordpress site.
~ julius wp categories www.domain.com|idThis command creates a new post on a Wordpress site. the JSON file must have the following structure:
{
"title": "The title of the post",
"slug": "the-slug-of-the-post",
"content": "The content of the post",
"seoTitle": "The SEO title of the post",
"seoDescription": "The SEO description of the post",
}This JSON file can be generated with the command julius post or with the API.
By default, the Wordpress REST API doesn't allow you to update the SEO title and description. This information is managed by different plugins, such as Yoast SEO. You can code a plugin for this.
A plugin example for Yoast can be found in this directory: julius-wp-plugin You can create a zip and install it from the Wordpress dashboard.
You can code something similar for other SEO plugins.
~ julius wp post www.domain.com|id categoryId post.jsonjulius wp categories www.domain.com|idThis command updates a post on a Wordpress site (title, content, SEO title & SEO description). the JSON file must have the following structure:
{
"title": "The title of the post",
"slug": "the-slug-of-the-post",
"content": "The content of the post",
"seoTitle": "The SEO title of the post",
"seoDescription": "The SEO description of the post",
}This JSON file can be generated with the command julius post or with the API.
~ julius wp update www.domain.com|id slug post.json [-d, --update-date] See the unit tests : tests/test-api.spec.ts