Merge remote-tracking branch 'origin/feature/chatbot-sidebar' into dev
This commit is contained in:
@@ -76,9 +76,29 @@ class ChatbotController extends Controller
|
||||
return response()->json(['response' => ''], 500);
|
||||
}
|
||||
|
||||
public function mainGenerateText(Request $request)
|
||||
{
|
||||
// Log hanya data yang relevan
|
||||
info("Received prompt: " . $request->input('prompt'));
|
||||
|
||||
private function classifyContent(string $prompt) {
|
||||
$classifyResponse = $this->openAIService->generateClassifyContent($prompt);
|
||||
return $classifyResponse;
|
||||
// Validasi input
|
||||
$request->validate([
|
||||
'prompt' => 'required|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
// Panggil service untuk generate text
|
||||
$response = $this->openAIService->mainGenerateText($request->input('prompt'));
|
||||
|
||||
return response()->json(['response' => $response]);
|
||||
} catch (\Exception $e) {
|
||||
// Tangani error dan log exception
|
||||
\Log::error("Error generating text: " . $e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'error' => ''
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ChatbotPimpinan;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ChatbotPimpinanController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('chatbot-pimpinan.index');
|
||||
}
|
||||
}
|
||||
@@ -152,6 +152,33 @@ class OpenAIService
|
||||
]);
|
||||
|
||||
return trim($response['choices'][0]['message']['content'] ?? 'No response');
|
||||
}
|
||||
}
|
||||
|
||||
public function mainGenerateText($prompt) {
|
||||
$response = $this->client->chat()->create([
|
||||
'model' => 'gpt-4o-mini',
|
||||
'messages' => [
|
||||
[
|
||||
'role' => 'system',
|
||||
'content' => "You are an expert assistant with deep knowledge in multiple fields, including programming, data science, and business strategy. Provide clear, concise, and accurate responses."
|
||||
],
|
||||
[
|
||||
'role' => 'user',
|
||||
'content' => $prompt
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return trim($response['choices'][0]['message']['content'] ?? 'No response');
|
||||
}
|
||||
|
||||
// 1. Buat fungsi untuk akses data advertisements
|
||||
// 2. Buat fungsi untuk akses data business_or_industries
|
||||
// 3. Buat fungsi untuk akses data customers
|
||||
// 4. Buat fungsi untuk akses data pbg_task
|
||||
// 5. Buat fungsi untuk akses data pbg_task_retribution
|
||||
// 6. Buat fungsi untuk akses data spatial_plannings
|
||||
// 7. Buat fungsi untuk akses data tourisms
|
||||
// 8. Buat fungsi untuk akses data umkms
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user