-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_paths.py
190 lines (153 loc) · 7.5 KB
/
file_paths.py
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
47
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/usr/bin/env python
################################################################################
# commbase-genai-slm-ollama-phi3-mini-memory-remote-rag-pinecone #
# #
# A sophisticated AI assistant's Small Language Model (Phi3), enhanced by #
# Retrieval-Augmented Generation (RAG) for improved response accuracy, and #
# supported by a Pinecone semantic vector database. #
# #
# Change History #
# 06/25/2024 Esteban Herrera Original code. #
# Add new history entries as needed. #
# #
# #
################################################################################
################################################################################
################################################################################
# #
# Copyright (c) 2022-present Esteban Herrera C. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# file_paths.py
# This file stores functions related to loading and managing file paths
# Requires os.path already imported
# Requirements
from config import CONFIG_FILE_DIR, CONFIG_FILE_PATH
def get_assistant_discourse_from_language_model_file():
"""
Retrieves the value of the ASSISTANT_DISCOURSE_FROM_LANGUAGE_MODEL_FILE
variable from the configuration file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
model_discourse_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "ASSISTANT_DISCOURSE_FROM_LANGUAGE_MODEL_FILE":
# Remove the quotes from the value of the variable
model_discourse_file = CONFIG_FILE_DIR + "/" + value.strip()[1:-1]
# Check if the variable was found
if model_discourse_file is not None:
return model_discourse_file
# If the variable was not found, return None
return None
def get_chat_log_file():
"""
Retrieves the value of the CHAT_LOG_FILE variable from the configuration
file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
chat_log_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "CHAT_LOG_FILE":
# Remove the quotes from the value of the variable
chat_log_file = CONFIG_FILE_DIR + "/" + value.strip()[1:-1]
# Check if the variable was found
if chat_log_file is not None:
return chat_log_file
# If the variable was not found, return None
return None
def get_chat_memory_file():
"""
Retrieves the value of the CHAT_MEMORY_FILE variable from the configuration
file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
chat_memory_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "CHAT_MEMORY_FILE":
# Remove the quotes from the value of the variable
chat_memory_file = CONFIG_FILE_DIR + "/" + value.strip()[1:-1]
# Check if the variable was found
if chat_memory_file is not None:
return chat_memory_file
# If the variable was not found, return None
return None
def get_run_voice_recorder_in_pane_path():
"""
Retrieves the value of the RUN_VOICE_RECORDER_IN_PANE_PATH variable from
the configuration file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
run_recorder_path = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "RUN_VOICE_RECORDER_IN_PANE_PATH":
# Remove the quotes from the value of the variable
run_recorder_path = CONFIG_FILE_DIR + "/" + value.strip()[1:-1]
# Check if the variable was found
if run_recorder_path is not None:
return run_recorder_path
# If the variable was not found, return None
return None
def get_stt_engine_path():
"""
Retrieves the value of the STT_ENGINE_PATH variable from the configuration
file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
stt_engine_path = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "STT_ENGINE_PATH":
# Remove the quotes from the value of the variable
stt_engine_path = value.strip()[1:-1]
# Check if the variable was found
if stt_engine_path is not None:
return stt_engine_path
# If the variable was not found, return None
return None