quero adaptar essa api para rodar em php laravel:
API documentation
API Recorder
5 API endpoints
Choose a language to see the code snippets for interacting with the API.
- Confirm that you have cURL installed on your system.
copy
$ curl --version
2. Find the API endpoint below corresponding to your desired function in the app. Copy the code snippet, replacing the placeholder values with your own input data. If this is a private Space, you may need to pass your Hugging Face token as well (read more). Or use the
API Recorder
to automatically generate your API requests.
Making a prediction and getting a result requires 2 requests: a POST and a GET request. The POST request returns an EVENT_ID, which is used in the second GET request to fetch the results. In these snippets, we've used awk and read to parse the results, combining these two requests into one command for ease of use. See curl docs.
api_name: /enable_inputs
copy
curl -X POST https://yuntian-deng-chatgpt4.hf.space/call/enable_inputs -s -H "Content-Type: application/json" -d '{
"data": [
]}'
| awk -F'"' '{ print 4}' \
| read EVENT_ID; curl -N https://yuntian-deng-chatgpt4.hf.space/call/enable_inputs/EVENT_ID
Accepts 0 parameters:
Returns 1 element
api_name: /reset_textbox
copy
curl -X POST https://yuntian-deng-chatgpt4.hf.space/call/reset_textbox -s -H "Content-Type: application/json" -d '{
"data": [
]}'
| awk -F'"' '{ print 4}' \
| read EVENT_ID; curl -N https://yuntian-deng-chatgpt4.hf.space/call/reset_textbox/EVENT_ID
Accepts 0 parameters:
Returns 1 element
string
The output value that appears in the "Type an input and press Enter" Textbox component.
api_name: /predict
copy
curl -X POST https://yuntian-deng-chatgpt4.hf.space/call/predict -s -H "Content-Type: application/json" -d '{
"data": [
"Hello!!",
0,
0,
3,
[["Hello!",None]]
]}'
| awk -F'"' '{ print 4}' \
| read EVENT_ID; curl -N https://yuntian-deng-chatgpt4.hf.space/call/predict/EVENT_ID
Accepts 5 parameters:
[0] string Required
The input value that is provided in the "Type an input and press Enter" Textbox component.
[1] number Required
The input value that is provided in the "Top-p (nucleus sampling)" Slider component.
[2] number Required
The input value that is provided in the "Temperature" Slider component.
[3] number Required
The input value that is provided in the "parameter_16" Number component.
[4] any Required
The input value that is provided in the "parameter_4" Chatbot component.
Returns list of 4 elements
[0]
The output value that appears in the "value_4" Chatbot component.
[1] number
The output value that appears in the "value_16" Number component.
[2] string
The output value that appears in the "Status code from OpenAI server" Textbox component.
[3] string
The output value that appears in the "Type an input and press Enter" Textbox component.
api_name: /reset_textbox_1
copy
curl -X POST https://yuntian-deng-chatgpt4.hf.space/call/reset_textbox_1 -s -H "Content-Type: application/json" -d '{
"data": [
]}'
| awk -F'"' '{ print 4}' \
| read EVENT_ID; curl -N https://yuntian-deng-chatgpt4.hf.space/call/reset_textbox_1/EVENT_ID
Accepts 0 parameters:
Returns 1 element
string
The output value that appears in the "Type an input and press Enter" Textbox component.
api_name: /predict_1
copy
curl -X POST https://yuntian-deng-chatgpt4.hf.space/call/predict_1 -s -H "Content-Type: application/json" -d '{
"data": [
"Hello!!",
0,
0,
3,
[["Hello!",None]]
]}'
| awk -F'"' '{ print 4}' \
| read EVENT_ID; curl -N https://yuntian-deng-chatgpt4.hf.space/call/predict_1/EVENT_ID
Accepts 5 parameters:
[0] string Required
The input value that is provided in the "Type an input and press Enter" Textbox component.
[1] number Required
The input value that is provided in the "Top-p (nucleus sampling)" Slider component.
[2] number Required
The input value that is provided in the "Temperature" Slider component.
[3] number Required
The input value that is provided in the "parameter_16" Number component.
[4] any Required
The input value that is provided in the "parameter_4" Chatbot component.
Returns list of 4 elements
[0]
The output value that appears in the "value_4" Chatbot component.
[1] number
The output value that appears in the "value_16" Number component.
[2] string
The output value that appears in the "Status code from OpenAI server" Textbox component.
[3] string
The output value that appears in the "Type an input and press Enter" Textbox component.