Unverified Commit 469a66b5 authored by Yeuoly's avatar Yeuoly

feat: upload image

parent 7582871e
...@@ -54,7 +54,10 @@ class MessageFileParser: ...@@ -54,7 +54,10 @@ class MessageFileParser:
image_config = file_upload_config.get('image') image_config = file_upload_config.get('image')
# check if image file feature is enabled or it's agent # check if image file feature is enabled or it's agent
if not image_config['enabled'] and not (app_model_config.agent_mode_dict.get('enabled', '') in ['react', 'function_call', 'cot']): if not image_config['enabled'] and not (
app_model_config.agent_mode_dict.get('enabled', False) and
app_model_config.agent_mode_dict.get('strategy', '') in ['react', 'function_call', 'cot']
):
continue continue
# Validate number of files # Validate number of files
......
from typing import Any, Dict, List, cast from typing import Any, Dict, List, cast
from enum import Enum from enum import Enum
from pydantic import validator
from base64 import b64encode from base64 import b64encode
from core.tools.entities.tool_entities import ToolInvokeMessage from core.tools.entities.tool_entities import ToolInvokeMessage
...@@ -60,7 +59,8 @@ class ModelTool(Tool): ...@@ -60,7 +59,8 @@ class ModelTool(Tool):
identity=self.identity.copy() if self.identity else None, identity=self.identity.copy() if self.identity else None,
parameters=self.parameters.copy() if self.parameters else None, parameters=self.parameters.copy() if self.parameters else None,
description=self.description.copy() if self.description else None, description=self.description.copy() if self.description else None,
model_configuration=self.model_configuration.copy() if self.model_configuration else None, model_instance=self.model_configuration['model_instance'],
model=self.model_configuration['model'],
tool_type=self.tool_type, tool_type=self.tool_type,
runtime=Tool.Runtime(**meta) runtime=Tool.Runtime(**meta)
) )
...@@ -80,6 +80,8 @@ class ModelTool(Tool): ...@@ -80,6 +80,8 @@ class ModelTool(Tool):
if self.tool_type == ModelTool.ModelToolType.VISION: if self.tool_type == ModelTool.ModelToolType.VISION:
return self._invoke_llm(user_id, tool_parameters) return self._invoke_llm(user_id, tool_parameters)
else:
return self.create_text_message('the tool is not configured correctly')
def _invoke_llm(self, user_id: str, tool_parameters: Dict[str, Any]) -> ToolInvokeMessage | List[ToolInvokeMessage]: def _invoke_llm(self, user_id: str, tool_parameters: Dict[str, Any]) -> ToolInvokeMessage | List[ToolInvokeMessage]:
# get image # get image
......
...@@ -82,7 +82,7 @@ const ChatItem: FC<ChatItemProps> = ({ ...@@ -82,7 +82,7 @@ const ChatItem: FC<ChatItemProps> = ({
model_config: configData, model_config: configData,
} }
if (visionConfig.enabled && files?.length && supportVision) if (((visionConfig.enabled && supportVision) || config.agent_mode.enabled) && files?.length)
data.files = files data.files = files
handleSend( handleSend(
......
...@@ -91,7 +91,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi ...@@ -91,7 +91,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
model_config: configData, model_config: configData,
} }
if (visionConfig.enabled && files?.length && supportVision) if (((visionConfig.enabled && supportVision) || config.agent_mode.enabled) && files?.length)
data.files = files data.files = files
handleSend( handleSend(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment