Skip to content

Commit 3847122

Browse files
committed
Remove unused code
1 parent fc41f18 commit 3847122

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

src/Loop.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33
namespace Kirschbaum\Loop;
44

55
use Illuminate\Support\Collection;
6-
use Illuminate\Support\Facades\Auth;
76
use Kirschbaum\Loop\Contracts\Tool;
87
use Kirschbaum\Loop\Contracts\Toolkit;
9-
use Prism\Prism\Enums\Provider;
10-
use Prism\Prism\Prism;
11-
use Prism\Prism\Text\Response;
128
use Prism\Prism\Tool as PrismTool;
13-
use Prism\Prism\ValueObjects\Messages\AssistantMessage;
14-
use Prism\Prism\ValueObjects\Messages\UserMessage;
159

1610
class Loop
1711
{
@@ -42,53 +36,6 @@ public function toolkit(Toolkit $toolkit): static
4236
return $this;
4337
}
4438

45-
/**
46-
* @param Collection<array-key, mixed> $messages
47-
*/
48-
public function ask(string $question, Collection $messages): Response
49-
{
50-
$prompt = sprintf(
51-
"
52-
You are a helpful assistant. You will have many tools available to you. You need to give informations about the data and ask the user what you need to give him what he needs. \n\n
53-
Today is %s. Current month is %s. Current day is %s. Database being used is %s. \n\n
54-
When using the tools, always pass all the parameters listed in the tool. If you don't have all the information, ask the user for it. If it's optional, pass null. \n
55-
When a field is tagged with a access_type read, it means that the field is automatically calculated and is not stored in the database. \n
56-
When referencing an ID, try to fetch the resource of that ID from the database and give additional informations about it. \n\n
57-
When giving the final output, please compress the information to the minimum needed to answer the question. No need to explain what math you did unless explicitly asked. \n\n
58-
Parameter names in tools never include the $ symbol. \n\n
59-
%s \n\n
60-
You are logged in as %s (User ID: %s)
61-
",
62-
now()->format('Y-m-d'),
63-
now()->format('F'),
64-
now()->format('d'),
65-
config()->string('database.default'),
66-
$this->context,
67-
Auth::user()?->name, /** @phpstan-ignore property.notFound */
68-
Auth::user()?->id,
69-
);
70-
dump($prompt);
71-
72-
$messages = $messages
73-
->reject(fn ($message) => empty($message['message']))
74-
->map(function ($message) {
75-
return $message['user'] === 'AI'
76-
? new AssistantMessage($message['message'])
77-
: new UserMessage($message['message']);
78-
})->toArray();
79-
80-
$messages[] = new UserMessage($question);
81-
82-
return Prism::text()
83-
// ->using(Provider::Anthropic, 'claude-3-5-sonnet-latest')
84-
->using(Provider::OpenAI, 'gpt-4o-mini')
85-
->withMaxSteps(10)
86-
->withMessages($messages)
87-
->withSystemPrompt($prompt)
88-
->withTools($this->getPrismTools())
89-
->asText();
90-
}
91-
9239
public function getPrismTools(): Collection
9340
{
9441
return $this->loopTools

0 commit comments

Comments
 (0)