Add TimescaleDB migration for QDS
This commit is contained in:
90
app/Http/Controllers/ChatbotController.php
Normal file
90
app/Http/Controllers/ChatbotController.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Gemini\Laravel\Facades\Gemini;
|
||||
|
||||
class ChatbotController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
// public function handleMessage(Request $request)
|
||||
// {
|
||||
// $request->validate(['message' => 'required|string']);
|
||||
// $userMessage = $request->input('message');
|
||||
|
||||
// try {
|
||||
// $result = Gemini::geminiPro()->generateContent($userMessage);
|
||||
// $reply = $result->text() ?? 'Sorry, no response from Gemini AI.';
|
||||
// } catch (\Exception $e) {
|
||||
// \Log::error('Gemini API Exception: ' . $e->getMessage(), ['trace' => $e->getTraceAsString()]);
|
||||
// if (config('app.debug')) {
|
||||
// return response()->json(['reply' => 'Error: ' . $e->getMessage()], 500);
|
||||
// }
|
||||
// return response()->json(['reply' => 'Error communicating with Gemini AI. Please try again later.'], 500);
|
||||
// }
|
||||
|
||||
// return response()->json(['reply' => $reply]);
|
||||
// }
|
||||
|
||||
// public function handleMessage(Request $request)
|
||||
// {
|
||||
// $request->validate([
|
||||
// 'message' => 'required|string'
|
||||
// ]);
|
||||
|
||||
// $apiKey = env('GEMINI_API_KEY'); // Put this in .env
|
||||
|
||||
// $response = Http::withHeaders([
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'x-goog-api-key' => $apiKey
|
||||
// ])->post('https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent', [
|
||||
// 'contents' => [
|
||||
// ['parts' => [['text' => $request->message]]]
|
||||
// ]
|
||||
// ]);
|
||||
|
||||
// if ($response->successful()) {
|
||||
// return response()->json([
|
||||
// 'reply' => $response->json()['candidates'][0]['content']['parts'][0]['text'] ?? 'No response.'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// return response()->json(['reply' => 'Failed to fetch response.'], 500);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user