Wildric-Auric / MidJourney-Wrapper

MidJourney wrapper in Discord.
Creative Commons Zero v1.0 Universal
695 stars 149 forks source link

Midjourney blend #34

Open secolaha opened 1 year ago

secolaha commented 1 year ago

Hi, This is an excelent pierce of code! Would it be possible to add the midjourney Blend command to the API? https://docs.midjourney.com/docs/blend

Wildric-Auric commented 1 year ago

That's a nice feature. When it will be implemented I will come back to this issue.

secolaha commented 1 year ago

Hi, Thanks for the quick reply. I not sure i understand. Where will it need to be implemented? It is currently working in Midjourney.

Wildric-Auric commented 1 year ago

I meant implemented in my repository.

Xs1937 commented 1 year ago

你好,globals文件的配置信息在哪里可以获取到呢

secolaha commented 1 year ago

makes sense :) got as bit confused there. thanks for the update.

zhaoleigithub commented 1 year ago

How to get SALAI_TOKEN?

SergioLopezMaldonado commented 1 year ago

I keep having the same 400 error

Wildric-Auric commented 1 year ago

@zhaoleigithub @SergioLopezMaldonado @Xs1937 Please manage to not ask questions unrelated to the issue where they are posted. For instance, the current issue is still opened for a futur feature implementation. However, for setting up globals.py, look at #37 and #18. Also read the first part of the Readme. @SergioLopezMaldonado For the 400 error, if you read other issues you will find how to debug. I'm almost sure you would find someone who has the same issue as you. Wrong token, wrong channel ID etc...

yuexdang commented 1 year ago

About Blend, I was stuck on a key step, which was that when I sent a request, if I used consistent parameters, it would go into a network error state after a short time, so that I could not send the content.

Here is my interpretation of Blend. There are two parts of the parameters that need to be modified, one in payload.data.options and the other in payload.data.application The argument to command.attachments, nonce is useless and this is how I write my request:

payload = {
    "type":2,"application_id":Globals.MID_JOURNEY_ID,
    "guild_id":Globals.SERVER_ID,"channel_id":Globals.CHANNEL_ID,
    "session_id":What you get from other session you send,
    "data":{
        "version":JUST SECRET,"id":JUST SECRET,
        "name":"blend","type":1,"options":options you need to get,
            "application_command":{
                "id":JUST SECRET,"application_id":Globals.MID_JOURNEY_ID,
                "version":JUST SECRET,
                "default_permission":True,
                "default_member_permissions":None,"type":1,"nsfw":False,
                "name":"blend","description":"Blend images together seamlessly!",
                "dm_permission":True,"options":[
                    {"type":11,"name":"image1","description":"First image to add to the blend","required":True},
                    {"type":11,"name":"image2","description":"Second image to add to the blend","required":True},
                    {"type":3,"name":"dimensions","description":"The dimensions of the image. If not specified, the image will be square.","choices":[{"name":"Portrait","value":"--ar 2:3"},{"name":"Square","value":"--ar 1:1"},{"name":"Landscape","value":"--ar 3:2"}]},
                    {"type":11,"name":"image3","description":"Third image to add to the blend (optional)"},
                    {"type":11,"name":"image4","description":"Fourth image to add to the blend (optional)"},
                    {"type":11,"name":"image5","description":"Fifth image to add to the blend (optional)"}]},
                    "attachments":attachments,
            }
}

There are a few things I suspect are wrong here, the first is the session id and version parameters, obviously they should have a fixed value, but I find that sending requests after a while changes the value, I'm not sure why, because blend doesn't have any developer documentation The second one is attachments, which obviously contains a parameter to upload filename, which is supposed to be one of the things that discord returns. I tried the url of the image, and in an experiment it worked, I thought it would work

But now obviously I can't run it properly, if you do, I hope to have a chance to receive a reply.

If you need my library, I have fork out a branch, if you need I can talk to you privately.

yslion commented 1 year ago

@yuexdang "id":JUST SECRET i think this is interaction.id of midjourney bot , but i have no idea of how to get it .

Wildric-Auric commented 1 year ago

@yuexdang its a very specific issue, if you want to put a link to something functional in a github repository about the issue or make a pull request, feel free to do it, but don't talk about more general stuff here please.

yuexdang commented 1 year ago

@yuexdang its a very specific issue, if you want to put a link to something functional in a github repository about the issue or make a pull request, feel free to do it, but don't talk about more general stuff here please.

So sorry about that , I promise I will never do that.

yuexdang commented 1 year ago

@yuexdang "id":JUST SECRET i think this is interaction.id of midjourney bot , but i have no idea of how to get it .

In my test , It just like a fixed value.I'm not sure about that but we can used it temporary. If your mean is that you can't get it, use developer tools in Browser, from the web request to find it

Wildric-Auric commented 1 year ago

I'm going to work next week on this project and perhaps add all new features of MidJourney

ebullienc3 commented 1 year ago

I'm going to work next week on this project and perhaps add all new features of MidJourney

Appreciate it, waiting on this.

yuexdang commented 1 year ago

There was an important problem. After a discord conversion, we couldn't get the upload filename variable, so we couldn't send the request properly when forging it So, Is there a way to retrieve requests for interactions, or to find other parameters that attachments can enter, or maybe we faked a discord request to convert images (I don't think converting images is a good option)?

mluciani commented 1 year ago

I tried the url of the image, and in an experiment it worked, I thought it would work

hi @yuexdang, how did you do this? Did you mean you used another valid upload_filename value or you were able to put in a URL somehow? I am stuck here as well because as far as I can tell there is no way to get the upload_filename.

(note I am trying to implement /describe not /blend, but its the same problem)

yuexdang commented 1 year ago

I tried the url of the image, and in an experiment it worked, I thought it would work

hi @yuexdang, how did you do this? Did you mean you used another valid upload_filename value or you were able to put in a URL somehow? I am stuck here as well because as far as I can tell there is no way to get the upload_filename.

This problem has been solved

First obtain the image link, then transfer the image link to google.api. When transferring, the image name sent is filename, and the content obtained after transferring includes upload_ filename

For detailed information, please refer to the issue below: https://github.com/yuexdang/DandJourney/issues/3