-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (35 loc) · 1.49 KB
/
Copy pathmain.py
File metadata and controls
47 lines (35 loc) · 1.49 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
47
from src.ui.interface import GradioApp
from src.core.connector import Connector
from src.state.state_manager import StateManager
from dotenv import load_dotenv
import ast
import os
import yaml
load_dotenv(override=True)
def main():
# 1. Load environment variables
variables = {
'EMBEDDING_MODEL': os.getenv('EMBEDDING_MODEL'),
'OPENAI_API_KEY': os.getenv('OPENAI_API_KEY'),
'CONFIG_PATH': os.getenv('CONFIG_PATH'),
'MODEL_TYPE': os.getenv('MODEL_TYPE'),
'SERVER_NAME': os.getenv('SERVER_NAME'),
'SERVER_PORT': int(os.getenv('SERVER_PORT')),
'AGENT_MODEL_LOADER': bool(os.getenv('AGENT_MODEL_LOADER').lower() == 'true'),
'CHROMA_DATABASE_PATH': os.getenv('CHROMA_PATH'),
'AGENT_MAX_STEP': int(os.getenv('AGENT_MAX_STEP'))
}
# 2. Load the Configuration files
with open(variables['CONFIG_PATH'], 'r') as file:
config = yaml.safe_load(file)
# 3. Updating the environment variables with the configuration file
variables['CONFIG'] = config
# 4. Create the State Manager instance
state_manager = StateManager()
# 5. Initialize the Connector instance with environment variables and state manager
backend = Connector(variables, state_manager)
# 6. Create and launch the Gradio interface with the same state manager
app = GradioApp(state_manager)
app.launch(server_name=variables['SERVER_NAME'], server_port=variables['SERVER_PORT'])
if __name__ == "__main__":
main()