40 lines
752 B
Go
40 lines
752 B
Go
|
package llm
|
||
|
|
||
|
import (
|
||
|
_ "apigo.cc/ai/llm/zhipu"
|
||
|
"apigo.cc/apigo/gojs"
|
||
|
_ "apigo.cc/apigo/gojs/modules"
|
||
|
"fmt"
|
||
|
"github.com/ssgo/u"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
//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.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)))
|
||
|
}
|