utils

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AiMut sync.Mutex

AiMut AI锁,防止同时过多调用

Functions

func AICheck

func AICheck(url, model, apiKey string, aiType ctype.AiType) error

AICheck AI可用性检测

func AggregationAIApi

func AggregationAIApi(url,
	model string,
	aiType ctype.AiType,
	aiChatMessages AIChatMessages,
	apiKey string) (string, error)

AggregationAIApi 聚合所有AI接口,直接通过aiType判断然后返回内容

func AutoVerification

func AutoVerification(img image.Image, outputShape ort.Shape) string

验证码识别

func ChatGLMChatReplyApi

func ChatGLMChatReplyApi(
	model,
	apiKey string,
	aiChatMessages AIChatMessages,
	retryNum int,
	lastErr error,
) (string, error)

ChatGLM API

func ConvertToGray

func ConvertToGray(img image.Image) *image.Gray

ConvertToGray 将彩色图像转换为灰度图

func CqieEncrypt

func CqieEncrypt(str string) []byte

加密函数:如果输入的 o 有效,则使用 SM4 加密

func DeleteFile

func DeleteFile(path string)

func DouBaoChatReplyApi

func DouBaoChatReplyApi(model,
	apiKey string,
	aiChatMessages AIChatMessages,
	retryNum int,
	lastErr error,
) (string, error)

DouBaoChatReplyApi 豆包API

func ImageToGrayFloatArray

func ImageToGrayFloatArray(img image.Image) []float32

图片转一维数组数据 ImageToGrayFloatArray 将灰度图像转换为一维浮点数组,范围为 [0.0, 1.0]

func LoadImage

func LoadImage(filePath string) (image.Image, error)

LoadImage 读取指定路径的图片并返回 image.Image 对象。 支持 JPEG 和 PNG 格式的图片。

func OtherChatReplyApi

func OtherChatReplyApi(url,
	model,
	apiKey string,
	aiChatMessages AIChatMessages,
	retryNum int,
	lastErr error,
) (string, error)

OtherChatReplyApi 其他支持CHATGPT API格式的AI模型接入

func PathExistForCreate

func PathExistForCreate(path string)

检测目录是否存在,不存在就创建

func PathExists

func PathExists(path string) (bool, error)

检测文件夹或文件是否存在

func ReadImg

func ReadImg(imgFile string) (image.Image, error)

从文件读取imgage

func ResizeImage

func ResizeImage(img image.Image, width, height uint) *image.RGBA

ResizeImage 将图片缩放到指定宽度和高度并返回 RGB 图像

func TongYiChatReplyApi

func TongYiChatReplyApi(
	model,
	apiKey string,
	aiChatMessages AIChatMessages,
	retryNum int,
	lastErr error,
) (string, error)

TongYiChatReplyApi 通义千问API

func XingHuoChatReplyApi

func XingHuoChatReplyApi(model,
	apiKey string,
	aiChatMessages AIChatMessages,
	retryNum int,
	lastErr error,
) (string, error)

星火API

func YatoriCoreInit

func YatoriCoreInit()

Types

type AIChatMessages

type AIChatMessages struct {
	Messages []Message `json:"messages"`
}

AIChatMessages ChatGLMChat struct that holds the chat messages.

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message struct represents individual messages.

type Problem

type Problem struct {
	gorm.Model
	Hash    string   //题目信息的Hash
	Type    string   //题目类型,比如单选,多选,简答题等
	Content string   //题目内容
	Answer  []string //答案
	Json    string   //json形式原内容
}

题目结构体

type QuestionSet added in v1.1.2

type QuestionSet struct {
	ID   string // 可以根据需要添加其他字段,例如题目ID
	HTML string
}

QuestionSet 结构体用于存储每个 div.Py-mian1 的原始 HTML 内容

func ParseQuestionSets added in v1.1.2

func ParseQuestionSets(doc *goquery.Document) []QuestionSet

ParseQuestionSets 函数用于提取所有 div.Py-mian1 节点的原始 HTML 内容

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL