Update app.py
Browse files
app.py
CHANGED
@@ -51,55 +51,54 @@ if uploaded_file is not None:
|
|
51 |
transcript = convert_segments_object_to_text(result_diar)
|
52 |
st.text(transcript)
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
password = st.secrets["GIGA_SECRET"]
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
data = {
|
73 |
-
'scope': os.getenv('GIGA_SCOPE')
|
74 |
-
}
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
"model": os.getenv('GIGA_MODEL'),
|
84 |
-
"messages": [
|
85 |
-
{
|
86 |
-
"role": "user",
|
87 |
-
"content": giga_base_prompt + transcript
|
88 |
-
}
|
89 |
-
],
|
90 |
-
"stream": False,
|
91 |
-
"max_tokens": int(giga_max_tokens),
|
92 |
-
})
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
98 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
st.write("Результат резюмирования:")
|
105 |
st.text(answer_from_llm)
|
|
|
51 |
transcript = convert_segments_object_to_text(result_diar)
|
52 |
st.text(transcript)
|
53 |
|
54 |
+
with st.spinner('Резюмируем...'):
|
55 |
+
username = st.secrets["GIGA_USERNAME"]
|
56 |
+
password = st.secrets["GIGA_SECRET"]
|
|
|
57 |
|
58 |
+
# Получаем строку с базовой авторизацией в формате Base64
|
59 |
+
auth_str = f'{username}:{password}'
|
60 |
+
auth_bytes = auth_str.encode('utf-8')
|
61 |
+
auth_base64 = base64.b64encode(auth_bytes).decode('utf-8')
|
62 |
+
url = os.getenv('GIGA_AUTH_URL')
|
63 |
|
64 |
+
headers = {
|
65 |
+
'Authorization': f'Basic {auth_base64}', # вставляем базовую авторизацию
|
66 |
+
'RqUID': os.getenv('GIGA_rquid'),
|
67 |
+
'Content-Type': 'application/x-www-form-urlencoded',
|
68 |
+
'Accept': 'application/json'
|
69 |
+
}
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
data = {
|
72 |
+
'scope': os.getenv('GIGA_SCOPE')
|
73 |
+
}
|
74 |
|
75 |
+
response = requests.post(url, headers=headers, data=data, verify=False)
|
76 |
+
access_token = response.json()['access_token']
|
77 |
+
print('Got access token')
|
78 |
|
79 |
+
url_completion = os.getenv('GIGA_COMPLETION_URL')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
+
data_copm = json.dumps({
|
82 |
+
"model": os.getenv('GIGA_MODEL'),
|
83 |
+
"messages": [
|
84 |
+
{
|
85 |
+
"role": "user",
|
86 |
+
"content": giga_base_prompt + transcript
|
87 |
}
|
88 |
+
],
|
89 |
+
"stream": False,
|
90 |
+
"max_tokens": int(giga_max_tokens),
|
91 |
+
})
|
92 |
+
|
93 |
+
headers_comp = {
|
94 |
+
'Content-Type': 'application/json',
|
95 |
+
'Accept': 'application/json',
|
96 |
+
'Authorization': 'Bearer ' + access_token
|
97 |
+
}
|
98 |
|
99 |
+
response = requests.post(url_completion, headers=headers_comp, data=data_copm, verify=False)
|
100 |
+
response_data = response.json()
|
101 |
+
answer_from_llm = response_data['choices'][0]['message']['content']
|
102 |
|
103 |
st.write("Результат резюмирования:")
|
104 |
st.text(answer_from_llm)
|