worker/tests/gigachat_test.go
Pasha 056d15094b
All checks were successful
Deploy / CreateImage (push) Successful in 2m40s
Deploy / ValidateConfig (push) Successful in 29s
Deploy / MigrateDatabase (push) Successful in 51s
Deploy / DeployService (push) Successful in 29s
update common and type sex
2025-06-08 19:19:13 +00:00

54 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tests
import (
"context"
"crypto/tls"
"fmt"
"gitea.pena/SQuiz/common/model"
"gitea.pena/SQuiz/worker/internal/clients/gigachat"
"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{
Sex: 1,
Age: "17-23",
}, model.Question{
Title: "О личной жизни",
Description: "Как много у вас котят?",
})
if err != nil {
panic(err)
}
fmt.Println(result)
time.Sleep(10 * time.Minute)
}