Skip to content

Commit

Permalink
oops pint was not setup
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Mar 26, 2024
1 parent e58d796 commit c7a8107
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 107 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/AddTeamMember.php
Expand Up @@ -18,7 +18,7 @@ class AddTeamMember implements AddsTeamMembers
/**
* Add a new team member to the given team.
*/
public function add(User $user, Team $team, string $email, string $role = null): void
public function add(User $user, Team $team, string $email, ?string $role = null): void
{
Gate::forUser($user)->authorize('addTeamMember', $team);

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/InviteTeamMember.php
Expand Up @@ -21,7 +21,7 @@ class InviteTeamMember implements InvitesTeamMembers
/**
* Invite a new team member to the given team.
*/
public function invite(User $user, Team $team, string $email, string $role = null): void
public function invite(User $user, Team $team, string $email, ?string $role = null): void
{
Gate::forUser($user)->authorize('addTeamMember', $team);

Expand Down
18 changes: 9 additions & 9 deletions app/Console/Commands/Archive/QueryEmbedding.php
Expand Up @@ -72,15 +72,15 @@ public function handle()
$reply = '';

foreach ($stream as $response) {
$step = $response->choices[0]->toArray();
$reply = $reply.' '.data_get($step, 'delta.content');
if ($count >= 20) {
$this->info($reply);
$count = 0;
$reply = '';
} else {
$count = $count + 1;
}
$step = $response->choices[0]->toArray();
$reply = $reply.' '.data_get($step, 'delta.content');
if ($count >= 20) {
$this->info($reply);
$count = 0;
$reply = '';
} else {
$count = $count + 1;
}
}

}
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/Generators/OutboundGenerator.php
Expand Up @@ -17,9 +17,9 @@ public function handle(): int
$description = $this->ask('A description to let the user know what it is for');

$results = sprintf("Does this look right, the name is %s, the description is %s and requires settings '%s'.",
$name,
$description,
false);
$name,
$description,
false);

if (! $this->confirm($results)) {
$this->error('Ok try again');
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/Generators/ResponseTypeGenerator.php
Expand Up @@ -21,9 +21,9 @@ public function handle(): int
]);

$results = sprintf("Does this look right, the name is %s, the description is %s and requires settings '%s'.",
$name,
$description,
$requires_settings);
$name,
$description,
$requires_settings);

if (! $this->confirm($results)) {
$this->error('Ok try again');
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/Generators/SourceGenerator.php
Expand Up @@ -17,9 +17,9 @@ public function handle(): int
$description = $this->ask('A description to let the user know what it is for');

$results = sprintf("Does this look right, the name is %s, the description is %s and requires settings '%s'.",
$name,
$description,
false);
$name,
$description,
false);

if (! $this->confirm($results)) {
$this->error('Ok try again');
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/Generators/TransformerGenerator.php
Expand Up @@ -17,9 +17,9 @@ public function handle(): int
$description = $this->ask('A description to let the user know what it is for');

$results = sprintf("Does this look right, the name is %s, the description is %s and requires settings '%s'.",
$name,
$description,
false);
$name,
$description,
false);

if (! $this->confirm($results)) {
$this->error('Ok try again');
Expand Down
4 changes: 2 additions & 2 deletions app/Generators/VueGenerator.php
Expand Up @@ -24,8 +24,8 @@ protected function makeVue()
File::makeDirectory(sprintf('%s/Partials', $rootPath), 0755, true, true);

$path = sprintf($this->generatorRepository->getRootPathOrStubs().'Vue/%s/%s',
str($this->generatorName)->plural()->toString(),
$this->generatorName);
str($this->generatorName)->plural()->toString(),
$this->generatorName);

