@@ -70,7 +70,7 @@ class LLMService:
7070 future : Future
7171
7272 def __init__ (self , current_user : CurrentUser , chat_question : ChatQuestion ,
73- current_assistant : Optional [CurrentAssistant ] = None , no_reasoning : bool = False ):
73+ current_assistant : Optional [CurrentAssistant ] = None , no_reasoning : bool = False , config : LLMConfig = None ):
7474 self .chunk_list = []
7575 engine = create_engine (str (settings .SQLALCHEMY_DATABASE_URI ))
7676 session_maker = sessionmaker (bind = engine )
@@ -110,7 +110,7 @@ def __init__(self, current_user: CurrentUser, chat_question: ChatQuestion,
110110
111111 self .ds = (ds if isinstance (ds , AssistantOutDsSchema ) else CoreDatasource (** ds .model_dump ())) if ds else None
112112 self .chat_question = chat_question
113- self .config = get_default_config ()
113+ self .config = config
114114 if no_reasoning :
115115 # only work while using qwen
116116 if self .config .additional_params :
@@ -125,6 +125,14 @@ def __init__(self, current_user: CurrentUser, chat_question: ChatQuestion,
125125 llm_instance = LLMFactory .create_llm (self .config )
126126 self .llm = llm_instance .llm
127127
128+ self .init_messages ()
129+
130+ @classmethod
131+ async def create (cls , * args , ** kwargs ):
132+ config : LLMConfig = await get_default_config ()
133+ instance = cls (* args , ** kwargs , config = config )
134+ return instance
135+
128136 def is_running (self , timeout = 0.5 ):
129137 try :
130138 r = concurrent .futures .wait ([self .future ], timeout )
0 commit comments