split into config / secrets

This commit is contained in:
Gokul Mohanarangan
2023-07-27 13:29:35 +05:30
parent d985153845
commit 2184bc3252
6 changed files with 60 additions and 8 deletions

2
server/.gitignore vendored
View File

@@ -165,7 +165,7 @@ cython_debug/
transcript_*.txt transcript_*.txt
test_*.txt test_*.txt
wordcloud*.png wordcloud*.png
utils/config.ini utils/secrets.ini
test_samples/ test_samples/
*.wav *.wav
*.mp3 *.mp3

View File

@@ -20,7 +20,7 @@ from sortedcontainers import SortedDict
from reflector_dataclasses import BlackListedMessages, FinalSummaryResult, ParseLLMResult, TitleSummaryInput, \ from reflector_dataclasses import BlackListedMessages, FinalSummaryResult, ParseLLMResult, TitleSummaryInput, \
TitleSummaryOutput, TranscriptionInput, TranscriptionOutput TitleSummaryOutput, TranscriptionInput, TranscriptionOutput
from utils.log_utils import LOGGER from utils.log_utils import LOGGER
from utils.run_utils import CONFIG, run_in_executor from utils.run_utils import CONFIG, run_in_executor, SECRETS
# WebRTC components # WebRTC components
pcs = set() pcs = set()
@@ -43,8 +43,8 @@ transcription_text = ""
last_transcribed_time = 0.0 last_transcribed_time = 0.0
# LLM # LLM
LLM_MACHINE_IP = CONFIG["LLM"]["LLM_MACHINE_IP"] LLM_MACHINE_IP = SECRETS["LLM"]["LLM_MACHINE_IP"]
LLM_MACHINE_PORT = CONFIG["LLM"]["LLM_MACHINE_PORT"] LLM_MACHINE_PORT = SECRETS["LLM"]["LLM_MACHINE_PORT"]
LLM_URL = f"http://{LLM_MACHINE_IP}:{LLM_MACHINE_PORT}/api/v1/generate" LLM_URL = f"http://{LLM_MACHINE_IP}:{LLM_MACHINE_PORT}/api/v1/generate"
# Topic and summary responses # Topic and summary responses

25
server/utils/config.ini Normal file
View File

@@ -0,0 +1,25 @@
[DEFAULT]
#Set exception rule for OpenMP error
#to allow duplicate lib initialization
KMP_DUPLICATE_LIB_OK = TRUE
[WHISPER]
#ExportWhisperModelSize
WHISPER_MODEL_SIZE = tiny
WHISPER_REAL_TIME_MODEL_SIZE = tiny
[SUMMARIZER]
#Summarizerconfig
SUMMARY_MODEL = facebook/bart-large-cnn
INPUT_ENCODING_MAX_LENGTH = 1024
MAX_LENGTH = 2048
BEAM_SIZE = 6
MAX_CHUNK_LENGTH = 1024
SUMMARIZE_USING_CHUNKS = YES
[AUDIO]
# Audiodevice
BLACKHOLE_INPUT_AGGREGATOR_DEVICE_NAME = aggregator
AV_FOUNDATION_DEVICE_ID = 1
CHANNELS = 2
SAMPLING_RATE = 48000

View File

@@ -10,13 +10,13 @@ import boto3
import botocore import botocore
from .log_utils import LOGGER from .log_utils import LOGGER
from .run_utils import CONFIG from .run_utils import SECRETS
BUCKET_NAME = CONFIG["AWS"]["BUCKET_NAME"] BUCKET_NAME = SECRETS["AWS-S3"]["BUCKET_NAME"]
s3 = boto3.client('s3', s3 = boto3.client('s3',
aws_access_key_id=CONFIG["AWS"]["AWS_ACCESS_KEY"], aws_access_key_id=SECRETS["AWS-S3"]["AWS_ACCESS_KEY"],
aws_secret_access_key=CONFIG["AWS"]["AWS_SECRET_KEY"]) aws_secret_access_key=SECRETS["AWS-S3"]["AWS_SECRET_KEY"])
def upload_files(files_to_upload: List[str]) -> NoReturn: def upload_files(files_to_upload: List[str]) -> NoReturn:

View File

@@ -15,6 +15,7 @@ class ReflectorConfig:
Create a single config object to share across the project Create a single config object to share across the project
""" """
__config = None __config = None
__secrets = None
@staticmethod @staticmethod
def get_config(): def get_config():
@@ -27,8 +28,20 @@ class ReflectorConfig:
ReflectorConfig.__config.read('utils/config.ini') ReflectorConfig.__config.read('utils/config.ini')
return ReflectorConfig.__config return ReflectorConfig.__config
@staticmethod
def get_secrets():
"""
Load the configurations from the local config.ini file
:return:
"""
if ReflectorConfig.__secrets is None:
ReflectorConfig.__secrets = configparser.ConfigParser()
ReflectorConfig.__secrets.read('utils/secrets.ini')
return ReflectorConfig.__secrets
CONFIG = ReflectorConfig.get_config() CONFIG = ReflectorConfig.get_config()
SECRETS = ReflectorConfig.get_secrets()
def run_in_executor(func, *args, executor=None, **kwargs): def run_in_executor(func, *args, executor=None, **kwargs):

View File

@@ -0,0 +1,14 @@
[LLM]
# LLM configs
LLM_MACHINE_IP=
LLM_MACHINE_PORT=
[AWS-S3]
#AWSconfig
AWS_ACCESS_KEY=
AWS_SECRET_KEY=
BUCKET_NAME=reflector-bucket
[OPENAI]
#ExportOpenAIAPIKey
OPENAI_APIKEY=