File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,31 @@ class CustomLLMController extends Controller
12
12
13
13
public function create_basic (Request $ request )
14
14
{
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
+ }
16
40
}
17
41
18
42
You can’t perform that action at this time.
0 commit comments