Update utils.py
Browse files
utils.py
CHANGED
@@ -17,33 +17,6 @@ def check_password():
|
|
17 |
else:
|
18 |
return True
|
19 |
|
20 |
-
def get_completion_from_gigachat(prompt, max_tokens, access_token):
|
21 |
-
url_completion = os.getenv('GIGA_COMPLETION_URL')
|
22 |
-
|
23 |
-
data_copm = json.dumps({
|
24 |
-
"model": os.getenv('GIGA_MODEL'),
|
25 |
-
"messages": [
|
26 |
-
{
|
27 |
-
"role": "user",
|
28 |
-
"content": prompt
|
29 |
-
}
|
30 |
-
],
|
31 |
-
"stream": False,
|
32 |
-
"max_tokens": max_tokens,
|
33 |
-
})
|
34 |
-
|
35 |
-
headers_comp = {
|
36 |
-
'Content-Type': 'application/json',
|
37 |
-
'Accept': 'application/json',
|
38 |
-
'Authorization': 'Bearer ' + access_token
|
39 |
-
}
|
40 |
-
|
41 |
-
response = requests.post(url_completion, headers=headers_comp, data=data_copm, verify=False)
|
42 |
-
response_data = response.json()
|
43 |
-
answer_from_llm = response_data['choices'][0]['message']['content']
|
44 |
-
|
45 |
-
return answer_from_llm
|
46 |
-
|
47 |
def convert_segments_object_to_text(data):
|
48 |
result = []
|
49 |
|
|
|
17 |
else:
|
18 |
return True
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def convert_segments_object_to_text(data):
|
21 |
result = []
|
22 |
|