-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from bootstrapguru/openai-chat-endpoint
Add OpenAI Chat Endpoint
- Loading branch information
Showing
24 changed files
with
954 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
.env | ||
docs/.vitepress/dist | ||
docs/.vitepress/cache | ||
/database/database.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Assistant extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'name', | ||
'model', | ||
'description', | ||
'prompt', | ||
'tools', | ||
]; | ||
|
||
protected $casts = [ | ||
'tools' => 'array', | ||
]; | ||
|
||
public function threads() | ||
{ | ||
return $this->hasMany(Thread::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Message extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'thread_id', | ||
'role', | ||
'content', | ||
'name', | ||
'tool_call_id', | ||
'tool_calls', | ||
]; | ||
|
||
protected $casts = [ | ||
'tool_calls' => 'array', | ||
]; | ||
|
||
public function thread() | ||
{ | ||
return $this->belongsTo(Thread::class); | ||
} | ||
|
||
public function tool() | ||
{ | ||
return $this->belongsTo(Tool::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
|
||
class Project extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'path', | ||
'assistant_id', | ||
]; | ||
|
||
public function assistant(): BelongsTo | ||
{ | ||
return $this->belongsTo(Assistant::class); | ||
} | ||
|
||
public function threads(): HasMany | ||
{ | ||
return $this->hasMany(Thread::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Thread extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'assistant_id', | ||
'title', | ||
'folder_path', | ||
]; | ||
|
||
public function assistant() | ||
{ | ||
return $this->belongsTo(Assistant::class); | ||
} | ||
|
||
public function messages() | ||
{ | ||
return $this->hasMany(Message::class); | ||
} | ||
|
||
public function project() | ||
{ | ||
return $this->belongsTo(Project::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Services; | ||
|
||
use Saloon\Http\Connector; | ||
use Saloon\Traits\Plugins\AcceptsJson; | ||
use Saloon\Traits\Plugins\AlwaysThrowOnErrors; | ||
|
||
class AIConnector extends Connector | ||
{ | ||
use AcceptsJson, AlwaysThrowOnErrors; | ||
|
||
/** | ||
* The Base URL of the API | ||
*/ | ||
public function resolveBaseUrl(): string | ||
{ | ||
return 'https://api.openai.com/v1'; | ||
} | ||
|
||
/** | ||
* Default headers for every request | ||
*/ | ||
protected function defaultHeaders(): array | ||
{ | ||
return [ | ||
'Authorization' => 'Bearer '.config('droid.api_key'), | ||
]; | ||
} | ||
} |
Oops, something went wrong.