Sabbah13 commited on
Commit
5e059ba
1 Parent(s): 7dc42bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -41
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
- if st.button('Резюмировать'):
55
- with st.spinner('Резюмируем...'):
56
- username = st.secrets["GIGA_USERNAME"]
57
- password = st.secrets["GIGA_SECRET"]
58
 
59
- # Получаем строку с базовой авторизацией в формате Base64
60
- auth_str = f'{username}:{password}'
61
- auth_bytes = auth_str.encode('utf-8')
62
- auth_base64 = base64.b64encode(auth_bytes).decode('utf-8')
63
- url = os.getenv('GIGA_AUTH_URL')
64
 
65
- headers = {
66
- 'Authorization': f'Basic {auth_base64}', # вставляем базовую авторизацию
67
- 'RqUID': os.getenv('GIGA_rquid'),
68
- 'Content-Type': 'application/x-www-form-urlencoded',
69
- 'Accept': 'application/json'
70
- }
71
-
72
- data = {
73
- 'scope': os.getenv('GIGA_SCOPE')
74
- }
75
 
76
- response = requests.post(url, headers=headers, data=data, verify=False)
77
- access_token = response.json()['access_token']
78
- print('Got access token')
79
 
80
- url_completion = os.getenv('GIGA_COMPLETION_URL')
 
 
81
 
82
- data_copm = json.dumps({
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
- headers_comp = {
95
- 'Content-Type': 'application/json',
96
- 'Accept': 'application/json',
97
- 'Authorization': 'Bearer ' + access_token
 
 
98
  }
 
 
 
 
 
 
 
 
 
 
99
 
100
- response = requests.post(url_completion, headers=headers_comp, data=data_copm, verify=False)
101
- response_data = response.json()
102
- answer_from_llm = response_data['choices'][0]['message']['content']
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)