Created
November 5, 2020 22:17
-
-
Save JoaoPedroPP/6b379986f641076a934bae8b600cfe1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WML_API = 'SUA_APIKEY_WML' | |
wml_url = 'URL_SCORE_MODELO' | |
def getToken(): | |
header = { | |
"Content-Type": "application/x-www-form-urlencoded", | |
'Authorization': 'Basic Yng6Yng=' | |
} | |
payload = 'apikey={}&grant_type=urn:ibm:params:oauth:grant-type:apikey'.format(WML_API) | |
req = requests.post('https://iam.bluemix.net/oidc/token', data=payload, headers=header) | |
resp = req.json() | |
return resp | |
def score(): | |
token = getToken() | |
header = { | |
"Authorization": "Bearer {}".format(token['access_token']) | |
} | |
params = { | |
'version': '2020-09-01' | |
} | |
payload = { | |
"input_data": [ | |
{ | |
"fields": [Nome dos campos serem utilziados como entrada do modelos] | |
"values": [[valores dos campos]] | |
} | |
] | |
} | |
req = requests.post(wml_url, json=payload, headers=header, params=params) | |
result = req.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment