@@ -53,7 +53,7 @@ def check_service_status(self) -> BaseResponse:
5353            return  BaseResponse (code = 404 , msg = f"未找到代码库 { self .engine_name }  )
5454        return  BaseResponse (code = 200 , msg = f"找到代码库 { self .engine_name }  )
5555
56-     def  _process (self , query : str , history : List [History ], model , llm_config : LLMConfig , embed_config : EmbedConfig ):
56+     def  _process (self , query : str , history : List [History ], model , llm_config : LLMConfig , embed_config : EmbedConfig ,  local_graph_path = "" ):
5757        '''process''' 
5858
5959        codes_res  =  search_code (query = query , cb_name = self .engine_name , code_limit = self .code_limit ,
@@ -67,7 +67,8 @@ def _process(self, query: str, history: List[History], model, llm_config: LLMCon
6767                                embed_model_path = embed_config .embed_model_path ,
6868                                embed_engine = embed_config .embed_engine ,
6969                                model_device = embed_config .model_device ,
70-                                 embed_config = embed_config 
70+                                 embed_config = embed_config ,
71+                                 local_graph_path = local_graph_path 
7172                                )
7273
7374        context  =  codes_res ['context' ]
@@ -115,6 +116,7 @@ def chat(
115116            model_name : str  =  Body ("" , ),
116117            temperature : float  =  Body (0.5 , ),
117118            model_device : str  =  Body ("" , ),
119+             local_graph_path : str = Body (", " ),
118120            ** kargs 
119121            ):
120122        params  =  locals ()
@@ -127,9 +129,9 @@ def chat(
127129        self .local_doc_url  =  local_doc_url  if  isinstance (local_doc_url , bool ) else  local_doc_url .default 
128130        self .request  =  request 
129131        self .cb_search_type  =  cb_search_type 
130-         return  self ._chat (query , history , llm_config , embed_config , ** kargs )
132+         return  self ._chat (query , history , llm_config , embed_config , local_graph_path ,  ** kargs )
131133
132-     def  _chat (self , query : str , history : List [History ], llm_config : LLMConfig , embed_config : EmbedConfig , ** kargs ):
134+     def  _chat (self , query : str , history : List [History ], llm_config : LLMConfig , embed_config : EmbedConfig , local_graph_path :  str ,  ** kargs ):
133135        history  =  [History (** h ) if  isinstance (h , dict ) else  h  for  h  in  history ]
134136
135137        service_status  =  self .check_service_status ()
@@ -140,7 +142,7 @@ def chat_iterator(query: str, history: List[History]):
140142            # model = getChatModel() 
141143            model  =  getChatModelFromConfig (llm_config )
142144
143-             result , content  =  self .create_task (query , history , model , llm_config , embed_config , ** kargs )
145+             result , content  =  self .create_task (query , history , model , llm_config , embed_config , local_graph_path ,  ** kargs )
144146            # logger.info('result={}'.format(result)) 
145147            # logger.info('content={}'.format(content)) 
146148
@@ -156,9 +158,9 @@ def chat_iterator(query: str, history: List[History]):
156158        return  StreamingResponse (chat_iterator (query , history ),
157159                                 media_type = "text/event-stream" )
158160
159-     def  create_task (self , query : str , history : List [History ], model , llm_config : LLMConfig , embed_config : EmbedConfig ):
161+     def  create_task (self , query : str , history : List [History ], model , llm_config : LLMConfig , embed_config : EmbedConfig ,  local_graph_path :  str ):
160162        '''构建 llm 生成任务''' 
161-         chain , context , result  =  self ._process (query , history , model , llm_config , embed_config )
163+         chain , context , result  =  self ._process (query , history , model , llm_config , embed_config ,  local_graph_path )
162164        logger .info ('chain={}' .format (chain ))
163165        try :
164166            content  =  chain ({"context" : context , "question" : query })
0 commit comments