-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
46 lines (38 loc) · 1.26 KB
/
Copy pathutils.py
File metadata and controls
46 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
from dotenv import load_dotenv, find_dotenv
# getting api keys
def load_env():
_ = load_dotenv(find_dotenv())
def get_openai_api_key():
load_env()
openai_api_key = os.getenv('OPENAI_API_KEY')
return openai_api_key
def get_groq_api_key():
load_env()
groq_api_key = os.getenv('GROQ_API_KEY')
return groq_api_key
def get_serper_api_key():
load_env()
serper_api_key = os.getenv('SERPER_API_KEY')
return serper_api_key
# function to break lines if longer then 80 charactors
# dont break if in the middle of the word
def pretty_print_result (result):
parsed_result:str =[]
for line in result.splitlines():
if len(line) > 80:
words = line.split(' ')
new_line=''
for word in words:
if len(new_line) +len(word) + 1 >80:
parsed_result.append(new_line)
new_line = word
else:
if new_line == '':
new_line = word
else:
new_line = new_line + ' ' + word
parsed_result.append(new_line)
else:
parsed_result.append(line)
return '\n'.join(parsed_result)