|
import os |
|
import requests |
|
|
|
API_URL = os.environ['HF_API_URL'] |
|
headers = { |
|
"Accept": "application/json", |
|
"Authorization": f"Bearer {os.environ['HF_API_KEY']}", |
|
"Content-Type": "application/json" |
|
} |
|
|
|
|
|
def query(payload): |
|
response = requests.post(API_URL, headers=headers, json=payload) |
|
return response.json() |
|
|
|
|
|
sentence = '''讚讜讚 讘谉-讙讜专讬讜谉 (16 讘讗讜拽讟讜讘专 1886 - 讜' 讘讻住诇讜 转砖诇"讚) 讛讬讛 诪讚讬谞讗讬 讬砖专讗诇讬 讜专讗砖 讛诪诪砖诇讛 讛专讗砖讜谉 砖诇 诪讚讬谞转 讬砖专讗诇.''' |
|
|
|
output = query({ |
|
"inputs": sentence, |
|
"parameters": { |
|
"aggregation_strategy": "simple" |
|
} |
|
}) |
|
|
|
print(output) |
|
|