-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
DALL-E Tool not responding with image #2246
Comments
🤖 Hey @perzeuss, great to cross paths with you again! 🚀 Thanks for providing such a detailed report about the DALL-E issue you're experiencing. I'm diving into it now and will be back with you in a jiffy with some answers. 😺 Hang tight! |
Another user faced this issue, see https://discord.com/channels/1082486657678311454/1107330913139970128/1200485873318383677 |
I did more debugging. API Logs:
Looks like the image has been generated. I also see that the frontend tries to fetch the image |
🤖 Based on the information you've provided, it seems like the issue might be related to how the DALL-E tool is handling the response from the OpenAI API. In the provided code, the response from the OpenAI API is expected to be in 'b64_json' format. However, the 'b64_json' response format is not a standard response format for the OpenAI API. The OpenAI API typically returns the generated image in a binary format, which is then base64 encoded by the client. In the provided code, it seems like the response is expected to be a base64 encoded JSON object, which might not be the case. Here's the problematic part of the code: response = client.images.generate(
prompt=prompt,
model='dall-e-3',
size=size,
n=n,
style=style,
quality=quality,
response_format='b64_json' # This might not be a valid response format
)
result = []
for image in response.data:
result.append(self.create_blob_message(blob=b64decode(image.b64_json),
meta={ 'mime_type': 'image/png' },
save_as=self.VARIABLE_KEY.IMAGE.value)) The 'b64_json' in the 'b64decode(image.b64_json)' line might not be the correct attribute to access the base64 encoded image data. You might need to check the actual structure of the response object to find the correct attribute. Please note that this is just a hypothesis based on the provided code and the typical behavior of the OpenAI API. The actual issue might be different based on the specific implementation of the DALL-E tool and the OpenAI API client. As for the expected format of the response from the DALL-E tool in the Dify codebase, it is a list of Here is the relevant code that constructs the response: result = []
for image in response.data:
result.append(self.create_blob_message(blob=b64decode(image.b64_json),
meta={ 'mime_type': 'image/png' },
save_as=self.VARIABLE_KEY.IMAGE.value))
return result In this code, You can find more details in the Dify codebase, specifically in the dalle2.py and dalle3.py files. I hope this helps in identifying the issue. If you need further assistance, please provide more details about the specific implementation of the DALL-E tool and the OpenAI API client in your setup. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Fixed for me by adding a missing entry in the nginx conf (
I used https://github.com/BorisPolonsky/dify-helm to set up dify and the nginx setup is out of date there. I opened a PR to resolve this: BorisPolonsky/dify-helm#29 |
Thank you so much for the quick fix and I can confirm that in my case it is working like a charm! FYI, I was using the docker compose way to fire up the server and added in the missing section as suggested by @perzeuss in the |
How about remove this from the system prompt, this seems unnecessary to me. |
I just did that for testing, because I initially thought the image does the wrong thing because of the tool response "image has been created and sent to user already, you should tell user to check it now." However, the issue can be closed, we just had to update the nginx config and there was no migration hint about that. |
Self Checks
Dify version
0.5.2
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
✔️ Expected Behavior
Agent responds with an image generated by DALL-E 3
❌ Actual Behavior
Agend responds with an empty image.
Tool data:
Hint: I can see in https://platform.openai.com/usage that DALL-E api has been called and images have been generated.
The text was updated successfully, but these errors were encountered: