File size: 2,130 Bytes
c102038
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e34a2a6
c102038
 
 
e34a2a6
 
 
 
 
 
c102038
 
 
e34a2a6
 
 
 
 
 
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
import yaml


# Read config file
if os.path.exists('config.yaml'):
    with open('config.yaml', 'r') as file:
        CONFIG = yaml.safe_load(file)
else:
    raise FileNotFoundError('config.yml not found Aborting!')

OPENAI_ORG_KEY = os.getenv("OPENAI_ORG_KEY", "")
OPENAI_KEY = os.getenv("OPENAI_KEY", "")
QDRANT_URL = os.getenv("url", CONFIG["vectorDB"]["kwargs"].get("url", ""))
QDRANT_KEY = os.getenv("qdrant_key", CONFIG["vectorDB"]["kwargs"].get("api_key", ""))

UI_USER = os.getenv("user", "admin")
UI_PWD = os.getenv("pwd", "admin")

CONFIG["embeddings"]["kwargs"]["openai_api_key"] = OPENAI_KEY
CONFIG["embeddings"]["kwargs"]["openai_organization"] = OPENAI_ORG_KEY
CONFIG["llm"]["kwargs"]["openai_api_key"] = OPENAI_KEY
CONFIG["llm"]["kwargs"]["openai_organization"] = OPENAI_ORG_KEY
CONFIG["vectorDB"]["kwargs"]["url"] = QDRANT_URL
CONFIG["vectorDB"]["kwargs"]["api_key"] = QDRANT_KEY


# if the history should be stored on AWS DynamoDB
# otherwise it will be stored on local FS to the output_path defined in the config.yaml file
if CONFIG['chatDB']['class'] == 'DynamoDBChatMessageHistory':
    CHATDB_TABLE_NAME = os.getenv("CHATDB_TABLE_NAME",
                                  CONFIG["chatDB"]["kwargs"].get("table_name", "ChatEurlexHistory"))
    AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID",
                                  CONFIG["chatDB"]["kwargs"].get("aws_access_key_id", ""))
    AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY",
                                      CONFIG["chatDB"]["kwargs"].get("aws_secret_access_key", ""))
    CONFIG["chatDB"]["kwargs"]["table_name"] = CHATDB_TABLE_NAME
    CONFIG["chatDB"]["kwargs"]["aws_access_key_id"] = AWS_ACCESS_KEY_ID
    CONFIG["chatDB"]["kwargs"]["aws_secret_access_key"] = AWS_SECRET_ACCESS_KEY

# if the Cohere reranking is enabled look for the api key and assign it to the CONFIG
if CONFIG['vectorDB'].get('rerank'):
    COHERE_KEY = os.getenv("COHERE_API_KEY",
                           CONFIG["vectorDB"]["rerank"]["kwargs"].get("cohere_api_key", ""))
    CONFIG["vectorDB"]["rerank"]["kwargs"]["cohere_api_key"] = COHERE_KEY