Skip to content

Commit

Permalink
Flera IDn kan skickas till skapa sammanfattning
Browse files Browse the repository at this point in the history
  • Loading branch information
bonny committed Apr 22, 2024
1 parent 18f2797 commit 177759f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/Console/Commands/CreateAISummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CreateAISummary extends Command {
*
* @var string
*/
protected $signature = 'crimeevents:create-summary {eventID}';
protected $signature = 'crimeevents:create-summary {eventID*}';

/**
* The console command description.
Expand All @@ -27,10 +27,13 @@ class CreateAISummary extends Command {
* @return int
*/
public function handle() {
$crimeEventId = $this->argument('eventID');
$crimeEventIds = $this->argument('eventID');

$this->line('Ok, let\'s go!');
$this->line('Skapar sammanfattning av händelse med id ' . $crimeEventId);
$this->generateSummary($crimeEventId);

foreach ($crimeEventIds as $crimeEventId) {
$this->generateSummary($crimeEventId);
}
return Command::SUCCESS;
}

Expand Down Expand Up @@ -66,11 +69,11 @@ protected function generateSummary($crimeEventId) {
$yourApiKey = getenv('OPEN_AI_API_KEY');
$client = \OpenAI::client($yourApiKey);

$crimeEvent = CrimeEvent::find($crimeEventId);
$crimeEvent = CrimeEvent::findOrFail($crimeEventId);
$userMessageContent =
"<h1>" . $crimeEvent->parsed_title . '</h1>'. PHP_EOL . '<p>' . $crimeEvent->parsed_teaser . '</p>' . PHP_EOL . $crimeEvent->autop($crimeEvent->parsed_content);
// $userMessageContent = strip_tags($userMessageContent);

$this->newLine();
$this->line("Hittade händelse " . $crimeEvent->parsed_date . ': ' . $crimeEvent->parsed_title);
$this->newLine();
// echo "chat instructions:\n" . $this->getChatInstruction() . "\n";exit;
Expand Down

0 comments on commit 177759f

Please sign in to comment.