Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,9 @@ device = st.sidebar.selectbox("Device", ["cpu", "cuda"], index=1)
|
|
14 |
batch_size = st.sidebar.number_input("Batch Size", min_value=1, value=16)
|
15 |
compute_type = st.sidebar.selectbox("Compute Type", ["float16", "int8"], index=0)
|
16 |
|
|
|
|
|
|
|
17 |
ACCESS_TOKEN = st.secrets["HF_TOKEN"]
|
18 |
|
19 |
uploaded_file = st.file_uploader("Загрузите аудиофайл", type=["mp4", "wav", "m4a"])
|
@@ -46,54 +49,55 @@ if uploaded_file is not None:
|
|
46 |
transcript = convert_segments_object_to_text(result_diar)
|
47 |
st.text(transcript)
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
st.write("Результат резюмирования:")
|
99 |
st.text(answer_from_llm)
|
|
|
14 |
batch_size = st.sidebar.number_input("Batch Size", min_value=1, value=16)
|
15 |
compute_type = st.sidebar.selectbox("Compute Type", ["float16", "int8"], index=0)
|
16 |
|
17 |
+
giga_base_prompt = st.sidebar.text_area("Промпт ГигаЧата для резюмирования")
|
18 |
+
giga_max_tokens = st.sidebar.number_input("Максимальное количество токенов при ответе", min_value=1, value=2048)
|
19 |
+
|
20 |
ACCESS_TOKEN = st.secrets["HF_TOKEN"]
|
21 |
|
22 |
uploaded_file = st.file_uploader("Загрузите аудиофайл", type=["mp4", "wav", "m4a"])
|
|
|
49 |
transcript = convert_segments_object_to_text(result_diar)
|
50 |
st.text(transcript)
|
51 |
|
52 |
+
if st.button('Резюмировать'):
|
53 |
+
with st.spinner('Резюмируем...'):
|
54 |
+
username = st.secrets["GIGA_USERNAME"]
|
55 |
+
password = st.secrets["GIGA_SECRET"]
|
56 |
|
57 |
+
# Получаем строку с базовой авторизацией в формате Base64
|
58 |
+
auth_str = f'{username}:{password}'
|
59 |
+
auth_bytes = auth_str.encode('utf-8')
|
60 |
+
auth_base64 = base64.b64encode(auth_bytes).decode('utf-8')
|
61 |
+
url = os.getenv('GIGA_AUTH_URL')
|
62 |
|
63 |
+
headers = {
|
64 |
+
'Authorization': f'Basic {auth_base64}', # вставляем базовую авторизацию
|
65 |
+
'RqUID': os.getenv('GIGA_rquid'),
|
66 |
+
'Content-Type': 'application/x-www-form-urlencoded',
|
67 |
+
'Accept': 'application/json'
|
68 |
+
}
|
69 |
|
70 |
+
data = {
|
71 |
+
'scope': os.getenv('GIGA_SCOPE')
|
72 |
+
}
|
73 |
|
74 |
+
response = requests.post(url, headers=headers, data=data, verify=False)
|
75 |
+
access_token = response.json()['access_token']
|
76 |
+
print('Got access token')
|
77 |
|
78 |
+
url_completion = os.getenv('GIGA_COMPLETION_URL')
|
79 |
|
80 |
+
data_copm = json.dumps({
|
81 |
+
"model": os.getenv('GIGA_MODEL'),
|
82 |
+
"messages": [
|
83 |
+
{
|
84 |
+
"role": "user",
|
85 |
+
"content": giga_base_prompt + transcript
|
86 |
+
}
|
87 |
+
],
|
88 |
+
"stream": False,
|
89 |
+
"max_tokens": int(giga_max_tokens),
|
90 |
+
})
|
91 |
|
92 |
+
headers_comp = {
|
93 |
+
'Content-Type': 'application/json',
|
94 |
+
'Accept': 'application/json',
|
95 |
+
'Authorization': 'Bearer ' + access_token
|
96 |
+
}
|
97 |
|
98 |
+
response = requests.post(url_completion, headers=headers_comp, data=data_copm, verify=False)
|
99 |
+
response_data = response.json()
|
100 |
+
answer_from_llm = response_data['choices'][0]['message']['content']
|
101 |
|
102 |
st.write("Результат резюмирования:")
|
103 |
st.text(answer_from_llm)
|