Skip to content

Commit 7748283

Browse files
Update Basic Function
1 parent 233d46c commit 7748283

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

app/Http/Controllers/CustomLLMController.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,31 @@ class CustomLLMController extends Controller
1212

1313
public function create_basic(Request $request)
1414
{
15-
return 'custom_llm_basic';
15+
try {
16+
17+
$data = $request->json()->all();
18+
$messages = $data['messages'];
19+
20+
$response = [
21+
'id' => 'chatcmpl-8mcLf78g0quztp4BMtwd3hEj58Uof',
22+
'object' => 'chat.completion',
23+
'created' => time(),
24+
'model' => 'gpt-3.5-turbo-0613',
25+
'system_fingerprint' => null,
26+
'choices' => [
27+
[
28+
'index' => 0,
29+
'delta' => ['content' => $messages[count($messages) - 1]['content'] ?? ''],
30+
'logprobs' => null,
31+
'finish_reason' => 'stop',
32+
],
33+
],
34+
];
35+
36+
return response()->json($response, 201);
37+
} catch (\Exception $e) {
38+
return response()->json(['error' => $e->getMessage()], 500);
39+
}
1640
}
1741

1842

0 commit comments

Comments
 (0)