Fix default chat configs to use user model if no server chat model set

Post merge cleanup in advanced reasoning to fallback to user chat
model if no server chat model defined for advanced and default
This commit is contained in:
Debanjum Singh Solanky
2024-10-13 02:59:10 -07:00
parent a2200466b7
commit 9314f0a398
3 changed files with 8 additions and 7 deletions

View File

@@ -18,11 +18,11 @@ async def send_message_to_model_wrapper(
system_message: str = "",
response_type: str = "text",
chat_model_option: ChatModelOptions = None,
subscribed: bool = False,
user: KhojUser = None,
uploaded_image_url: str = None,
):
conversation_config: ChatModelOptions = (
chat_model_option or await ConversationAdapters.aget_default_conversation_config()
chat_model_option or await ConversationAdapters.aget_default_conversation_config(user)
)
vision_available = conversation_config.vision_enabled
@@ -32,6 +32,7 @@ async def send_message_to_model_wrapper(
conversation_config = vision_enabled_config
vision_available = True
subscribed = await ais_user_subscribed(user)
chat_model = conversation_config.chat_model
max_tokens = (
conversation_config.subscribed_max_prompt_size

View File

@@ -97,7 +97,7 @@ async def generate_python_code(
code_generation_prompt,
uploaded_image_url=uploaded_image_url,
response_type="json_object",
subscribed=subscribed,
user=user,
)
# Validate that the response is a non-empty, JSON-serializable list

View File

@@ -37,7 +37,7 @@ logger = logging.getLogger(__name__)
async def apick_next_tool(
query: str,
conversation_history: dict,
subscribed: bool,
user: KhojUser = None,
uploaded_image_url: str = None,
location: LocationData = None,
user_name: str = None,
@@ -86,13 +86,13 @@ async def apick_next_tool(
max_iterations=max_iterations,
)
chat_model_option = await ConversationAdapters.aget_advanced_conversation_config()
chat_model_option = await ConversationAdapters.aget_advanced_conversation_config(user)
with timer("Chat actor: Infer information sources to refer", logger):
response = await send_message_to_model_wrapper(
function_planning_prompt,
response_type="json_object",
subscribed=subscribed,
user=user,
chat_model_option=chat_model_option,
)
@@ -148,7 +148,7 @@ async def execute_information_collection(
this_iteration = await apick_next_tool(
query,
conversation_history,
subscribed,
user,
uploaded_image_url,
location,
user_name,