Giter VIP home page Giter VIP logo

laravel-gpt's Introduction

LaravelGPT

Unleash the Power of OpenAI's ChatGPT API

Latest Version on Packagist Total Downloads

Introducing LaravelGPT, a tool designed to simplify the integration of OpenAI's ChatGPT with your Laravel applications. This package offers a seamless connection to the OpenAI Chat Completions API, even supporting Function Calling. Forget the complications of crafting the correct JSON schema - LaravelGPT does the work for you. Say goodbye to dense, hard-to-read code, and start building the applications of the future! With LaravelGPT, you can truly unleash the power of ChatGPT in your applications, setting the stage for innovation and advanced user interaction.

Installation

You can install the package via composer:

composer require maltekuhr/laravel-gpt

Next you need to configure your OpenAI API Key and Organization ID. You can find both in the OpenAI Dashboard.

OPENAI_ORGANIZATION=YOUR_ORGANIZATION_ID
OPENAI_API_KEY=YOUR_API_KEY

You are now ready to use LaravelGPT! I recommend you to read the Documentation.

Further Documentation

For further documentation please see the Documentation.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-gpt's People

Contributors

maltekuhr 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar

laravel-gpt's Issues

Sending files to GPT

From what I can see in the source code - src/GPTAction.php there isn't an option to include a file attachment to the instructions being sent. Is this ability coming soon?

Invalid schema for function 'knowledge_books': [] is not of type 'object'

I have stumbled across an issue with a function I am generating. The data is returned exactly the same as your example but I still get this error. Am I missing something?

{
    "message": "Invalid schema for function 'knowledge_books': [] is not of type 'object'.",
    "code": 500,
    "exception": "OpenAI\\Exceptions\\ErrorException",

In my chat I am conditionally running my code based on a flag:

public function functions(): ?array
{
    $functions = [];

    // Conditionally add knowledge to AI
    if ($this->filters['search_books']) {
        $functions[] = new KnowledgeBooksGPTFunction($this->filters);
    }

    return $functions;
}

Then in the function itself:

public function function(): Closure
{   
    return function (): array {
        $filters = $this->filters;
        $assessmentVulns = Books::select([
                'books.name as name',
                'books.description as description',
            ])
            ->where('books.category_id', $filters['category_id'])
            // other where from filters array 
            ->take(10)
            ->get()
            ->map(fn ($vulnerability) => [
                'name' => $vulnerability->name,
                'description' => $vulnerability->description,
            ])->toArray();

        return ['results' => $assessmentVulns];
    }

This is left blank

    public function rules(): array
    {
        return [];
    }

    public function description(): string
    {
        return 'My Amazing description.';
    }

Translation failing to return the complete batch

Hi,

This package looks interesting and I wanted to give it a swirl. My playground is to create a command to translate my en.json to another language, Italian let's say ๐Ÿ•.

context

Here is what I do:

  • I open the json file and load it into an array
  • I chunk the array by 20 lines
  • I send this to a GPTAction after having imploded the array with \n

My GPTAction usage looks like this (I call it foreach chunk):

TranslateGPTAction::make('Italian')->send(implode("\n", $keys))['translation']

The parameter sent to the send() method looks like:

foo\nbar\nbaz

Problem

The first loop, i get the proper amount of lines translated (i.e 20). For the second loop, I always get only one line.
After diving a bit in the plugin, I see that Chat GPT is only returning the first line on the second loop. I tried to wait a bit between iterations, but no impact.

Anyone has an idea ?

Thanks in advance

Assistant and Thread ID

Hi how about the possibility to create a Thread?

It could be useful in order to avoid sending history every time...

No publishable resources for tag [config].

Laravel 9

When running the following artisan command

php artisan vendor:publish --provider="MalteKuhr\LaravelGPT\Providers\GPTServiceProvider" --tag="config"

the following warning is returned

INFO  No publishable resources for tag [config].

Running the same command without the --tag="config" parameter publishes the config file successfully.

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.