1212from config import settings
1313from kubechat .chat .history .redis import RedisChatMessageHistory
1414from kubechat .llm .base import Predictor , PredictorType
15- from kubechat .db .models import ssl_file_path , ssl_temp_file_path
15+ from kubechat .db .models import ssl_file_path , ssl_temp_file_path , BotType
1616from kubechat .db .ops import query_chat_feedbacks , logger , PagedResult
1717from kubechat .source .base import get_source , CustomSourceInitializationError
1818from kubechat .utils .utils import AVAILABLE_SOURCE
@@ -82,7 +82,7 @@ def validate_source_connect_config(config: Dict) -> (bool, str):
8282 return True , ""
8383
8484
85- def validate_bot_config (model , config : Dict ) -> (bool , str ):
85+ def validate_bot_config (model , config : Dict , bot ) -> (bool , str ):
8686 try :
8787 Predictor .from_model (model , PredictorType .CUSTOM_LLM , ** config )
8888 except Exception as e :
@@ -91,14 +91,20 @@ def validate_bot_config(model, config: Dict) -> (bool, str):
9191 try :
9292 # validate the prompt
9393 prompt_template = config .get ("prompt_template" , None )
94- PromptTemplate (template = prompt_template , input_variables = ["query" , "context" ])
94+ if bot .type == BotType .KNOWLEDGE :
95+ PromptTemplate (template = prompt_template , input_variables = ["query" , "context" ])
96+ elif bot .type == BotType .COMMON :
97+ # PromptTemplate(template=prompt_template, input_variables=["query"])
98+ pass
99+ else :
100+ return False , "Unsupported bot type"
95101 except ValidationError :
96102 return False , "Invalid prompt template"
97103
98104 try :
99105 # validate the memory prompt
100106 prompt_template = config .get ("memory_prompt_template" , None )
101- if prompt_template :
107+ if prompt_template and bot . type == BotType . KNOWLEDGE :
102108 PromptTemplate (template = prompt_template , input_variables = ["query" , "context" ])
103109 except ValidationError :
104110 return False , "Invalid memory prompt template"
0 commit comments