Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Sep 2, 2023
1 parent 17d337b commit 562f6ef
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/Console/Commands/ExampleChatWithFunction.php
Expand Up @@ -33,7 +33,7 @@ public function handle()
$user = User::first();
auth()->login($user);
$question = $this->argument('url');
$question = "Get content for following url " . $question;
$question = 'Get content for following url '.$question;
$messages = [];
$messages[] = [
'role' => 'system',
Expand All @@ -46,7 +46,7 @@ public function handle()
$message = Message::create([
'role' => RoleTypeEnum::User,
'content' => $question,
'user_id' => $user->id
'user_id' => $user->id,
]);
$function = LlmFunction::label('get_content_from_url')->firstOrFail();
$message->llm_functions()->attach([$function->id]);
Expand All @@ -56,7 +56,7 @@ public function handle()
$results = ChatClient::setMessage($message)
->chat($messages);

$this->info("Message ID: " . $message->id);
$this->info('Message ID: '.$message->id);
$this->info($results->content);
}
}
4 changes: 1 addition & 3 deletions app/Console/Commands/QuickChatCommand.php
Expand Up @@ -7,7 +7,6 @@
use App\Models\User;
use Facades\App\OpenAi\ChatClient;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;

class QuickChatCommand extends Command
{
Expand Down Expand Up @@ -43,11 +42,10 @@ public function handle()
'content' => $question,
];


$message = Message::create([
'role' => RoleTypeEnum::User,
'content' => $question,
'user_id' => $user->id
'user_id' => $user->id,
]);

$this->info('Sending request');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/MessageResource.php
Expand Up @@ -24,7 +24,7 @@ public function toArray(Request $request): array
'meta_data' => MetaDataResource::collection($this->meta_data),
'tags' => TagResource::collection($this->tags),
'llm_functions' => LlmFunctionResource::collection($this->llm_functions),
'children' => MessageResource::collection($this->children()->whereNotNull("content")->get()),
'children' => MessageResource::collection($this->children()->whereNotNull('content')->get()),
'created_at' => $this->created_at->diffForHumans(),
'created_at_formatted' => $this->created_at->diffForHumans(),
'tasks' => TaskResource::collection($this->tasks),
Expand Down
5 changes: 3 additions & 2 deletions app/Models/LlmFunction.php
Expand Up @@ -42,8 +42,9 @@ public function getParametersDecodedAttribute(): array
return (array) json_decode($this->parameters, true);
}

public function scopeLabel($query, string $label) {
return $query->where("label", "LIKE", $label);
public function scopeLabel($query, string $label)
{
return $query->where('label', 'LIKE', $label);
}

public function messages(): BelongsToMany
Expand Down
8 changes: 4 additions & 4 deletions app/OpenAi/ChatClient.php
Expand Up @@ -64,10 +64,10 @@ public function chat(array $messages, bool $run_functions = true): Message
$arguments = data_get($response, 'choices.0.message.function_call.arguments');
$dto = FunctionCallDto::from(
[
'arguments' => $arguments,
'function_name' => $name,
'message' => $this->messageModel,
]);
'arguments' => $arguments,
'function_name' => $name,
'message' => $this->messageModel,
]);

logger('Making function call then will reiterate', [
$arguments,
Expand Down

0 comments on commit 562f6ef

Please sign in to comment.