From 9ea9d52d6b8f4a4fb2f983b9d7fdcf661be8cc3e Mon Sep 17 00:00:00 2001 From: ggatatata Date: Tue, 26 Nov 2024 22:23:09 +0700 Subject: [PATCH] Fix - division by zero change amount_per_topic position so that when no topic as input it won't divide by zero. which make an error. --- internal/roadmap_agent.py | 2 +- routers/pre_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/roadmap_agent.py b/internal/roadmap_agent.py index 73dd3cc..a89b212 100644 --- a/internal/roadmap_agent.py +++ b/internal/roadmap_agent.py @@ -18,7 +18,7 @@ class AgentState(TypedDict): # Initialize LLM llm = ChatOpenAI( - model=os.getenv('MODEL'), + model=os.getenv('SAIG_LLM_MODEL'), base_url=os.getenv('LLM_SAIG_API'), api_key="NA", temperature=0.6, diff --git a/routers/pre_test.py b/routers/pre_test.py index e7230f2..f086ff7 100644 --- a/routers/pre_test.py +++ b/routers/pre_test.py @@ -22,7 +22,6 @@ async def qa(body: PreTestRequest): response_topic = body.topics topic_titles = [topic.title for topic in response_topic] topic_amount = len(topic_titles) - amount_per_topic = round(max_question / topic_amount) diff_titles = [diff.level for diff in response_topic] current_amount = 0 n = 0 @@ -30,6 +29,7 @@ async def qa(body: PreTestRequest): final_questions = [] final_json = [] if topic_titles: + amount_per_topic = round(max_question / topic_amount) for t in topic_titles: if topic_amount - n != 1: if amount_per_topic == 1: