Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubKermes committed Apr 17, 2024
1 parent 2390999 commit 23722a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions app/Http/Controllers/RulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public function getRules(string $countryName, string $cityName): array

if (!$rules || $rules->rules_en === null || $rules->rules_pl === null) {
$cityData = [
"city_id" => $city->id,
"country_id" => $country->id,
"city_name" => $city->name,
"country_name" => $country->name,
"cityId" => $city->id,
"countryId" => $country->id,
"cityName" => $city->name,
"countryName" => $country->name,
];
$importer = new OpenAIService();
$data = $importer->importRulesForCity($cityData, true);
Expand All @@ -55,9 +55,8 @@ public function getRules(string $countryName, string $cityName): array
return $data;
}

public function importRules(bool $force): void
public function importRules(bool $force, OpenAIService $importer): void
{
$importer = new OpenAIService();
$importer->importRulesForAllCities($force);
}
}
1 change: 0 additions & 1 deletion app/Models/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class Rules extends Model
{
use HasFactory;

protected $table = "rules_for_cities";
protected $fillable = [
Expand Down
8 changes: 4 additions & 4 deletions app/Services/OpenAIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ public function importRulesForCity(array $cityData, bool $force): array
{
$cityId = $cityData["cityId"];
$countryId = $cityData["countryId"];
$city_name = $cityData["city_name"];
$cityName = $cityData["cityName"];
$countryName = $cityData["countryName"];

$prompt_en = "Act as a helpful assistant. Explain what are the legal limitations for riding electric scooters in $city_name, $countryName? Contain information about: max speed, helmet requirements, allowed ABV, passengers, other relevant details. Be formal, speak English. Don't include city name in your response. If you don't have information answering the question, write 'null'.";
$prompt_en = "Act as a helpful assistant. Explain what are the legal limitations for riding electric scooters in $cityName, $countryName? Contain information about: max speed, helmet requirements, allowed ABV, passengers, other relevant details. Be formal, speak English. Don't include city name in your response. If you don't have information answering the question, write 'null'.";
$prompt_pl = "Translate to polish: ";
$currentRulesInCountry = Rules::query()->where("countryId", $countryId)->first();

Expand All @@ -113,7 +113,7 @@ public function importRulesForCity(array $cityData, bool $force): array

if (strlen($rules_en) < 700 || strlen($rules_pl) < 700) {
return [
"city" => $city_name,
"city" => $cityName,
"country" => $countryName,
"rules_en" => null,
"rules_pl" => null,
Expand All @@ -128,7 +128,7 @@ public function importRulesForCity(array $cityData, bool $force): array
]);

return [
"city" => $city_name,
"city" => $cityName,
"country" => $countryName,
"rules_en" => $rules_en,
"rules_pl" => $rules_pl,
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Importers/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function runImporters() {
}
function runRules() {
router.post('/import-rules/0', [])
router.get('/import-rules/0', [])
toast.success(__('Rules import started.'))
}
</script>
Expand Down

0 comments on commit 23722a6

Please sign in to comment.