File size: 1,118 Bytes
3a55010
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3594036
1a000de
9ebf961
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
"""
Centralised, cached access to runtime configuration.
"""

from functools import lru_cache
from importlib import resources
import json
import os
from pathlib import Path
import yaml
from dotenv import load_dotenv


@lru_cache(maxsize=None)
def _load_prompt_template() -> str:
    with open("prompts/router_prompt.yml", "r") as fh:
        return yaml.safe_load(fh)["template"]


@lru_cache(maxsize=None)
def _load_mcp_configs() -> dict:
    cfg_path = Path(
        os.getenv(
            "MCP_CONFIG_PATH",
            Path(__file__).resolve().parent / "settings" / "mcp_config.json",
        )
    )
    with cfg_path.open() as fh:
        return json.load(fh)["mcpServers"]


load_dotenv()

PROMPT_TEMPLATE: str = _load_prompt_template()
MCP_CONFIGS: dict = _load_mcp_configs()
MODEL_API_KEY: str = os.getenv("MODEL_API_KEY")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
SMITHERY_API_KEY = os.getenv("SMITHERY_API_KEY")
MCP_CONFIGS["healthcare-mcp-public"]["args"].append(SMITHERY_API_KEY)
MCP_CONFIGS["healthcare-mcp-public"]["url"] = MCP_CONFIGS["healthcare-mcp-public"]["url"].format(api_key=SMITHERY_API_KEY)