Skip to content

Commit 6af00b2

Browse files
authored
Fix image file name not in AI issue (#282)
* fix for image file name not in output * fix for server port * fix for events and image file name issue
1 parent d1e6cf2 commit 6af00b2

12 files changed

Lines changed: 32 additions & 13 deletions

File tree

flo_ai/flo_ai/arium/arium.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,11 @@ def _serialize_node_output(self, result: Any) -> Optional[str]:
647647
if isinstance(result, str):
648648
return result
649649
if isinstance(result, list):
650-
parts = [self._serialize_node_output(item) for item in result]
651-
return '\n'.join(p for p in parts if p) or None
650+
# agent.run() returns conversation_history (all messages); take only
651+
# the last item, which is the agent's own reply for this node.
652+
if not result:
653+
return None
654+
return self._serialize_node_output(result[-1])
652655
if hasattr(result, 'content'):
653656
return self._serialize_node_output(result.content)
654657
if hasattr(result, 'text'):

flo_ai/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "flo_ai"
3-
version = "1.1.5"
3+
version = "1.1.6"
44
description = "A easy way to create structured AI agents"
55
authors = [{ name = "rootflo", email = "engineering.tools@rootflo.ai" }]
66
requires-python = ">=3.10,<4.0"

flo_ai/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='flo-ai',
8-
version='1.1.3',
8+
version='1.1.6',
99
author='Rootflo',
1010
description='Create composable AI agents',
1111
long_description=long_description,

wavefront/client/src/components/InferencePopup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ const InferencePopup: React.FC<InferencePopupProps> = ({ onClose, renderModal =
243243
const imageMessage = {
244244
image_base64: imageBase64Content,
245245
mime_type: uploadedImage.mimeType,
246+
file_name: uploadedImage.file.name,
246247
};
247248
messageInputs.push(imageMessage);
248249
}

wavefront/client/src/pages/apps/[appId]/agents/[id].tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ const AgentDetail: React.FC = () => {
416416
const imageMessage = {
417417
image_base64: image.base64Content,
418418
mime_type: image.mimeType,
419+
file_name: image.file.name,
419420
};
420421
setChatHistory((prev) => [...prev, { role: 'user', content: imageMessage }]);
421422
conversationInputs.push({

wavefront/client/src/pages/apps/[appId]/workflows/[id].tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ const WorkflowDetail: React.FC = () => {
369369
const imageMessage = {
370370
image_base64: image.base64Content,
371371
mime_type: image.mimeType,
372+
file_name: image.file.name,
372373
};
373374
messageInputs.push({ role: 'user', content: imageMessage });
374375
setChatHistory((prev) => [...prev, { role: 'user', content: imageMessage }]);
@@ -379,6 +380,7 @@ const WorkflowDetail: React.FC = () => {
379380
const imageMessage = {
380381
image_base64: imageBase64Content,
381382
mime_type: uploadedImage.mimeType,
383+
file_name: uploadedImage.file?.name,
382384
};
383385
messageInputs.push({ role: 'user', content: imageMessage });
384386
setChatHistory((prev) => [...prev, { role: 'user', content: imageMessage }]);

wavefront/client/src/types/chat-message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
export interface ImageContent {
33
image_base64: string;
44
mime_type?: string;
5+
file_name?: string;
56
}
67

78
export interface DocumentContent {

wavefront/server/modules/agents_module/agents_module/utils/input_processing_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ def process_inference_inputs(
4343
elif input_item.get('role') == 'user':
4444
input_content = input_item.get('content', {})
4545
if is_image_message(input_content):
46+
# Inject filename as a text message before the image so
47+
# agents can reference the original file name in their output.
48+
file_name = input_content.get('file_name')
49+
if file_name:
50+
resolved_inputs.append(
51+
UserMessage(
52+
content=TextMessageContent(
53+
text=f'The original filename of this image is: {file_name}'
54+
)
55+
)
56+
)
4657
# Extract image_bytes and mime_type from image_base64
4758
try:
4859
data_url_pattern = r'^data:(image/[a-zA-Z0-9.+-]+);base64,(.+)$'

wavefront/server/modules/agents_module/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"flo-utils",
1414
"tools-module",
1515
"api-services-module",
16-
"flo-ai==1.1.5",
16+
"flo-ai==1.1.6",
1717
]
1818

1919
[tool.uv.sources]

wavefront/server/modules/knowledge_base_module/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"pandas~=2.2.3",
1818
"ollama~=0.4.8",
1919
"textract~=1.6.5",
20-
"flo-ai==1.1.5",
20+
"flo-ai==1.1.6",
2121
"google-cloud-pubsub~=2.30.0",
2222
"boto3<=1.38.40",
2323
"pyyaml>=6.0.3,<7",

0 commit comments

Comments
 (0)