Skip to content

Commit

Permalink
Update Basic Function
Browse files Browse the repository at this point in the history
  • Loading branch information
kaustubhkagrawal committed Feb 11, 2024
1 parent 233d46c commit 7748283
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion app/Http/Controllers/CustomLLMController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,31 @@ class CustomLLMController extends Controller

public function create_basic(Request $request)
{
return 'custom_llm_basic';
try {

$data = $request->json()->all();
$messages = $data['messages'];

$response = [
'id' => 'chatcmpl-8mcLf78g0quztp4BMtwd3hEj58Uof',
'object' => 'chat.completion',
'created' => time(),
'model' => 'gpt-3.5-turbo-0613',
'system_fingerprint' => null,
'choices' => [
[
'index' => 0,
'delta' => ['content' => $messages[count($messages) - 1]['content'] ?? ''],
'logprobs' => null,
'finish_reason' => 'stop',
],
],
];

return response()->json($response, 201);
} catch (\Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}


Expand Down

0 comments on commit 7748283

Please sign in to comment.