Skip to content

Commit 004e840

Browse files
committed
use bot_in.type instead of bot.type
1 parent f7aba9a commit 004e840

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

kubechat/views/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ async def create_bot(request, bot_in: BotIn):
640640
memory = config.get("memory", False)
641641
model = config.get("model")
642642
llm_config = config.get("llm")
643-
valid, msg = validate_bot_config(model, llm_config, bot, memory)
643+
valid, msg = validate_bot_config(model, llm_config, bot_in.type, memory)
644644
if not valid:
645645
return fail(HTTPStatus.BAD_REQUEST, msg)
646646
await bot.asave()
@@ -715,7 +715,7 @@ async def update_bot(request, bot_id, bot_in: BotIn):
715715
model = new_config.get("model")
716716
memory = new_config.get("memory", False)
717717
llm_config = new_config.get("llm")
718-
valid, msg = validate_bot_config(model, llm_config, bot, memory)
718+
valid, msg = validate_bot_config(model, llm_config, bot_in.type, memory)
719719
if not valid:
720720
return fail(HTTPStatus.BAD_REQUEST, msg)
721721
old_config = json.loads(bot.config)

kubechat/views/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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, bot, memory) -> (bool, str):
85+
def validate_bot_config(model, config: Dict, type, memory) -> (bool, str):
8686
try:
8787
Predictor.from_model(model, PredictorType.CUSTOM_LLM, **config)
8888
except Exception as e:
@@ -91,9 +91,9 @@ def validate_bot_config(model, config: Dict, bot, memory) -> (bool, str):
9191
try:
9292
# validate the prompt
9393
prompt_template = config.get("prompt_template", None)
94-
if prompt_template and bot.type == BotType.KNOWLEDGE:
94+
if prompt_template and type == BotType.KNOWLEDGE:
9595
PromptTemplate(template=prompt_template, input_variables=["query", "context"])
96-
elif prompt_template and bot.type == BotType.COMMON:
96+
elif prompt_template and type == BotType.COMMON:
9797
PromptTemplate(template=prompt_template, input_variables=["query"])
9898
# pass
9999
except ValidationError:
@@ -103,9 +103,9 @@ def validate_bot_config(model, config: Dict, bot, memory) -> (bool, str):
103103
try:
104104
# validate the memory prompt
105105
prompt_template = config.get("memory_prompt_template", None)
106-
if prompt_template and bot.type == BotType.KNOWLEDGE:
106+
if prompt_template and type == BotType.KNOWLEDGE:
107107
PromptTemplate(template=prompt_template, input_variables=["query", "context"])
108-
elif prompt_template and bot.type == BotType.COMMON:
108+
elif prompt_template and type == BotType.COMMON:
109109
PromptTemplate(template=prompt_template, input_variables=["query"])
110110
# pass
111111
except ValidationError:

0 commit comments

Comments
 (0)