upgrade to new gojs
This commit is contained in:
		
							parent
							
								
									459a235055
								
							
						
					
					
						commit
						f9c67b6d50
					
				@ -1,2 +1,3 @@
 | 
			
		||||
# huoshan
 | 
			
		||||
 | 
			
		||||
To know about js functions, go to [huoshan.ts](https://apigo.cc/ai/huoshan/huoshan.ts)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								go.mod
									
									
									
									
									
								
							@ -3,33 +3,27 @@ module apigo.cc/ai/huoshan
 | 
			
		||||
go 1.18
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	apigo.cc/apigo/gojs v0.1.1
 | 
			
		||||
	apigo.cc/gojs v0.0.1
 | 
			
		||||
	github.com/ssgo/config v1.7.7
 | 
			
		||||
	github.com/ssgo/log v1.7.7
 | 
			
		||||
	github.com/ssgo/u v1.7.7
 | 
			
		||||
	github.com/ssgo/u v1.7.9
 | 
			
		||||
	github.com/volcengine/volc-sdk-golang v1.0.178
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	golang.org/x/net v0.29.0 // indirect
 | 
			
		||||
	golang.org/x/text v0.18.0 // indirect
 | 
			
		||||
	golang.org/x/net v0.30.0 // indirect
 | 
			
		||||
	golang.org/x/text v0.19.0 // indirect
 | 
			
		||||
	gopkg.in/yaml.v3 v3.0.1 // indirect
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	filippo.io/edwards25519 v1.1.0 // indirect
 | 
			
		||||
	github.com/cenkalti/backoff/v4 v4.1.2 // indirect
 | 
			
		||||
	github.com/dlclark/regexp2 v1.11.4 // indirect
 | 
			
		||||
	github.com/fsnotify/fsnotify v1.7.0 // indirect
 | 
			
		||||
	github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
 | 
			
		||||
	github.com/go-sql-driver/mysql v1.8.1 // indirect
 | 
			
		||||
	github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
 | 
			
		||||
	github.com/google/uuid v1.6.0 // indirect
 | 
			
		||||
	github.com/mitchellh/mapstructure v1.5.0 // indirect
 | 
			
		||||
	github.com/ssgo/dao v0.1.5 // indirect
 | 
			
		||||
	github.com/ssgo/db v1.7.9 // indirect
 | 
			
		||||
	github.com/ssgo/httpclient v1.7.7 // indirect
 | 
			
		||||
	github.com/ssgo/standard v1.7.7 // indirect
 | 
			
		||||
	github.com/ssgo/tool v0.4.27 // indirect
 | 
			
		||||
	golang.org/x/sys v0.25.0 // indirect
 | 
			
		||||
	golang.org/x/sys v0.26.0 // indirect
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
package huoshan
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"apigo.cc/apigo/gojs"
 | 
			
		||||
	"apigo.cc/gojs"
 | 
			
		||||
	_ "embed"
 | 
			
		||||
	"github.com/ssgo/config"
 | 
			
		||||
	"github.com/ssgo/log"
 | 
			
		||||
@ -30,13 +30,14 @@ func SetSSKey(key, iv []byte) {
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	obj := gojs.Map{
 | 
			
		||||
		"name":  "huoshan",
 | 
			
		||||
		"image": RequireImage(),
 | 
			
		||||
	}
 | 
			
		||||
	config.LoadConfig("huoshan", &conf)
 | 
			
		||||
	conf.AKey = confAes.DecryptUrlBase64ToString(conf.AKey)
 | 
			
		||||
	conf.SKey = confAes.DecryptUrlBase64ToString(conf.SKey)
 | 
			
		||||
	log.DefaultLogger.Info("Conf", "", conf)
 | 
			
		||||
	gojs.Register("huoshan", gojs.Module{
 | 
			
		||||
	gojs.Register("apigo.cc/ai/huoshan", gojs.Module{
 | 
			
		||||
		Object:  obj,
 | 
			
		||||
		TsCode:  huoshanTS,
 | 
			
		||||
		Example: "",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								huoshan.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								huoshan.ts
									
									
									
									
									
								
							@ -2,9 +2,19 @@ export default {
 | 
			
		||||
    image: {
 | 
			
		||||
        text2image,
 | 
			
		||||
        image2image,
 | 
			
		||||
        readImage
 | 
			
		||||
        readImage,
 | 
			
		||||
        base64
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//about image
 | 
			
		||||
function text2image(prompt:string, option?:Object):string  {return ""}
 | 
			
		||||
function image2image(image:string[], prompt:string, option?:Object):string  {return ""}
 | 
			
		||||
// image2image
 | 
			
		||||
// image able with base64, bin(byte[], what you get from "readImage"), url(url must be written in an array like ["your url"])
 | 
			
		||||
function image2image(image, prompt:string, option?:Object):string  {return ""}
 | 
			
		||||
function readImage(path:string):string {return ""}
 | 
			
		||||
// base64 written-in base64 function,you can use what you want
 | 
			
		||||
// data give what you want to give
 | 
			
		||||
function base64(data):string {return ""}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								image.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								image.go
									
									
									
									
									
								
							@ -1,8 +1,8 @@
 | 
			
		||||
package huoshan
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"apigo.cc/apigo/gojs"
 | 
			
		||||
	"apigo.cc/apigo/gojs/dop251/goja"
 | 
			
		||||
	"apigo.cc/gojs"
 | 
			
		||||
	"apigo.cc/gojs/goja"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/ssgo/log"
 | 
			
		||||
	"github.com/ssgo/u"
 | 
			
		||||
@ -62,6 +62,9 @@ func RequireImage() gojs.Map {
 | 
			
		||||
				panic(vm.NewGoError(err))
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		"base64": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
 | 
			
		||||
			return vm.ToValue(u.Base64(u.Bytes(gojs.MakeArgs(&argsIn, vm).Check(1).Any(0))))
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -90,7 +93,6 @@ func T2IXL(prompt string, option map[string]interface{}, vm *goja.Runtime) []str
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// I2IXLbyUrl used t2i_xl_sft
 | 
			
		||||
//
 | 
			
		||||
// option 会覆盖已有参数,可传空,return_url不可更改
 | 
			
		||||
func I2IXLbyUrl(imageUrls []string, prompt string, option map[string]interface{}, vm *goja.Runtime) []string {
 | 
			
		||||
	vis := visual.NewInstance()
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								test.js
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								test.js
									
									
									
									
									
								
							@ -1,8 +1,7 @@
 | 
			
		||||
import {image} from "huoshan"
 | 
			
		||||
import u from "util"
 | 
			
		||||
import {image} from 'apigo.cc/ai/huoshan'
 | 
			
		||||
 | 
			
		||||
function main() {
 | 
			
		||||
    let a = image.image2image(u.base64(image.readImage("img_2.jpeg")), "在吃冰淇淋", {
 | 
			
		||||
    let a = image.image2image(image.base64(image.readImage("img_2.jpeg")), "在吃冰淇淋", {
 | 
			
		||||
        style_reference_args: {
 | 
			
		||||
            id_weight: 1.0
 | 
			
		||||
        }
 | 
			
		||||
@ -12,7 +11,7 @@ function main() {
 | 
			
		||||
            id_weight: 1.0
 | 
			
		||||
        }
 | 
			
		||||
    })
 | 
			
		||||
    let c = image.image2image([""], "在吃冰淇淋", {
 | 
			
		||||
    let c = image.image2image(["一个url"], "在吃冰淇淋", {
 | 
			
		||||
        style_reference_args: {
 | 
			
		||||
            id_weight: 1.0
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,7 @@
 | 
			
		||||
package huoshan
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"apigo.cc/apigo/gojs"
 | 
			
		||||
	_ "apigo.cc/apigo/gojs/modules"
 | 
			
		||||
	"apigo.cc/gojs"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/ssgo/u"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user