@@ -12,7 +12,10 @@ import (
12
12
"time"
13
13
)
14
14
15
- const negative = "(deformed eyes, nose, ears, nose, leg, head), bad anatomy, ugly"
15
+ const (
16
+ negative = "(deformed eyes, nose, ears, nose, leg, head), bad anatomy, ugly"
17
+ userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0"
18
+ )
16
19
17
20
func Ox001 (ctx * gin.Context , model , samples , message string ) (value string , err error ) {
18
21
var (
@@ -104,7 +107,7 @@ func Ox000(ctx *gin.Context, model, samples, message string) (value string, err
104
107
GET (baseUrl + "/queue/join" ).
105
108
Query ("fn_index" , "0" ).
106
109
Query ("session_hash" , hash ).
107
- DoS ( http .StatusOK )
110
+ DoC ( emit . Status ( http .StatusOK ), emit . IsSTREAM )
108
111
if err != nil {
109
112
return
110
113
}
@@ -248,6 +251,119 @@ func Ox002(ctx *gin.Context, model, message string) (value string, err error) {
248
251
return
249
252
}
250
253
254
+ func Ox003 (ctx * gin.Context , message string ) (value string , err error ) {
255
+ var (
256
+ hash = emit .GioHash ()
257
+ proxies = ctx .GetString ("proxies" )
258
+ domain = pkg .Config .GetString ("domain" )
259
+ baseUrl = "https://ehristoforu-dalle-3-xl-lora-v2.hf.space"
260
+ cookie = "_ga_R1FN4KJKJH=GS1.1.1718072627.1.0.1718072627.0.0.0; _ga=GA1.2.1193271156.1718072627; _gid=GA1.2.1863970600.1718072627"
261
+ r = rand .New (rand .NewSource (time .Now ().UnixNano ()))
262
+ )
263
+
264
+ if domain == "" {
265
+ domain = fmt .Sprintf ("http://127.0.0.1:%d" , ctx .GetInt ("port" ))
266
+ }
267
+
268
+ response , err := emit .ClientBuilder ().
269
+ Proxies (proxies ).
270
+ Context (ctx .Request .Context ()).
271
+ POST (baseUrl + "/queue/join" ).
272
+ Header ("Origin" , baseUrl ).
273
+ Header ("Referer" , baseUrl + "/?__theme=light" ).
274
+ Header ("User-Agent" , userAgent ).
275
+ Header ("Accept-Language" , "en-US,en;q=0.9" ).
276
+ Header ("Cookie" , cookie ).
277
+ JHeader ().
278
+ Body (map [string ]interface {}{
279
+ "data" : []interface {}{
280
+ message + ", {{{{by famous artist}}}, beautiful, 4k" ,
281
+ negative + ", extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation" ,
282
+ true ,
283
+ r .Intn (51206501 ) + 1100000000 ,
284
+ 1024 ,
285
+ 1024 ,
286
+ 12 ,
287
+ true ,
288
+ },
289
+ "event_data" : nil ,
290
+ "fn_index" : 3 ,
291
+ "trigger_id" : 6 ,
292
+ "session_hash" : hash ,
293
+ }).DoC (emit .Status (http .StatusOK ), emit .IsJSON )
294
+ if err != nil {
295
+ return "" , err
296
+ }
297
+ logger .Info (emit .TextResponse (response ))
298
+
299
+ response , err = emit .ClientBuilder ().
300
+ Proxies (proxies ).
301
+ Context (ctx .Request .Context ()).
302
+ GET (baseUrl + "/queue/data" ).
303
+ Query ("session_hash" , hash ).
304
+ Header ("Origin" , baseUrl ).
305
+ Header ("Referer" , baseUrl + "/?__theme=light" ).
306
+ Header ("User-Agent" , userAgent ).
307
+ Header ("Accept" , "text/event-stream" ).
308
+ Header ("Accept-Language" , "en-US,en;q=0.9" ).
309
+ Header ("Cookie" , cookie ).
310
+ DoC (emit .Status (http .StatusOK ), emit .IsSTREAM )
311
+ if err != nil {
312
+ return "" , err
313
+ }
314
+
315
+ c , err := emit .NewGio (ctx .Request .Context (), response )
316
+ if err != nil {
317
+ return "" , err
318
+ }
319
+
320
+ c .Event ("process_completed" , func (j emit.JoinEvent ) (_ interface {}) {
321
+ d := j .Output .Data
322
+
323
+ if len (d ) == 0 {
324
+ c .Failed (fmt .Errorf ("image generate failed: %s" , j .InitialBytes ))
325
+ return
326
+ }
327
+
328
+ values , ok := d [0 ].([]interface {})
329
+ if ! ok {
330
+ c .Failed (fmt .Errorf ("image generate failed: %s" , j .InitialBytes ))
331
+ return
332
+ }
333
+
334
+ if len (values ) == 0 {
335
+ c .Failed (fmt .Errorf ("image generate failed: %s" , j .InitialBytes ))
336
+ return
337
+ }
338
+
339
+ v , ok := values [0 ].(map [string ]interface {})
340
+ if ! ok {
341
+ c .Failed (fmt .Errorf ("image generate failed: %s" , j .InitialBytes ))
342
+ return
343
+ }
344
+
345
+ info , ok := v ["image" ].(map [string ]interface {})
346
+ if ! ok {
347
+ c .Failed (fmt .Errorf ("image generate failed: %s" , j .InitialBytes ))
348
+ return
349
+ }
350
+
351
+ // 锁环境了,只能先下载下来
352
+ value , err = com .Download (proxies , info ["url" ].(string ), "png" )
353
+ if err != nil {
354
+ c .Failed (fmt .Errorf ("image generate failed: %s" , j .InitialBytes ))
355
+ return
356
+ }
357
+
358
+ value = fmt .Sprintf ("%s/file/%s" , domain , value )
359
+ return
360
+ })
361
+
362
+ err = c .Do ()
363
+
364
+ return
365
+ }
366
+
251
367
func google (ctx * gin.Context , model , message string ) (value string , err error ) {
252
368
var (
253
369
hash = emit .GioHash ()
0 commit comments