Skip to content

The Anomalous Blog is a showcase project for the LaravelNeuro Laravel package. It uses a LaravelNeuro state-machine to fully automate the generation of blog articles with image and audio recordings leveraging generative AI models.

Notifications You must be signed in to change notification settings

LaravelNeuro/anomalousblog

Repository files navigation

Anomalous Blog - A LaravelNeuro Proof-of-Concept Application

Anomalous Blog Screenshot

What is LaravelNeuro?

LaravelNeuro is a Laravel package designed to allow for the integration of AI APIs into your application architecture. This includes a sophisticated state-machine system that can be used to create complex LaravelNeuro state-machines, networking AI agents, php scripts, and Eloquent Models.

About the Anomalous Blog

The Anomalous Blog consists of blog articles that were generated by first crawling real news articles, then running them through a multi-tiered state machine to create short pieces of supernatural fiction, which are then "assessed" by a fictional paranormal intelligence agency, the "SCP Foundation". The blog is rendered using a Vue3 Frontend, plugged into the Laravel application using InertiaJS. Articles presented are drawn from the Database and linked to Eloquent models created by the "CreepyPastaMachine", the central LaravelNeuro state-machine around which the application is built.

Installation Instructions

If you would like to test this application and experiment with the CreepyPastaMachine state-machine, you need to fill out the following parameters in your .env file:

Database and API Keys

DB_CONNECTION=mysql
DB_HOST=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

OPENAI_API_KEY=
GNEWS_API_KEY=

You can procure API Keys on the Open AI Platform and genews.io (WARNING: OpenAI Models are not free-to-use but rather come with a per-1000-tokens price. For reference: When generating new articles on the original Anomalous Blog, the sum usage of all involved models costs approximately 25 cents per article at the moment.)

In principle, all OpenAI models used here can be replaced with different models, if you have the necessary access and they offer a curl-based API (for example, you could replace chat-completion models with Ollama-hosted models. To do this, you'd have to either build a custom pipeline using the basic pipeline or use the basic pipeline: LaravelNeuro\LaravelNeuro\Pipeline

you may also need to manipulate prompts using the preProcessPrompt and postProcessPrompt method overrides in your CreepyPastaMachine transitions (located in app/CreepyPastaMachine/Transitions

php artisan make:pipeline MyPipeline

and replacing the Pipeline namespace in the setup file with your custom pipeline's namespace, or you could use the BasicPipeline

Application Installation

Make sure to build the Vue frontend. You may have to adapt the vite-config to your application's specifications, especially if you want to run npm run dev for development.

npm run build

State Machine Installation

php artisan lneuro:install CreepyPastaMachine

CreepyPastaMachine

The CreepyPastaMachine is a LaravelNeuro state machine. It leverages various Function-Type Transitions as well as a number of Agent-Type Transitions. In a LaravelNeuro state-machine, a number of units are set up to contain certain types of related AI-Agents, which are defined within each unit. Then, Transitions are defined, showing through which functions and agents a given task passes.

This state-machine is located in the app/Corporations/CreepyPastaMachine folder and has the APP\Corporation\CreepyPastaMachine namespace.

The structure of the machine can be found and manipulated at (app/Corporations/CreepyPastaMachine/setup.json):

How to Run

php artisan lneuro:run CreepyPastaMachine start

Structure

This is what happens during a run of CreepyPastaMachine:

Transition Transition-Type Model-Type Summary
NewsCrawler Function - Leverages the gnews.io API to collect news articles from preset categories, then selects a random recent one to pass through the state-machine.
Summarizer Agent Chat-Completion Summarizes the selected news article in bulletin points.
Paranormalist Agent Chat-Completion Injects new bulletin points with paranormal/supernatural fictional content.
Writer Agent Chat-Completion Writes a new article from the expanded summary. And injects a placeholder element.
BlogTranslator Agent Chat-Completion Translates the article into German.
Formatter Agent Chat-Completion Formats German and English Article with HTML markup.
Photographer Agent Image-Generation Generates Article-Image using the injected img-tag's alt-attribue.
Assessor Agent Chat-Completion Ingests the modified summary from earler and writes an SCP Foundation report.
Arbiter Agent Chat-Completion Ingests the modified summary AND the report and returns a json-object with the SCP classifications.
AssessmentTranslator Agent Chat-Completion Translates report into German.
BlogVO Agent Text-to-Speech Creates voice-over for the article and repeats on itself once to do this for both languages
ScpVO Agent Text-to-Speech Creates voice-over for the classifications and report and repeats on itself once to do this for both languages
Validator Function - Ensures that the Eloquent models that were created during the run have been fully filled out and are valid for use on the site

After the run, the new BlogArticle and ScpWarning models created in the Database are used by the AnomalousBlogController to render generated articles and assessments on the website.

"transitions": [
      {
        "type": "FUNCTION",
        "transitionName": "NewsCrawler",
        "transitionHandle": "NewsCrawler"
      },
      {
        "type": "AGENT",
        "transitionName": "Summarizer",
        "transitionHandle": "Blog.Summarizer"
      },
      {
        "type": "AGENT",
        "transitionName": "Paranormalist",
        "transitionHandle": "Blog.Paranormalist"
      },
      {
        "type": "AGENT",
        "transitionName": "Writer",
        "transitionHandle": "Blog.Writer"
      },
      {
        "type": "AGENT",
        "transitionName": "BlogTranslator",
        "transitionHandle": "Translator.Fulltext"
      },
      {
        "type": "AGENT",
        "transitionName": "Formatter",
        "transitionHandle": "Blog.Formatter"
      },
      {
        "type": "AGENT",
        "transitionName": "Photographer",
        "transitionHandle": "Blog.Photographer"
      },
      {
        "type": "AGENT",
        "transitionName": "Assessor",
        "transitionHandle": "SCPfoundation.Assessor"
      },
      {
        "type": "AGENT",
        "transitionName": "Arbiter",
        "transitionHandle": "SCPfoundation.Arbiter"
      },
      {
        "type": "AGENT",
        "transitionName": "AssessmentTranslator",
        "transitionHandle": "Translator.Fulltext"
      },
      {
        "type": "AGENT",
        "transitionName": "BlogVO",
        "transitionHandle": "Radio.Blogger"
      },
      {
        "type": "AGENT",
        "transitionName": "ScpVO",
        "transitionHandle": "Radio.SCPclerk"
      },
      {
        "type": "FUNCTION",
        "transitionName": "Validator",
        "transitionHandle": "Validator"
      }
    ]

About

The Anomalous Blog is a showcase project for the LaravelNeuro Laravel package. It uses a LaravelNeuro state-machine to fully automate the generation of blog articles with image and audio recordings leveraging generative AI models.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published