ciyidogan commited on
Commit
55ba9e7
Β·
verified Β·
1 Parent(s): e47265d

Update chat_handler.py

Browse files
Files changed (1) hide show
  1. chat_handler.py +20 -21
chat_handler.py CHANGED
@@ -14,11 +14,30 @@ import requests
14
  from prompt_builder import build_intent_prompt, build_parameter_prompt
15
  from utils import log
16
  from api_executor import call_api as execute_api
17
- from config_provider import ConfigProvider
18
  from validation_engine import validate
19
  from session import session_store, Session
20
  from llm_interface import LLMInterface, SparkLLM, GPT4oLLM
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  # Global LLM instance
23
  llm_provider: Optional[LLMInterface] = None
24
 
@@ -50,26 +69,6 @@ def _safe_intent_parse(raw: str) -> tuple[str, str]:
50
  tail = raw[m.end():]
51
  log(f"🎯 Parsed intent: {name}")
52
  return name, tail
53
-
54
- # ───────────────────────── CONFIG ───────────────────────── #
55
- SPARK_URL = str(cfg.global_config.spark_endpoint).rstrip("/")
56
- _cfg = None
57
-
58
- def get_config():
59
- """Get or reload config"""
60
- global _cfg
61
- if _cfg is None:
62
- from config_provider import ConfigProvider
63
- _cfg = ConfigProvider.get()
64
- return _cfg
65
-
66
- def reload_config():
67
- """Force reload config"""
68
- global _cfg
69
- from config_provider import ConfigProvider
70
- ConfigProvider._instance = None
71
- _cfg = ConfigProvider.get()
72
- return _cfg
73
 
74
  # ───────────────────────── SPARK ───────────────────────── #
75
  def initialize_llm(force_reload=False):
 
14
  from prompt_builder import build_intent_prompt, build_parameter_prompt
15
  from utils import log
16
  from api_executor import call_api as execute_api
 
17
  from validation_engine import validate
18
  from session import session_store, Session
19
  from llm_interface import LLMInterface, SparkLLM, GPT4oLLM
20
 
21
+ # ───────────────────────── CONFIG ───────────────────────── #
22
+ # Lazy loading for config
23
+ _cfg = None
24
+
25
+ def get_config():
26
+ """Get or reload config"""
27
+ global _cfg
28
+ if _cfg is None:
29
+ from config_provider import ConfigProvider
30
+ _cfg = ConfigProvider.get()
31
+ return _cfg
32
+
33
+ def reload_config():
34
+ """Force reload config"""
35
+ global _cfg
36
+ from config_provider import ConfigProvider
37
+ ConfigProvider._instance = None
38
+ _cfg = ConfigProvider.get()
39
+ return _cfg
40
+
41
  # Global LLM instance
42
  llm_provider: Optional[LLMInterface] = None
43
 
 
69
  tail = raw[m.end():]
70
  log(f"🎯 Parsed intent: {name}")
71
  return name, tail
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  # ───────────────────────── SPARK ───────────────────────── #
74
  def initialize_llm(force_reload=False):