2025-05-07 17:10:09 +00:00
|
|
|
|
package tests
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"crypto/tls"
|
|
|
|
|
"fmt"
|
|
|
|
|
"gitea.pena/SQuiz/common/model"
|
2025-05-16 08:33:04 +00:00
|
|
|
|
"gitea.pena/SQuiz/worker/internal/clients/gigachat"
|
2025-05-07 17:10:09 +00:00
|
|
|
|
"github.com/go-redis/redis/v8"
|
|
|
|
|
"github.com/go-resty/resty/v2"
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGigachat(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
logger, _ := zap.NewDevelopment()
|
|
|
|
|
|
|
|
|
|
redisClient := redis.NewClient(&redis.Options{
|
|
|
|
|
Addr: "localhost:6379",
|
|
|
|
|
Password: "admin",
|
|
|
|
|
DB: 2,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
gigaChatClient, err := gigachat.NewGigaChatClient(ctx, gigachat.Deps{
|
|
|
|
|
Logger: logger,
|
|
|
|
|
Client: resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}),
|
|
|
|
|
BaseURL: "https://gigachat.devices.sberbank.ru/api/v1",
|
|
|
|
|
AuthKey: "ZGM3MDY0ZjAtODM4Yi00ZTQ4LTgzMTgtZDA0ZDA3NmIwYzJjOjRkZWI4Y2NhLTc1YzUtNDg5ZS04YzY4LTVkNTdmMWU1YjU5Nw==",
|
|
|
|
|
RedisClient: redisClient,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
go gigaChatClient.TokenResearch(ctx)
|
|
|
|
|
|
|
|
|
|
result, err := gigaChatClient.SendMsg(ctx, model.GigaChatAudience{
|
2025-06-06 14:27:43 +00:00
|
|
|
|
Sex: 1,
|
2025-05-10 14:11:35 +00:00
|
|
|
|
Age: "17-23",
|
2025-05-07 17:10:09 +00:00
|
|
|
|
}, model.Question{
|
|
|
|
|
Title: "О личной жизни",
|
|
|
|
|
Description: "Как много у вас котят?",
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println(result)
|
|
|
|
|
|
|
|
|
|
time.Sleep(10 * time.Minute)
|
|
|
|
|
}
|