Skip to content

Commit 43fa5b9

Browse files
committed
ready to merge
1 parent fda9025 commit 43fa5b9

File tree

16 files changed

+43
-62
lines changed

16 files changed

+43
-62
lines changed

Modules/LlmDriver/app/BaseClient.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@ public function modifyPayload(array $payload, bool $noTools = false): array
121121
$payload['tools'] = $this->getFunctions();
122122
}
123123

124-
125124
if ($this->system) {
126125
$payload['system'] = $this->system;
127126
}
128127

129-
130128
$payload = $this->addJsonFormat($payload);
131129

132130
return $payload;

Modules/LlmDriver/app/ClaudeClient.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,20 @@ public function remapMessages(array $messages, bool $userLast = false): array
357357
return true;
358358
})
359359
->transform(function (MessageInDto $item) {
360-
/**
361-
* @NOTE
362-
* Claude does not like to end a certain way
363-
*/
364-
$item->content = str(
365-
cleanString($item->content)
366-
)->replaceEnd("\n", '')->trim()->toString();
367-
368-
if (empty($item->content)) {
369-
$item->content = 'See content in thread.';
370-
}
360+
/**
361+
* @NOTE
362+
* Claude does not like to end a certain way
363+
*/
364+
$item->content = str(
365+
cleanString($item->content)
366+
)->replaceEnd("\n", '')->trim()->toString();
367+
368+
if (empty($item->content)) {
369+
$item->content = 'See content in thread.';
370+
}
371371

372-
return $item->toArray();
373-
});
372+
return $item->toArray();
373+
});
374374

