llm_old/llm_test.go

44 lines
867 B
Go
Raw Normal View History

2024-10-02 14:09:54 +08:00
package llm
import (
"fmt"
"testing"
2024-10-12 14:37:11 +08:00
2024-10-25 15:57:24 +08:00
// uncomment apigo.cc/ai/zhipu for test
// _ "apigo.cc/ai/zhipu"
2024-10-12 14:37:11 +08:00
"apigo.cc/gojs"
_ "apigo.cc/gojs/console"
"github.com/ssgo/u"
2024-10-02 14:09:54 +08:00
)
//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) {
2024-10-12 14:37:11 +08:00
gojs.Alias("llm", "apigo.cc/ai/llm")
gojs.Alias("console", "apigo.cc/gojs/console")
2024-10-02 14:09:54 +08:00
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)))
}