siliconflow

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 4 Imported by: 0

README

该包用于调用硅基流动下的非对话大模型类功能

模型列表:硅基流动

对话类例如deepseek-ai/DeepSeek-R1,openai包均支持

快速上手

文生图

package main

import (
	"fmt"
	"os"

	"github.com/dingdinglz/openai/siliconflow"
)

func main() {
	client := siliconflow.New(&siliconflow.Config{
		ApiKey: os.Getenv("APIKEY"),
	})
	res, e := client.Text2Image(siliconflow.Text2ImageRequest{
		Model:     "stabilityai/stable-diffusion-3-5-large",
		BatchSize: 1,
		Prompt:    "画一只小猫",
	})
	if e != nil {
		fmt.Println(e.Error())
		return
	}
	for _, i := range res {
		fmt.Println(i)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(config *Config) *Client

func (*Client) Text2Image

func (client *Client) Text2Image(req Text2ImageRequest) ([]string, error)

调用文生图接口,成功返回生成的图片的url数组

type Config

type Config struct {
	ApiKey string
}

type Text2ImageRequest

type Text2ImageRequest struct {
	// 输出图片个数
	BatchSize int `json:"batch_size"`

	// 用于控制生成图像与给定提示(Prompt)的匹配程度,该值越高,生成的图像越倾向于严格匹配文本提示的内容;该值越低,则生成的图像会更加具有创造性和多样性,可能包含更多的意外元素。
	GuidanceScale float64 `json:"guidance_scale"`

	// 图像尺寸,格式:[宽度]x[高度]
	ImageSize string `json:"image_size"`

	// 模型名
	Model string `json:"model"`

	// 推理步骤数,其中stable-diffusion-3-5-large-turbo是固定值4
	NumInferenceSteps int `json:"num_inference_steps"`

	// 提示词
	Prompt string `json:"prompt"`
	// 负向提示词
	NegativePrompt string `json:"negative_prompt"`

	// 提示增强开关,当开启时,将提示优化为详细的、模型友好的版本
	PromptEnhancement bool `json:"prompt_enhancement"`

	// 随机种子
	Seed int64 `json:"seed"`
}

Jump to

Keyboard shortcuts

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