-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
163 lines (156 loc) · 2.86 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const axios = require('axios');
const fs = require('fs');
const api = "http://127.0.0.1:8188"
async function queuePrompt(prompt) {
try {
const response = await axios.post( api+'/prompt', { prompt });
console.log('Response:', response.data);
} catch (error) {
console.error('Error sending prompt:', error);
}
}
const promptText = `
{
"3": {
"inputs": {
"seed": 23131,
"steps": 20,
"cfg": 8,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 1,
"model": [
"4",
0
],
"positive": [
"6",
0
],
"negative": [
"7",
0
],
"latent_image": [
"5",
0
]
},
"class_type": "KSampler",
"_meta": {
"title": "KSampler"
}
},
"4": {
"inputs": {
"ckpt_name": "majicMIX realistic 麦橘写实_v7.safetensors"
},
"class_type": "CheckpointLoaderSimple",
"_meta": {
"title": "Load Checkpoint"
}
},
"5": {
"inputs": {
"width": 512,
"height": 512,
"batch_size": 1
},
"class_type": "EmptyLatentImage",
"_meta": {
"title": "Empty Latent Image"
}
},
"6": {
"inputs": {
"text": "1 girl",
"clip": [
"4",
1
]
},
"class_type": "CLIPTextEncode",
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"7": {
"inputs": {
"text": "text, watermark",
"clip": [
"4",
1
]
},
"class_type": "CLIPTextEncode",
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"8": {
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
},
"class_type": "VAEDecode",
"_meta": {
"title": "VAE Decode"
}
},
"9": {
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
},
"class_type": "SaveImage",
"_meta": {
"title": "Save Image"
}
},
"11": {
"inputs": {
"images": [
"13",
0
]
},
"class_type": "PreviewImage",
"_meta": {
"title": "Preview Image"
}
},
"13": {
"inputs": {
"notify_url": "https://api.xxx.com/notify",
"task_id": "12345678",
"image": [
"8",
0
]
},
"class_type": "成功回调",
"_meta": {
"title": "成功回调"
}
}
}
`;
const prompt = JSON.parse(promptText);
// 修改 JSON 配置(如有需要)
prompt["6"]["inputs"]["text"] = "masterpiece best quality man";
// 生成随机 seed
const randomSeed = Math.floor(Math.random() * 10000) + 1;
prompt["3"]["inputs"]["seed"] = randomSeed;
// 生成随机 task_id
const randomTaskId = Math.floor(Math.random() * 1000000).toString();
prompt["13"]["inputs"]["task_id"] = randomTaskId;
queuePrompt(prompt);