Giter VIP home page Giter VIP logo

laravel-chatgpt-application's Introduction

Laravel ChatGPT

Application Laravel integrated with OpenAI's ChatGPT, with Authentication and Cache.

In this project, we have a Laravel 9 application with PHP 8.2, with a login session and access to OpenAI's ChatGPT API, in addition, there is a cache application to avoid the consumption of recently performed queries. The entire Laravel project also has TailwindCSS themes, Vite.js to compile scripts, docker-compose file with PHP 8.2, MySQL and Redis. Furthermore, the entire project runs easily with Laravel Sail, requiring only a docker environment to run.

Get Started

Required:

  • PHP 8.1+
  • Docker
  • WSL2 (recommended)
  • OpenAI account for API Key

Installation

  • Clone this repository
  • Run composer update
  • Into folder, run ./vendor/bin/sail build
  • After build, run ./vendor/bin/sail up -d
  • Done, access on browser http://localhost

Tutorial

...

How this project was made!

  • Create a new project with Laravel Sail template
curl -s "https://laravel.build/example-app?with=mysql,redis" | bash
  • Running the project with Laravel Sail
sail up -d
  • Require laravel breeze for gerante auth sessions pages
composer require laravel/breeze --dev
  • Install Laravel Breeze, apply generate auth session pages on project
php artisan breeze:install
  • Run all migrations, including migrations of breeze
php artisan migrate
  • Install npm dependencies
npm install
  • Run npm to test application are stared
npm run dev
  • If your application not found scripts will be set configuration into ./vite.config.js file add after plugins: [...]
    watch: {
        usePolling: true,
        origin: 'http://localhost'
    },
    server: {
        hmr: {
            host: 'localhost'
        }
    }
  • To add authentication session on application
php artisan breeze:install --dark
  • Install Nuno Maduro dependencies for supporting at OpenAI, with all api resources.
composer require openai-php/client
  • Add into .env OpenAI key
echo -e '\nOPEN_AI_KEY="CHANGE_TO_YOUR_KEY..."' >> .env
  • Genertate OpenAIController
sail artisan make:controller OpenAIController
  • Run again NPM for auto builds scripts after changes
npm run dev
  • New Route on web.php file, into session auth, add route:
    Route::get('/openai', [OpenAIController::class, 'index'])->name('openai.index');
  • New Link for menu access, on file ./resources/views/layouts/navigation.blade.php add:

    <div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
        <x-nav-link
            :href="route('openai.index')"
            :active="request()->routeIs('openai.index')"
        >
            {{ __('OpenAI') }}
        </x-nav-link>
    </div>
  • New file ./app/Http/Controllers/OpenAIController.php

  • New file ./resources/views/openai/index.blade.php

Inspirations

  • About OpenAI models

Openai Models

  • OpenAI-PHP Dependencies

Nuno Maduro - OpenAI-PHP dependecy

  • OpenAI ChatGPT

OpenAI ChatGTP

  • App Node.js with ChatGPT and WhatsApp

Victor Harray - Guide integration ChatGPT with WhatsApp

laravel-chatgpt-application's People

Contributors

urnauzao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-chatgpt-application's Issues

Where is the chatGPT integration?

As far as I know, there is not yet any chatGPT api? Only to the previous endpoints to the text etc. models. (This repo should be called "laravel-gpt3-application")

.env into controller

Hi @urnauzao thanks for idea,
but please remove .env helper from OpenAiController. Use config() instead.
The controller too can be refactorized for better readability.
When I can I'll submite a PR?
Bye
Alessandro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.