$files = File::allFiles($path);

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/DeleteSourceController.php
Expand Up @@ -16,8 +16,8 @@ public function delete(Source $source)
DB::transaction(function () use ($source) {
/** @phpstan-ignore-next-line */
$source->documents->each(function (Document $document) {
$document->document_chunks()->delete();
$document->delete();
$document->document_chunks()->delete();
$document->delete();
});

$source->delete();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/OutboundController.php
Expand Up @@ -21,8 +21,8 @@ public function __invoke(Project $project, Outbound $outbound)
$user = auth()->user();
$request = $validated['question'];

/** @var ResponseDto $response */
$response = $outbound->run($user, $request);
/** @var ResponseDto $response */
$response = $outbound->run($user, $request);

return response($response->response->contents->toArray(), $response->status);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectController.php
Expand Up @@ -21,7 +21,7 @@ public function index()
'projects' => Project::query()
->with('sources', 'outbounds')
->where('team_id',
auth()->user()->current_team_id)
auth()->user()->current_team_id)
->orderBy('updated_at', 'DESC')
->simplePaginate(10)
->withQueryString(),
Expand Down
Expand Up @@ -10,26 +10,26 @@ class ChatGptRetrievalResponseTypeController extends BaseResponseTypeController
{
public function create(Outbound $outbound)
{
ResponseType::create([
'type' => ResponseTypeEnum::ChatGptRetrieval,
'order' => $outbound->response_types->count() + 1,
'outbound_id' => $outbound->id,
'prompt_token' => [],
'meta_data' => [],
]);
ResponseType::create([
'type' => ResponseTypeEnum::ChatGptRetrieval,
'order' => $outbound->response_types->count() + 1,
'outbound_id' => $outbound->id,
'prompt_token' => [],
'meta_data' => [],
]);

request()->session()->flash('flash.banner', 'Response Type created, this one has no settings 👉');
request()->session()->flash('flash.banner', 'Response Type created, this one has no settings 👉');

return back();
return back();
}

public function store(Outbound $outbound)
{
public function store(Outbound $outbound)
{
// TODO: Implement store() method.
}

public function update(Outbound $outbound, ResponseType $response_type)
{
public function update(Outbound $outbound, ResponseType $response_type)
{
// TODO: Implement update() method.
}
}
12 changes: 6 additions & 6 deletions app/LLMModels/OpenAi/ClientWrapper.php
Expand Up @@ -110,9 +110,9 @@ public function generateImage($prompt): string
}

public function projectChat(Project $project,
User $user,
array $messages,
$tries = 1): string|\Exception
User $user,
array $messages,
$tries = 1): string|\Exception
{
if (config('openai.mock')) {
$data = get_fixture('completion_response.json');
Expand Down Expand Up @@ -177,9 +177,9 @@ public function projectChat(Project $project,
}

public function nonStreamProjectChat(Project $project,
User $user,
array $messages,
$tries = 1): string|\Exception
User $user,
array $messages,
$tries = 1): string|\Exception
{

$messages = clean_messages($messages);
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Document.php
Expand Up @@ -57,7 +57,7 @@ public function project()
);
}

public function directoryForFile(): string|null
public function directoryForFile(): ?string
{
if (in_array($this->source->type, [
SourceEnum::WebFile,
Expand Down Expand Up @@ -87,7 +87,7 @@ protected static function booted()
});
}

public function pathToFile(): string|null
public function pathToFile(): ?string
{
if (in_array($this->source->type, [
SourceEnum::WebFile,
Expand Down
30 changes: 15 additions & 15 deletions app/ResponseType/ContentCollection.php
Expand Up @@ -7,22 +7,22 @@

class ContentCollection extends \Spatie\LaravelData\Data
{
public function __construct(
#[DataCollectionOf(Content::class)]
public DataCollection $contents,
public mixed $raw = []
) {
}
public function __construct(
#[DataCollectionOf(Content::class)]
public DataCollection $contents,
public mixed $raw = []
) {
}

public function getFirstContent(): Content|null
{
return $this->contents->first();
}
public function getFirstContent(): ?Content
{
return $this->contents->first();
}

public static function emptyContent()
{
return ContentCollection::from([
'contents' => Content::collection([]),
]);
public static function emptyContent()
{
return ContentCollection::from([
'contents' => Content::collection([]),
]);
}
}
3 changes: 1 addition & 2 deletions app/ResponseType/Types/ChatUi.php
Expand Up @@ -144,8 +144,7 @@ protected function makeAssistantMessage(string $content): Message
private function noSystemMessage(): bool
{
return ! Message::query()

->select(['role', 'content'])
->select(['role', 'content'])
->where('user_id', $this->user->id)
->where('project_id', $this->project->id)
->where('role', 'system')
Expand Down
2 changes: 1 addition & 1 deletion app/ResponseType/Types/PregReplace.php
Expand Up @@ -22,7 +22,7 @@ public function handle(ResponseType $responseType): ResponseDto
}

if ($preg_replace_pattern) {
$this->response_dto->response->contents->map(function ($document) use ($preg_replace_pattern, $preg_replace_replacement) {
$this->response_dto->response->contents->map(function ($document) use ($preg_replace_pattern, $preg_replace_replacement) {
$document->content = preg_replace($preg_replace_pattern, $preg_replace_replacement, $document->content);

return $document;
Expand Down
14 changes: 7 additions & 7 deletions app/helpers.php
Expand Up @@ -25,12 +25,12 @@ function clean_messages(array $messages): array
function file_name_from_url(string $url): string
{
return str($url)->beforeLast('?')->afterLast('/')
->when(! str($url)->endsWith('.html'), function (Stringable $string) {
return $string->append('.html');
})
->whenStartsWith('.', function ($item) {
/** @var Stringable $item */
return $item->prepend('index');
})->toString();
->when(! str($url)->endsWith('.html'), function (Stringable $string) {
return $string->append('.html');
})
->whenStartsWith('.', function ($item) {
/** @var Stringable $item */
return $item->prepend('index');
})->toString();
}
}
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Expand Up @@ -52,7 +52,7 @@ public function unverified(): static
/**
* Indicate that the user should have a personal team.
*/
public function withPersonalTeam(callable $callback = null): static
public function withPersonalTeam(?callable $callback = null): static
{
if (! Features::hasTeamFeatures()) {
return $this->state([]);
Expand Down
Expand Up @@ -14,17 +14,17 @@ public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->text('two_factor_secret')
->after('password')
->nullable();
->after('password')
->nullable();

$table->text('two_factor_recovery_codes')
->after('two_factor_secret')
->nullable();
->after('two_factor_secret')
->nullable();

if (Fortify::confirmsTwoFactorAuthentication()) {
$table->timestamp('two_factor_confirmed_at')
->after('two_factor_recovery_codes')
->nullable();
->after('two_factor_recovery_codes')
->nullable();
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions routes/api.php
Expand Up @@ -17,12 +17,12 @@
*/

Route::any('/projects/{project}/sources/{source}/webhook',
[WebHookSourceController::class, 'webhook'])
[WebHookSourceController::class, 'webhook'])
->name('api.sources.webhook');

Route::middleware('auth:sanctum')
->get('/outbounds/{outbound}/response_types/{response_type}/chat_api',
[ChatApiResponseTypeController::class, 'api'])
[ChatApiResponseTypeController::class, 'api'])
->name('api.outbound.response_types.chat_api');

Route::middleware('auth:sanctum')->controller(ChatGptRetrievalOutboundController::class)->group(
Expand Down
6 changes: 3 additions & 3 deletions routes/web.php
Expand Up @@ -154,9 +154,9 @@ function () {
config('jetstream.auth_session'),
'verified',
])->group(function () {
Route::get('/projects/{project}/outbounds', function (Project $project) {
return response($project->outbounds);
})->name('projects.outbounds');
Route::get('/projects/{project}/outbounds', function (Project $project) {
return response($project->outbounds);
})->name('projects.outbounds');
});

Route::middleware([
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/ClientWrapperTest.php
Expand Up @@ -104,9 +104,9 @@ public function test_embeddings()
Tags: flowers; abstract; symbolism
EOL;

$response = ClientWrapper::getEmbedding($fixture);
$response = ClientWrapper::getEmbedding($fixture);

$this->assertInstanceOf(EmbeddingsResponseDto::class, $response);
$this->assertInstanceOf(EmbeddingsResponseDto::class, $response);

}

Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/ContentCollectionTest.php
Expand Up @@ -21,8 +21,8 @@ public function test_can_deal_with_documents()
'contents' => Content::collection(DocumentChunk::get()),
]);

expect($collection->contents)->toBeInstanceOf(DataCollection::class);
expect($collection->contents->first())->toBeInstanceOf(Content::class);
expect($collection->contents)->toBeInstanceOf(DataCollection::class);
expect($collection->contents->first())->toBeInstanceOf(Content::class);
}

public function test_converts()
Expand Down

0 comments on commit c7a8107

Please sign in to comment.