🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 请求URL: POST /api/index/ ## ****模型接口**** ~~~ prompt:对话内容,例子:你好 history:上下文,例子:[['客户','AI'],['客户','AI'],['客户','AI']] ,注意:格式正常才会生产上下文,如无上下文检查数据格式是否正确 token:登录token,例子:0c916b868bb1b71996ee42f1c127a4bd ~~~ ***** curl ``` curl --location --request POST 'http://36.134.166.120:5001/api/index/' \\ \--header 'Content-Type: application/json' \\ \--header 'Accept: \*/\*' \\ \--header 'Host: 36.134.166.120:5001' \\ \--header 'Connection: keep-alive' \\ \--data-raw '{ "prompt": "你好", "history": \[\], "token":"0c916b868bb1b71996ee42f1c127a4bd" }' ``` ***** javascript ``` var settings = { "url": "http://36.134.166.120:5001/api/index/", "method": "POST", "timeout": 0, "headers": { "Content-Type": "application/json", "Accept": "\*/\*", "Host": "36.134.166.120:5001", "Connection": "keep-alive"    }, "data": JSON.stringify({ "prompt": "你好", "history": \[\], "token": "0c916b868bb1b71996ee42f1c127a4bd"    }), }; $.ajax(settings).done(function (response) {    console.log(response); }); ``` ***** java(Unirest) ``` Unirest.setTimeouts(0, 0); HttpResponse response = Unirest.post("http://36.134.166.120:5001/api/index/")    .header("Content-Type", "application/json")    .header("Accept", "\*/\*")    .header("Host", "36.134.166.120:5001")    .header("Connection", "keep-alive")    .body("{\\r\\n    \\"prompt\\": \\"你好\\",\\r\\n    \\"history\\": \[\],\\r\\n    \\"token\\":\\"0c916b868bb1b71996ee42f1c127a4bd\\"\\r\\n}")    .asString(); ``` ***** PHP(curl) ``` <?php $curl = curl\_init(); curl\_setopt\_array($curl, array( CURLOPT\_URL => 'http://36.134.166.120:5001/api/index/', CURLOPT\_RETURNTRANSFER => true, CURLOPT\_ENCODING => '', CURLOPT\_MAXREDIRS => 10, CURLOPT\_TIMEOUT => 0, CURLOPT\_FOLLOWLOCATION => true,    CURLOPT\_HTTP\_VERSION => CURL\_HTTP\_VERSION\_1\_1, CURLOPT\_CUSTOMREQUEST => 'POST',    CURLOPT\_POSTFIELDS =>'{     "prompt": "你好",     "history": \[\],     "token":"0c916b868bb1b71996ee42f1c127a4bd" }', CURLOPT\_HTTPHEADER => array( 'Content-Type: application/json', 'Accept: \*/\*', 'Host: 36.134.166.120:5001', 'Connection: keep-alive'    ), )); $response = curl\_exec($curl); curl\_close($curl); echo $response; ``` ***** python ``` import http.client import json conn = http.client.HTTPSConnection("36.134.166.120", 5001) payload = json.dumps({ "prompt": "你好", "history": \[\], "token": "0c916b868bb1b71996ee42f1c127a4bd" }) headers = { 'Content-Type': 'application/json', 'Accept': '\*/\*', 'Host': '36.134.166.120:5001', 'Connection': 'keep-alive' } conn.request("POST", "/api/index/", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ***** C# ``` var client = new RestClient("http://36.134.166.120:5001/api/index/"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Accept", "\*/\*"); request.AddHeader("Host", "36.134.166.120:5001"); request.AddHeader("Connection", "keep-alive"); var body = @"{ " + "\\n" + @"    ""prompt"": ""你好"", " + "\\n" + @"    ""history"": \[\], " + "\\n" + @"    ""token"":""0c916b868bb1b71996ee42f1c127a4bd"" " + "\\n" + @"}"; request.AddParameter("application/json", body,  ParameterType.RequestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` ***** #### ’**以上模型接口请求是流响应**