Spaces:
Sleeping
Sleeping
vtrv.vls
commited on
Commit
·
0cea943
1
Parent(s):
7815cda
New API
Browse files
app.py
CHANGED
@@ -19,6 +19,7 @@ def giga_gen(content, chat_history):
|
|
19 |
chat_history = []
|
20 |
else:
|
21 |
chat_history.append({"role": "user", "content": content})
|
|
|
22 |
res = generate(chat_history,'auth_token.json')
|
23 |
send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
|
24 |
print(chat_history)
|
|
|
19 |
chat_history = []
|
20 |
else:
|
21 |
chat_history.append({"role": "user", "content": content})
|
22 |
+
print(chat_history)
|
23 |
res = generate(chat_history,'auth_token.json')
|
24 |
send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
|
25 |
print(chat_history)
|
utils.py
CHANGED
@@ -24,18 +24,13 @@ def gen_auth_token(auth_file):
|
|
24 |
json.dump(json.loads(response.text), f, ensure_ascii=False)
|
25 |
|
26 |
|
27 |
-
def get_text(content
|
28 |
# url = "https://gigachat.devices.sberbank.ru/api/v1/chat/completions"
|
29 |
url = "https://api.mlrnd.ru/api/v1/chat/completions"
|
30 |
|
31 |
payload = json.dumps({
|
32 |
"model": "Test_model",
|
33 |
-
"messages":
|
34 |
-
{
|
35 |
-
"role": "user",
|
36 |
-
"content": content
|
37 |
-
}
|
38 |
-
],
|
39 |
"temperature": 1,
|
40 |
"top_p": 0.1,
|
41 |
"n": 1,
|
@@ -67,6 +62,7 @@ def generate(content='Привет!', auth_file=None):
|
|
67 |
auth_token = json.load(f)
|
68 |
|
69 |
resp = get_text(content, auth_token['access_token'])
|
|
|
70 |
|
71 |
return resp["choices"][0]["message"]["content"]
|
72 |
|
|
|
24 |
json.dump(json.loads(response.text), f, ensure_ascii=False)
|
25 |
|
26 |
|
27 |
+
def get_text(content, auth_token=None):
|
28 |
# url = "https://gigachat.devices.sberbank.ru/api/v1/chat/completions"
|
29 |
url = "https://api.mlrnd.ru/api/v1/chat/completions"
|
30 |
|
31 |
payload = json.dumps({
|
32 |
"model": "Test_model",
|
33 |
+
"messages": content,
|
|
|
|
|
|
|
|
|
|
|
34 |
"temperature": 1,
|
35 |
"top_p": 0.1,
|
36 |
"n": 1,
|
|
|
62 |
auth_token = json.load(f)
|
63 |
|
64 |
resp = get_text(content, auth_token['access_token'])
|
65 |
+
print(resp)
|
66 |
|
67 |
return resp["choices"][0]["message"]["content"]
|
68 |
|