Skip to content

Commit

Permalink
Merge pull request #5 from LlmLaraHub/modules
Browse files Browse the repository at this point in the history
Start moving all the core stuff into Modules
  • Loading branch information
alnutile authored Apr 14, 2024
2 parents 04b296c + cb53e18 commit 84d7232
Show file tree
Hide file tree
Showing 200 changed files with 14,208 additions and 156 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added Modules/.DS_Store
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions Modules/Foundation/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Foundation",
"alias": "foundation",
"description": "",
"keywords": [],
"priority": 0,
"providers": [

],
"files": []
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
3 changes: 1 addition & 2 deletions app/LlmDriver/readme.md → Modules/LlmDriver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ return [
App\Providers\FortifyServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,
App\LlmDriver\LlmServiceProvider::class,
\LlmLaraHub\LlmDriver\LlmServiceProvider::class,
];

```
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\CompletionResponse;
use App\LlmDriver\Responses\EmbeddingsResponseDto;
use Illuminate\Support\Facades\Log;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\CompletionResponse;
use LlmLaraHub\LlmDriver\Responses\EmbeddingsResponseDto;

abstract class BaseClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\CompletionResponse;
use App\LlmDriver\Responses\EmbeddingsResponseDto;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\CompletionResponse;
use LlmLaraHub\LlmDriver\Responses\EmbeddingsResponseDto;

class ClaudeClient extends BaseClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

enum DriversEnum: string
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Support\Creation\CreationContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

use Spatie\LaravelData\Attributes\WithCast;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\FunctionResponse;
use App\Models\Chat;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\FunctionResponse;

abstract class FunctionContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

class FunctionDto extends \Spatie\LaravelData\Data
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

class ParametersDto extends \Spatie\LaravelData\Data
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

class PropertyDto extends \Spatie\LaravelData\Data
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

use App\LlmDriver\Responses\FunctionResponse;
use App\Models\Chat;
use LlmLaraHub\LlmDriver\Responses\FunctionResponse;

class SearchAndSummarize extends FunctionContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace App\LlmDriver\Functions;
namespace LlmLaraHub\LlmDriver\Functions;

use App\Domains\Messages\RoleEnum;
use App\LlmDriver\LlmDriverFacade;
use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\FunctionResponse;
use App\Models\Chat;
use Illuminate\Support\Facades\Log;
use LlmLaraHub\LlmDriver\LlmDriverFacade;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\FunctionResponse;

class SummarizeCollection extends FunctionContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

interface HasDrivers
{
Expand Down
32 changes: 32 additions & 0 deletions Modules/LlmDriver/app/Helpers/JobMiddlewareTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace LlmLaraHub\LlmDriver\Helpers;

use Illuminate\Queue\Middleware\WithoutOverlapping;
use LlmLaraHub\LlmDriver\HasDrivers;
use LlmLaraHub\LlmDriver\LlmDriverFacade;

trait JobMiddlewareTrait
{
public function driverMiddleware(HasDrivers $hasDrivers): array
{
$defaults = [];

/**
* @NOTE
* basically Ollama can only handle one job
* at a time from what I can tell right now.
* So this prevents to many jobs hitting
* it at once
*/
if (LlmDriverFacade::driver($hasDrivers->getDriver())->isAsync()) {
return $defaults;
}

return [
(new WithoutOverlapping($hasDrivers->getDriver()))
->releaseAfter(30)
->expireAfter(600),
];
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Helpers;
namespace LlmLaraHub\LlmDriver\Helpers;

use voku\helper\StopWords;
use Wamania\Snowball\StemmerFactory;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\LlmDriver\Functions\SummarizeCollection;
use LlmLaraHub\LlmDriver\Functions\SummarizeCollection;

class LlmDriverClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use Illuminate\Support\Facades\Facade;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\LlmDriver\Functions\SearchAndSummarize;
use App\LlmDriver\Functions\SummarizeCollection;
use Illuminate\Support\ServiceProvider;
use LlmLaraHub\LlmDriver\Functions\SearchAndSummarize;
use LlmLaraHub\LlmDriver\Functions\SummarizeCollection;

class LlmServiceProvider extends ServiceProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

class MockClient extends BaseClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\CompletionResponse;
use App\LlmDriver\Responses\EmbeddingsResponseDto;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Laravel\Pennant\Feature;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\CompletionResponse;
use LlmLaraHub\LlmDriver\Responses\EmbeddingsResponseDto;

class OllamaClient extends BaseClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\CompletionResponse;
use App\LlmDriver\Responses\EmbeddingsResponseDto;
use Illuminate\Support\Facades\Log;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\CompletionResponse;
use LlmLaraHub\LlmDriver\Responses\EmbeddingsResponseDto;
use OpenAI\Laravel\Facades\OpenAI;

class OpenAiClient extends BaseClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace App\LlmDriver;
namespace LlmLaraHub\LlmDriver;

use App\Domains\Messages\RoleEnum;
use App\Events\ChatUiUpdateEvent;
use App\LlmDriver\Functions\FunctionCallDto;
use App\LlmDriver\Requests\MessageInDto;
use App\LlmDriver\Responses\FunctionResponse;
use App\Models\Chat;
use Facades\App\Domains\Messages\SearchOrSummarizeChatRepo;
use Illuminate\Support\Arr;
use LlmLaraHub\LlmDriver\Functions\FunctionCallDto;
use LlmLaraHub\LlmDriver\Requests\MessageInDto;
use LlmLaraHub\LlmDriver\Responses\FunctionResponse;

class Orchestrate
{
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Requests;
namespace LlmLaraHub\LlmDriver\Requests;

use Spatie\LaravelData\Data;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Responses;
namespace LlmLaraHub\LlmDriver\Responses;

class CompletionResponse extends \Spatie\LaravelData\Data
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Responses;
namespace LlmLaraHub\LlmDriver\Responses;

use Pgvector\Laravel\Vector;
use Spatie\LaravelData\Attributes\WithCastable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Responses;
namespace LlmLaraHub\LlmDriver\Responses;

/**
* @NOTE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\LlmDriver\Responses;
namespace LlmLaraHub\LlmDriver\Responses;

use Pgvector\Laravel\Vector;
use Spatie\LaravelData\Casts\Cast;
Expand Down
28 changes: 28 additions & 0 deletions Modules/LlmDriver/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "llmlarahub/llmdriver",
"description": "Driver for any LLM",
"authors": [
{
"name": "Alfred Nutile",
"email": "[email protected]"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {

}
}
},
"autoload": {
"psr-4": {
"LlmLaraHub\\LlmDriver\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"LlmLaraHub\\LlmDriver\\Tests\\": "tests/"
}
}
}
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions Modules/LlmDriver/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "LlmDriver",
"alias": "llmdriver",
"description": "",
"keywords": [],
"priority": 0,
"providers": [

],
"files": []
}
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 84d7232

Please sign in to comment.