xulh commited on
Commit
47be708
·
1 Parent(s): c2a676a

代码初始化

Browse files
Files changed (1) hide show
  1. inference-api/inference.py +4 -4
inference-api/inference.py CHANGED
@@ -7,12 +7,12 @@ app = FastAPI()
7
  API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment-latest"
8
 
9
 
10
- @app.post("/api-inference/")
11
  def get_version(item: ApiModel):
12
  # payload = {
13
  # "inputs": "Today is a great day",
14
  # }
15
- print("请求参数:", ApiModel)
16
- headers = {"Authorization": ApiModel.token}
17
- response = requests.post(API_URL, headers=headers, json=ApiModel.payload)
18
  return response.json()
 
7
  API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment-latest"
8
 
9
 
10
+ @app.post("/api-inference")
11
  def get_version(item: ApiModel):
12
  # payload = {
13
  # "inputs": "Today is a great day",
14
  # }
15
+ print("请求参数:", item)
16
+ headers = {"Authorization": item.token}
17
+ response = requests.post(API_URL, headers=headers, json=item.payload)
18
  return response.json()