Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of the sys.files variable on other nodes #10235

Open
4 of 5 tasks
G81192 opened this issue Nov 4, 2024 · 6 comments
Open
4 of 5 tasks

use of the sys.files variable on other nodes #10235

G81192 opened this issue Nov 4, 2024 · 6 comments

Comments

@G81192
Copy link
Contributor

G81192 commented Nov 4, 2024

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

My issue is similar to #7260. I see that issue #7260 has been closed, but I find that the problem still exists. I am unable to use the sys.files variable on other nodes, and I'm not sure if this is due to my configuration or if this feature is still unsupported.
image

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
@G81192
Copy link
Contributor Author

G81192 commented Nov 4, 2024

and I’m currently using the latest version (0.10.2)

Copy link

dosubot bot commented Nov 4, 2024

I found a similar discussion and issue related to using the sys.files variable in workflow nodes. The issue was addressed by ensuring that the isShowVisionConfig condition is true, which allows the vision configuration, including sys.files, to be available. This is controlled by the following code:

const isShowVisionConfig = !!currModel?.features?.includes(ModelFeatureEnum.vision);

Make sure isShowVisionConfig is set to true in your configuration. Additionally, ensure that the image upload function is enabled in the 'Features' section of the application orchestration page. The workflow should be configured to handle file variables properly by fetching files from the variable pool using the _fetch_files method and converting tool messages to include files using the _convert_tool_messages method [1][2].

If you are still experiencing issues, it might be worth checking if your configuration aligns with these requirements.

To continue talking to Dosu, mention @dosu.

@G81192
Copy link
Contributor Author

G81192 commented Nov 4, 2024

I have a scenario where I need to create a custom tool to recognize QR code information from uploaded images. How can I access the uploaded image file in the tool?

Copy link

dosubot bot commented Nov 4, 2024

To access the uploaded image file in a custom tool for recognizing QR code information, you can use the ToolFileMessageTransformer class to transform the tool invoke messages. When the message type is ToolInvokeMessage.MessageType.IMAGE, the image is downloaded, and a URL is generated for it. You can then use this URL to access the image file.

Here's a relevant code snippet:

if message.type == ToolInvokeMessage.MessageType.IMAGE and isinstance(message.message, str):
    try:
        file = ToolFileManager.create_file_by_url(
            user_id=user_id, tenant_id=tenant_id, conversation_id=conversation_id, file_url=message.message
        )

        url = f'/files/tools/{file.id}{guess_extension(file.mimetype) or ".png"}'
        result.append(
            ToolInvokeMessage(
                type=ToolInvokeMessage.MessageType.IMAGE_LINK,
                message=url,
                save_as=message.save_as,
                meta=message.meta.copy() if message.meta is not None else {},
            )
        )
    except Exception as e:
        logger.exception(e)
        result.append(
            ToolInvokeMessage(
                type=ToolInvokeMessage.MessageType.TEXT,
                message=f"Failed to download image: {message.message}, please try to download it manually.",
                meta=message.meta.copy() if message.meta is not None else {},
                save_as=message.save_as,
            )
        )

This code attempts to download the image using the URL provided in the message and then constructs a new URL to access the image file. You can use this URL to access the image for QR code recognition [1].

To continue talking to Dosu, mention @dosu.

@crazywoola
Copy link
Member

Currently, I don't think we can do this, all images's preview are presigned and they will be outdated in a very short time. I have already talk to our dev team regarding this issue. I suggest you can use HTTP to upload to other OSS storage and return a url instead.

@G81192
Copy link
Contributor Author

G81192 commented Nov 4, 2024

Currently, I don't think we can do this, all images's preview are presigned and they will be outdated in a very short time. I have already talk to our dev team regarding this issue. I suggest you can use HTTP to upload to other OSS storage and return a url instead.

@crazywoola Okay, I see that the HTTP request node can use the sys.files variable and upload files, which should solve my problem. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants