mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Fix sync to async issue when getting all valid vision configs
This commit is contained in:
parent
9b12290c17
commit
cd5db277f3
2 changed files with 13 additions and 1 deletions
|
@ -761,6 +761,10 @@ class ConversationAdapters:
|
|||
def get_all_conversation_configs():
|
||||
return ChatModelOptions.objects.all()
|
||||
|
||||
@staticmethod
|
||||
async def aget_all_conversation_configs():
|
||||
return await sync_to_async(list)(ChatModelOptions.objects.all())
|
||||
|
||||
@staticmethod
|
||||
def get_vision_enabled_config():
|
||||
conversation_configurations = ConversationAdapters.get_all_conversation_configs()
|
||||
|
@ -769,6 +773,14 @@ class ConversationAdapters:
|
|||
return config
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
async def aget_vision_enabled_config():
|
||||
conversation_configurations = await ConversationAdapters.aget_all_conversation_configs()
|
||||
for config in conversation_configurations:
|
||||
if config.vision_enabled:
|
||||
return config
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_openai_conversation_config():
|
||||
return OpenAIProcessorConversationConfig.objects.filter().first()
|
||||
|
|
|
@ -595,7 +595,7 @@ async def send_message_to_model_wrapper(
|
|||
|
||||
vision_available = conversation_config.vision_enabled
|
||||
if not vision_available and uploaded_image_url:
|
||||
vision_enabled_config = ConversationAdapters.get_vision_enabled_config()
|
||||
vision_enabled_config = await ConversationAdapters.aget_vision_enabled_config()
|
||||
if vision_enabled_config:
|
||||
conversation_config = vision_enabled_config
|
||||
vision_available = True
|
||||
|
|
Loading…
Add table
Reference in a new issue