Error when using numbers in startnode with OpenAI moderation #3569

Closed
opened 2026-02-21 17:59:23 -05:00 by yindo · 0 comments
Owner

Originally created by @AndyMik90 on GitHub (May 22, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.8

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

If you use the "number" input field for a start node and have the open moderation functionality enabled. you get error "TypeError: sequence item 3: expected str instance, int found"

✔️ Expected Behavior

Run the workflow

Actual Behavior

Seems that the function:

def _is_violated(self, inputs: dict):
        text = '\n'.join(inputs.values())
        model_manager = ModelManager()
        model_instance = model_manager.get_model_instance(
            tenant_id=self.tenant_id,
            provider="openai",
            model_type=ModelType.MODERATION,
            model="text-moderation-stable"
        )

        openai_moderation = model_instance.invoke_moderation(
            text=text
        )

        return openai_moderation

in api/core/moderation/openai_moderation/openapi_moderation.py is throwing the error because it expects string when the number input is int.

Originally created by @AndyMik90 on GitHub (May 22, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.8 ### Cloud or Self Hosted Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce If you use the "number" input field for a start node and have the open moderation functionality enabled. you get error "TypeError: sequence item 3: expected str instance, int found" ### ✔️ Expected Behavior Run the workflow ### ❌ Actual Behavior Seems that the function: ``` def _is_violated(self, inputs: dict): text = '\n'.join(inputs.values()) model_manager = ModelManager() model_instance = model_manager.get_model_instance( tenant_id=self.tenant_id, provider="openai", model_type=ModelType.MODERATION, model="text-moderation-stable" ) openai_moderation = model_instance.invoke_moderation( text=text ) return openai_moderation ``` in api/core/moderation/openai_moderation/openapi_moderation.py is throwing the error because it expects string when the number input is int.
yindo added the 🐞 bug label 2026-02-21 17:59:23 -05:00
yindo closed this issue 2026-02-21 17:59:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#3569