43 lines
827 B
Go
43 lines
827 B
Go
package llm
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
_ "apigo.cc/ai/llm/zhipu"
|
|
"apigo.cc/gojs"
|
|
_ "apigo.cc/gojs/console"
|
|
"github.com/ssgo/u"
|
|
)
|
|
|
|
//func TestZhipu(t *testing.T) {
|
|
// zp := llm.Create("zp", "zhipu", llm.Config{
|
|
// ApiKey: "112dba40872699df44e07355f7de0c0c.ObK2rslHYBuxII5J",
|
|
// })
|
|
// r, usage, err := zp.FastAsk(llm.Messages().User().Text("你好").Make(), nil) //func(r string) {
|
|
// // fmt.Print(r)
|
|
// //})
|
|
//
|
|
// fmt.Println(11, r)
|
|
// fmt.Println(22, usage)
|
|
// fmt.Println(33, err)
|
|
//}
|
|
|
|
func TestExport(t *testing.T) {
|
|
gojs.Alias("llm", "apigo.cc/ai/llm")
|
|
gojs.Alias("console", "apigo.cc/gojs/console")
|
|
gojs.ExportForDev()
|
|
}
|
|
|
|
func TestLLM(t *testing.T) {
|
|
r, err := gojs.RunFile("test.js")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if r == nil {
|
|
t.Fatal("no answer")
|
|
}
|
|
fmt.Println()
|
|
fmt.Println(u.BCyan(u.JsonP(r)))
|
|
}
|