Spaces:
Sleeping
Sleeping
vtrv.vls
commited on
Commit
·
f9d1508
1
Parent(s):
4c98104
API test
Browse files
utils.py
CHANGED
|
@@ -15,8 +15,6 @@ def gen_auth_token(auth_file):
|
|
| 15 |
'RqUID': '1b519047-0ee9-4b63-8599-e5ffc9c77e72',
|
| 16 |
'Authorization': os.getenv('GIGACHAT_API_TOKEN')
|
| 17 |
}
|
| 18 |
-
|
| 19 |
-
print(headers)
|
| 20 |
|
| 21 |
response = requests.request("POST", url, headers=headers, data=payload, verify=False)
|
| 22 |
|
|
@@ -56,13 +54,9 @@ def get_text(content='Привет!', auth_token=None):
|
|
| 56 |
def generate(content='Привет!', auth_file=None):
|
| 57 |
if auth_file is None or not os.path.isfile(auth_file):
|
| 58 |
gen_auth_token(auth_file)
|
| 59 |
-
|
| 60 |
-
print(os.listdir())
|
| 61 |
|
| 62 |
with open(auth_file) as f:
|
| 63 |
auth_token = json.load(f)
|
| 64 |
-
|
| 65 |
-
print(auth_token)
|
| 66 |
|
| 67 |
if datetime.fromtimestamp(auth_token['expires_at']/1000) <= datetime.now() - timedelta(seconds=60):
|
| 68 |
gen_auth_token()
|
|
|
|
| 15 |
'RqUID': '1b519047-0ee9-4b63-8599-e5ffc9c77e72',
|
| 16 |
'Authorization': os.getenv('GIGACHAT_API_TOKEN')
|
| 17 |
}
|
|
|
|
|
|
|
| 18 |
|
| 19 |
response = requests.request("POST", url, headers=headers, data=payload, verify=False)
|
| 20 |
|
|
|
|
| 54 |
def generate(content='Привет!', auth_file=None):
|
| 55 |
if auth_file is None or not os.path.isfile(auth_file):
|
| 56 |
gen_auth_token(auth_file)
|
|
|
|
|
|
|
| 57 |
|
| 58 |
with open(auth_file) as f:
|
| 59 |
auth_token = json.load(f)
|
|
|
|
|
|
|
| 60 |
|
| 61 |
if datetime.fromtimestamp(auth_token['expires_at']/1000) <= datetime.now() - timedelta(seconds=60):
|
| 62 |
gen_auth_token()
|