375375
/**
376376
* Claude needs me to not use the role tool

Modules/LlmDriver/app/Functions/CreateTasksTool.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
namespace LlmLaraHub\LlmDriver\Functions;
44

55
use App\Models\Message;
6-
use App\Models\Project;
76
use App\Models\Task;
87
use App\Models\User;
9-
use Facades\App\Domains\Sources\WebSearch\GetPage;
108
use Illuminate\Support\Facades\Log;
119
use LlmLaraHub\LlmDriver\Responses\FunctionResponse;
12-
use LlmLaraHub\LlmDriver\ToolsHelper;
1310

1411
class CreateTasksTool extends FunctionContract
1512
{
@@ -26,7 +23,6 @@ class CreateTasksTool extends FunctionContract
2623
ToolTypes::ChatCompletion,
2724
];
2825

29-
3026
public function handle(
3127
Message $message): FunctionResponse
3228
{
@@ -50,7 +46,7 @@ public function handle(
5046
'details' => $details,
5147
'due_date' => $due_date,
5248
'assistant' => $assistant,
53-
'user_id' => ($user_id !== "" && User::whereId($user_id)->exists()) ? $user_id : null,
49+
'user_id' => ($user_id !== '' && User::whereId($user_id)->exists()) ? $user_id : null,
5450
]);
5551
}
5652

Modules/LlmDriver/tests/Feature/CreateTasksToolTest.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@
22

33
namespace LlmLaraHub\LlmDriver\Tests\Feature;
44

5-
use App\Domains\Chat\DateRangesEnum;
6-
use App\Domains\Chat\MetaDataDto;
75
use App\Models\Chat;
8-
use App\Models\Document;
9-
use App\Models\DocumentChunk;
10-
use App\Models\Filter;
116
use App\Models\Message;
127
use App\Models\Project;
13-
use Illuminate\Support\Facades\File;
14-
use LlmLaraHub\LlmDriver\DistanceQuery\DistanceQueryFacade;
15-
use LlmLaraHub\LlmDriver\DistanceQuery\Drivers\PostGres;
168
use LlmLaraHub\LlmDriver\Functions\CreateTasksTool;
17-
use Pgvector\Laravel\Vector;
189
use Tests\TestCase;
1910

2011
class CreateTasksToolTest extends TestCase
@@ -38,7 +29,7 @@ public function test_generates_tasks(): void
3829
'chat_id' => $chat->id,
3930
'args' => [
4031
'tasks' => $data,
41-
]
32+
],
4233
]);
4334

4435
$this->assertDatabaseCount('tasks', 0);

app/Domains/Projects/KickOffProject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class KickOffProject
1010
{
1111
public function handle(Project $project)
1212
{
13-
$chat = $project->chats?->first();
13+
$chat = $project->chats()->first();
1414

1515
$chat->updateQuietly([
1616
'chat_status' => UiStatusEnum::InProgress,

app/Domains/Projects/Orchestrate.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use App\Domains\Messages\RoleEnum;
66
use App\Models\Chat;
7-
use App\Models\Project;
87
use Illuminate\Support\Facades\Log;
98
use LlmLaraHub\LlmDriver\Functions\ToolTypes;
109
use LlmLaraHub\LlmDriver\LlmDriverFacade;

app/Domains/Projects/Prompts/CampaignPromptTemplate.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class CampaignPromptTemplate
66
{
7-
8-
public static function systemPrompt(): string {
7+
public static function systemPrompt(): string
8+
{
99
$now = now()->toISOString();
1010

1111
return <<<PROMPT
@@ -40,7 +40,7 @@ public static function systemPrompt(): string {
4040
public static function prompt(): string
4141
{
4242

43-
return <<<PROMPT
43+
return <<<'PROMPT'
4444
## Unique Selling Proposition (USP)
4545
[What makes your product/service unique? Why should your target audience choose you over competitors?]
4646
@@ -67,6 +67,5 @@ public static function prompt(): string
6767

6868
PROMPT;
6969

70-
7170
}
7271
}

app/Http/Controllers/ProjectController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
namespace App\Http\Controllers;
44

55
use App\Domains\Chat\UiStatusEnum;
6-
use Facades\App\Domains\Projects\KickOffProject;
76
use App\Domains\Projects\Prompts\CampaignPromptTemplate;
87
use App\Domains\Projects\StatusEnum;
98
use App\Http\Resources\ChatResource;
10-
use App\Http\Resources\ProjectResource;
119
use App\Http\Resources\MessageResource;
10+
use App\Http\Resources\ProjectResource;
1211
use App\Http\Resources\ProjectResourceShow;
1312
use App\Models\Chat;
1413
use App\Models\Project;
15-
use Illuminate\Http\Request;
14+
use Facades\App\Domains\Projects\KickOffProject;
1615
use Facades\App\Domains\Projects\Orchestrate;
1716

1817
class ProjectController extends Controller
@@ -36,12 +35,12 @@ public function create()
3635
return inertia('Projects/Create', [
3736
'content_start' => [
3837
[
39-
'key' => "Campaign Template",
38+
'key' => 'Campaign Template',
4039
'content' => CampaignPromptTemplate::prompt(),
4140
'system_prompt' => CampaignPromptTemplate::systemPrompt(),
42-
]
41+
],
4342
],
44-
'statuses' => StatusEnum::selectOptions()
43+
'statuses' => StatusEnum::selectOptions(),
4544
]);
4645
}
4746

@@ -87,7 +86,8 @@ public function show(Project $project)
8786
]);
8887
}
8988

90-
public function showWithChat(Project $project, Chat$chat) {
89+
public function showWithChat(Project $project, Chat $chat)
90+
{
9191

9292
return inertia('Projects/Show', [
9393
'project' => new ProjectResourceShow($project),

app/Http/Resources/MessageResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ class MessageResource extends JsonResource
1515
public function toArray(Request $request): array
1616
{
1717
$user = [];
18-
if($this->user_id) {
18+
if ($this->user_id) {
1919
$user = new UserResource($this->user);
2020
}
21+
2122
return [
2223
'id' => $this->id,
2324
'role' => $this->role->value,

app/Models/Chat.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Chat extends Model implements HasDrivers
3737

3838
public function getDriver(): string
3939
{
40-
if($this->chat_driver) {
40+
if ($this->chat_driver) {
4141
return $this->chat_driver->value;
4242
}
4343

@@ -71,9 +71,10 @@ public function getChatable(): HasDrivers
7171

7272
public function getEmbeddingDriver(): string
7373
{
74-
if($this->embedding_driver) {
74+
if ($this->embedding_driver) {
7575
return $this->embedding_driver->value;
7676
}
77+
7778
return $this->chatable->getEmbeddingDriver();
7879
}
7980

@@ -144,7 +145,7 @@ public function addInputWithTools(
144145
string $message,
145146
mixed $tool_id,
146147
mixed $tool_name,
147-
mixed $tool_args) : Message
148+
mixed $tool_args): Message
148149
{
149150

150151
return DB::transaction(function () use ($message, $tool_id, $tool_name, $tool_args) {
@@ -192,7 +193,8 @@ public function getAiResponse($input)
192193
return $this->getChatResponse();
193194
}
194195

195-
public function getMessageThread(int $limit = 5): array {
196+
public function getMessageThread(int $limit = 5): array
197+
{
196198
return $this->getChatResponse($limit);
197199
}
198200

0 commit comments

Comments
 (0)