minimax

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 12 Imported by: 0

README

Go MiniMax

Go Reference Go Report Card

Fiber

👉 中文 | English


🚀 MiniMax API SDK for Go.

安装

go get github.com/luckpunk/go-minimax

go-minimax 需要 Go version 1.18 及以上.

功能

  • Chatcompletion pro
  • Chatcompletion
  • Embeddings
  • T2A
  • T2A pro
  • T2A large
  • T2A Stream
  • Voice Cloning
  • Assistants API
  • Thread
  • Run
  • Message
  • Files
  • Retrieval
  • Finetune API
  • Role Classification
  • Role Audio Generation

使用

Minimax ChatCompletion 示例:
package main

import (
	"context"
	"fmt"
	
	minimax "github.com/luckpunk/go-minimax"
)

func main() {
    client := minimax.NewClient("your token", "your group id")
	resp, err := client.CreateCompletion(context.Background(), &minimax.ChatCompletionRequest{
		Model:            minimax.Abab5Dot5,
		TokensToGenerate: 1024,
		RoleMeta: &minimax.RoleMeta{
			UserName: "我",
			BotName:  "专家",
		},
		Prompt: "你是一个擅长发现故事中蕴含道理的专家,你很善于基于我给定的故事发现其中蕴含的道理。",
		Messages: []minimax.Message{
			{
				SenderType: minimax.ChatMessageRoleUser,
				Text:       "Please introduce yourself.",
			},
		},
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("%v\n", resp.Reply)
}

Minimax ChatCompletionStream 示例:
package main

import (
	"context"
	"errors"
	"fmt"
	"io"

	minimax "github.com/luckpunk/go-minimax"
)

func main() {
    client := minimax.NewClient("your token", "your group id")
	stream, err := client.CreateCompletionStream(context.Background(), &minimax.ChatCompletionRequest{
		Model:            minimax.Abab5Dot5,
		TokensToGenerate: 1024,
		RoleMeta: &minimax.RoleMeta{
			UserName: "我",
			BotName:  "专家",
		},
		Prompt: "你是一个擅长发现故事中蕴含道理的专家,你很善于基于我给定的故事发现其中蕴含的道理。",
		Messages: []minimax.Message{
			{
				SenderType: minimax.ChatMessageRoleUser,
				Text:       "Please introduce yourself.",
			},
		},
	})
	if err != nil {
		panic(err)
	}
	defer stream.Close()

	for {
		resp, err := stream.Recv()
		if err != nil {
			if errors.Is(err, io.EOF) {
				break
			}
			panic(err)
		}
		fmt.Printf("%#v\n", resp)
	}
}

Minimax ChatCompletionPro 示例:
package main

import (
	"context"
	"errors"
	"fmt"
	"io"

	minimax "github.com/luckpunk/go-minimax"
)

func main() {
    client := minimax.NewClient("your token", "your group id")
	res, err := client.CreateCompletionPro(context.Background(), &minimax.ChatCompletionProRequest{
		Model:            minimax.Abab6,
		TokensToGenerate: 1024,
		Messages: []minimax.ProMessage{
			{
				SenderType: minimax.ChatMessageRoleUser,
				SenderName: "Twac",
				Text:       "请介绍一下你自己",
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	fmt.Printf("%#v\n", res)
}

Minimax ChatCompletionProStream 示例:
package main

import (
	"context"
	"errors"
	"fmt"
	"io"

	minimax "github.com/luckpunk/go-minimax"
)

func main() {
    client := minimax.NewClient("your token", "your group id")
	stream, err := client.CreateCompletionProStream(context.Background(), &minimax.ChatCompletionProRequest{
		Model:            minimax.Abab6,
		TokensToGenerate: 1024,
		Messages: []minimax.ProMessage{
			{
				SenderType: minimax.ChatMessageRoleUser,
				SenderName: "Twac",
				Text:       "请介绍一下你自己",
			},
		},
	})
	if err != nil {
		panic(err)
	}
	defer stream.Close()

	for {
		resp, err := stream.Recv()
		if err != nil {
			if errors.Is(err, io.EOF) {
				break
			}
			panic(err)
		}
		fmt.Printf("%#v\n", resp)
	}
}

Minimax CreateEmbeddings 示例:
package main

import (
	"context"
	"fmt"
	
	minimax "github.com/luckpunk/go-minimax"
)

func main() {
    client := minimax.NewClient("your token", "your group id")
	resp, err := client.CreateEmbeddings(context.Background(), &minimax.CreateEmbeddingsRequest{
		Texts: []string{"hello"},
		// Type: minimax.EmbeddingsDbType,
		Type:  minimax.EmbeddingsQueryType,
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", resp)
}

Minimax CreateTextToSpeech 示例:
package main

import (
	"context"
	"fmt"

	minimax "github.com/luckpunk/go-minimax"
)

func main() {
	client := minimax.NewClient("your token", "your group id")
	resp, err := client.CreateTextToSpeech(context.Background(), &minimax.CreateT2ARequest{
		Text:    "hello",
		VoiceID: "female-yujie",
		Path:    "./",
		Name:    "hello.mp3",
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("%#v\n", resp)
}

Minimax CreateTextToSpeechPro 示例:
package main

import (
	"context"
	"fmt"

	minimax "github.com/luckpunk/go-minimax"
)

func main() {
	client := minimax.NewClient("your token", "your group id")
	resp, err := client.CreateTextToSpeechPro(context.Background(), &minimax.CreateT2ARequest{
		Text:    "hello",
		VoiceID: "female-yujie",
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("%#v\n", resp)
}

Documentation

Index

Constants

View Source
const (
	Abab5       = "abab5-chat"
	Abab5Dot5   = "abab5.5-chat"
	Abab5Dot5s  = "abab5.5s-chat"
	Abab6       = "abab6-chat"
	Embo01      = "embo-01"
	Speech01    = "speech-01"
	Speech02    = "speech-02"
	Speech01Pro = "speech-01-pro" // alias speech-01=speech-01-pro

	ModelBot            = "MM智能助理"
	ChatMessageRoleUser = "USER"
	ChatMessageRoleBot  = "BOT"
	EmbeddingsDbType    = "db"
	EmbeddingsQueryType = "query"

	ToolCodeInterpreter = "code_interpreter"
	ToolRetrieval       = "retrieval"
	ToolFunction        = "function"
	ToolWebSearch       = "web_search"
)
View Source
const (
	VoiceMaleQnQingSe            = "male-qn-qingse"             // 青涩青年音色
	VoiceMaleQnJingYing          = "male-qn-jingying"           // 精英青年音色
	VoiceMaleQnBaDao             = "male-qn-badao"              // 霸道青年音色
	VoiceMaleQnDaXueSheng        = "male-qn-daxuesheng"         // 青年大学生音色
	VoiceFemaleShaoNv            = "female-shaonv"              // 少女音色
	VoiceFemaleYuJie             = "female-yujie"               // 御姐音色
	VoiceFemaleChengShu          = "female-chengshu"            // 成熟女性音色
	VoiceFemaleTianMei           = "female-tianmei"             // 甜美女性音色
	VoicePresenterMale           = "presenter_male"             // 男性主持人
	VoicePresenterFemale         = "presenter_female"           // 女性主持人
	VoiceAudiobookMale1          = "audiobook_male_1"           // 男性有声书1
	VoiceAudiobookMale2          = "audiobook_male_2"           // 男性有声书2
	VoiceAudiobookFemale1        = "audiobook_female_1"         // 女性有声书1
	VoiceAudiobookFemale2        = "audiobook_female_2"         // 女性有声书2
	VoiceMaleQnQingSeJingPin     = "male-qn-qingse-jingpin"     // 青涩青年音色-beta
	VoiceMaleQnJingYingJingPin   = "male-qn-jingying-jingpin"   // 精英青年音色-beta
	VoiceMaleQnBaDaoJingPin      = "male-qn-badao-jingpin"      // 霸道青年音色-beta
	VoiceMaleQnDaXueShengJingPin = "male-qn-daxuesheng-jingpin" // 青年大学生音色-beta
	VoiceFemaleShaoNvJingPin     = "female-shaonv-jingpin"      // 少女音色-beta
	VoiceFemaleYuJieJingPin      = "female-yujie-jingpin"       // 御姐音色-beta
	VoiceFemaleChengShuJingPin   = "female-chengshu-jingpin"    // 成熟女性音色-beta
	VoiceFemaleTianMeiJingPin    = "female-tianmei-jingpin"     // 甜美女性音色-beta
)

voice_id:音色编号支,持系统音色(id)以及复刻音色(id)两种类型,其中系统音色(ID)如下:

View Source
const (
	APIV1 = "https://api.minimax.chat/v1"
)

Variables

View Source
var (
	ErrCompletionUnsupportedModel        = errors.New("this model is not supported with this method, please use CreateChatCompletion client method instead") //nolint:lll
	ErrCompletionStreamNotSupported      = errors.New("streaming is not supported with this method, please use CreateCompletionStream")                      //nolint:lll
	ErrTooManyEmptyStreamMessages        = errors.New("too many empty messages")
	ErrCreateTextToSpeechProNotSupported = errors.New("params is not supported, please use CreateTextToSpeechPro")
)

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Typ          string        `json:"type"`
	Text         string        `json:"text"`
	StartIndex   int64         `json:"start_index"`
	EndIndex     int64         `json:"end_index"`
	FileCitation *FileCitation `json:"file_citation"`
	WebCitation  *WebCitation  `json:"web_citation"`
}

type Assistant

type Assistant struct {
	ID           string            `json:"id"`
	Object       string            `json:"object"`
	CreatedAt    int64             `json:"created_at"`
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Model        string            `json:"model"`
	Instructions string            `json:"instructions"`
	Tools        []*Tool           `json:"tools"`
	FileIds      []string          `json:"file_ids"`
	MetaData     map[string]string `json:"meta_data"`
	RoleMeta     *RoleMeta         `json:"role_meta"`
	Status       string            `json:"status"`
}

type AssistantCreateRequest

type AssistantCreateRequest struct {
	Model        string            `json:"model"`
	RoleMeta     *RoleMeta         `json:"role_meta"`
	Instructions string            `json:"instructions,omitempty"`
	Name         string            `json:"name,omitempty"`
	Description  string            `json:"description,omitempty"`
	Tools        []*Tool           `json:"tools,omitempty"`
	FileIds      []string          `json:"file_ids,omitempty"`
	MetaData     map[string]string `json:"meta_data,omitempty"`
}

type AssistantDeleteResponse

type AssistantDeleteResponse struct {
	ID       string    `json:"id"`
	Object   string    `json:"object"`
	Deleted  bool      `json:"deleted"`
	BaseResp *BaseResp `json:"base_resp"`
}

type AssistantFile

type AssistantFile struct {
	ID          string `json:"id"`
	Object      string `json:"object"`
	CreatedAt   int64  `json:"created_at"`
	AssistantId string `json:"assistant_id"`
}

type AssistantFileListResponse

type AssistantFileListResponse struct {
	Object   string           `json:"object"`
	Data     []*AssistantFile `json:"data"`
	HasMore  bool             `json:"has_more"`
	FirstId  string           `json:"first_id"`
	LastId   string           `json:"last_id"`
	BaseResp *BaseResp        `json:"base_resp"`
}

type AssistantFilesCreateRequest

type AssistantFilesCreateRequest struct {
	AssistantId string `json:"assistant_id"`
	FileId      string `json:"file_id"`
}

type AssistantFilesCreateResponse

type AssistantFilesCreateResponse struct {
	ID          string    `json:"id"`
	Object      string    `json:"object"`
	CreatedAt   string    `json:"created_at"`
	AssistantId string    `json:"assistant_id"`
	BaseResp    *BaseResp `json:"base_resp"`
}

type AssistantListOption

type AssistantListOption struct {
	AssistantId string `json:"assistant_id"`
	FileId      string `json:"file_id"`
	Limit       int    `json:"limit"`
	Order       string `json:"order"`
	Before      string `json:"before"`
	After       string `json:"after"`
}

type AssistantListResponse

type AssistantListResponse struct {
	Object   string       `json:"object"`
	Data     []*Assistant `json:"data"`
	HasMore  bool         `json:"has_more"`
	FirstId  string       `json:"first_id"`
	LastId   string       `json:"last_id"`
	BaseResp *BaseResp    `json:"base_resp"`
}

type AssistantRetrieveResponse

type AssistantRetrieveResponse struct {
	*Assistant
	BaseResp *BaseResp `json:"base_resp"`
}

type AsstMessage

type AsstMessage struct {
	ID          string            `json:"id"`
	Object      string            `json:"object"`
	CreatedAt   int64             `json:"created_at"`
	ThreadId    string            `json:"thread_id"`
	Role        string            `json:"role"`
	Content     []*Content        `json:"content"`
	FileIds     []string          `json:"file_ids"`
	AssistantId string            `json:"assistant_id"`
	RunId       string            `json:"run_id"`
	MetaData    map[string]string `json:"metadata"`
}

type BaseResp

type BaseResp struct {
	StatusCode int    `json:"status_code"`
	StatusMsg  string `json:"status_msg"`
}

type BotSetting

type BotSetting struct {
	BotName string `json:"bot_name"`
	Content string `json:"content"`
}

type CallFunction

type CallFunction struct {
	ID       string `json:"id"`
	Typ      string `json:"type"`
	Function struct {
		Name      string `json:"name"`
		Arguments string `json:"arguments"`
		Output    string `json:"output"`
	} `json:"function"`
}

type CallRetrieval

type CallRetrieval struct {
	ID        string `json:"id"`
	Typ       string `json:"type"`
	Retrieval struct {
		Query   string `json:"query"`
		Outputs string `json:"outputs"`
	} `json:"retrieval"`
}

type ChatCompletionProRequest

type ChatCompletionProRequest struct {
	Model             string           `json:"model"`
	Messages          []ProMessage     `json:"messages"`
	BotSetting        []BotSetting     `json:"bot_setting"`
	SampleMessages    []Message        `json:"sample_messages,omitempty"`
	Stream            bool             `json:"stream,omitempty"`
	TokensToGenerate  int64            `json:"tokens_to_generate,omitempty"`
	Temperature       float32          `json:"temperature,omitempty"`
	TopP              float32          `json:"top_p,omitempty"`
	MaskSensitiveInfo bool             `json:"mask_sensitive_info,omitempty"`
	Functions         []*Function      `json:"functions,omitempty"`
	FunctionCall      *FunctionCall    `json:"function_call,omitempty"`
	ReplyConstraints  ReplyConstraints `json:"reply_constraints"`
	Plugins           []string         `json:"plugins"`
}

type ChatCompletionProResponse

type ChatCompletionProResponse struct {
	ID                  string                 `json:"id"`
	Created             int64                  `json:"created"`
	Model               string                 `json:"model"`
	Reply               string                 `json:"reply"`
	Choices             []ChatMessageProChoice `json:"choices"`
	Usage               Usage                  `json:"usage"`
	InputSensitive      bool                   `json:"input_sensitive,omitempty"`
	InputSensitiveType  int64                  `json:"input_sensitive_type,omitempty"`
	OutputSensitive     bool                   `json:"output_sensitive,omitempty"`
	OutputSensitiveType int64                  `json:"output_sensitive_type"`
	BaseResp            BaseResp               `json:"base_resp,omitempty"`
}

type ChatCompletionProStream

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

func (ChatCompletionProStream) Close

func (stream ChatCompletionProStream) Close()

func (ChatCompletionProStream) Recv

func (stream ChatCompletionProStream) Recv() (T, error)

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model               string    `json:"model"`
	Messages            []Message `json:"messages"`
	Stream              bool      `json:"stream,omitempty"`
	Prompt              string    `json:"prompt"`
	TokensToGenerate    int64     `json:"tokens_to_generate,omitempty"`
	Temperature         float32   `json:"temperature,omitempty"`
	TopP                float32   `json:"top_p,omitempty"`
	UseStandardSSE      bool      `json:"use_standard_sse,omitempty"`
	BeamWidth           int       `json:"beam_width,omitempty"`
	RoleMeta            *RoleMeta `json:"role_meta"`
	ContinueLastMessage bool      `json:"continue_last_message"`
	SkipInfoMask        bool      `json:"skip_info_mask"`
}

type ChatCompletionResponse

type ChatCompletionResponse struct {
	ID                  string              `json:"id"`
	Created             int64               `json:"created"`
	Model               string              `json:"model"`
	Reply               string              `json:"reply"`
	Choices             []ChatMessageChoice `json:"choices"`
	Usage               Usage               `json:"usage"`
	InputSensitive      bool                `json:"input_sensitive,omitempty"`
	InputSensitiveType  int64               `json:"input_sensitive_type,omitempty"`
	OutputSensitive     bool                `json:"output_sensitive,omitempty"`
	OutputSensitiveType int64               `json:"output_sensitive_type"`
	BaseResp            BaseResp            `json:"base_resp,omitempty"`
}

type ChatCompletionStream

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

func (ChatCompletionStream) Close

func (stream ChatCompletionStream) Close()

func (ChatCompletionStream) Recv

func (stream ChatCompletionStream) Recv() (T, error)

type ChatMessageChoice

type ChatMessageChoice struct {
	Text         string `json:"text"`
	Index        int64  `json:"index"`
	FinishReason string `json:"finish_reason,omitempty"`
	Delta        string `json:"delta"`
}

type ChatMessageProChoice

type ChatMessageProChoice struct {
	FinishReason string       `json:"finish_reason,omitempty"`
	Index        int64        `json:"index"`
	Messages     []ProMessage `json:"messages"`
}

type Client

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

func NewClient

func NewClient(apiToken, groupID string) *Client

func NewClientWithConfig

func NewClientWithConfig(config *Config) *Client

func (*Client) CreateAssistantFiles

func (c *Client) CreateAssistantFiles(ctx context.Context, request *AssistantFilesCreateRequest) (*AssistantFilesCreateResponse, error)

func (*Client) CreateAssistants

func (c *Client) CreateAssistants(ctx context.Context, request *AssistantCreateRequest) (*Assistant, error)

func (*Client) CreateCompletion

func (c *Client) CreateCompletion(ctx context.Context, request *ChatCompletionRequest) (*ChatCompletionResponse, error)

func (*Client) CreateCompletionPro

func (c *Client) CreateCompletionPro(ctx context.Context, request *ChatCompletionProRequest, opts ...CompletionProOption) (*ChatCompletionProResponse, error)

func (*Client) CreateCompletionProStream

func (c *Client) CreateCompletionProStream(ctx context.Context, request *ChatCompletionProRequest, opts ...CompletionProOption) (*ChatCompletionProStream, error)

func (*Client) CreateCompletionStream

func (c *Client) CreateCompletionStream(ctx context.Context, request *ChatCompletionRequest) (*ChatCompletionStream, error)

func (*Client) CreateEmbeddings

func (c *Client) CreateEmbeddings(ctx context.Context, request *CreateEmbeddingsRequest) (*CreateEmbeddingsResponse, error)

func (*Client) CreateMessages

func (c *Client) CreateMessages(ctx context.Context, request *MessageCreateRequest) (*MessageResponse, error)

func (*Client) CreateRun

func (c *Client) CreateRun(ctx context.Context, request *RunCreateRequest) (*RunResponse, error)

func (*Client) CreateTextToSpeech

func (c *Client) CreateTextToSpeech(ctx context.Context, request *CreateT2ARequest) (*CreateT2AResponse, error)

func (*Client) CreateTextToSpeechPro

func (c *Client) CreateTextToSpeechPro(ctx context.Context, request *CreateT2ARequest) (*CreateT2AResponse, error)

func (*Client) CreateThreads

func (c *Client) CreateThreads(ctx context.Context, meta map[string]string) (*Thread, error)

func (*Client) DeleteAssistants

func (c *Client) DeleteAssistants(ctx context.Context, assistantId string) (*AssistantDeleteResponse, error)

func (*Client) DeleteFile

func (c *Client) DeleteFile(ctx context.Context, request *DeleteFileRequest) (*DeleteFileResponse, error)

func (*Client) ListAssistantFiles

func (c *Client) ListAssistantFiles(ctx context.Context, opt *AssistantListOption) (*AssistantFileListResponse, error)

func (*Client) ListAssistants

func (c *Client) ListAssistants(ctx context.Context, opt *AssistantListOption) (*AssistantListResponse, error)

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, purpose PurposeType) (*ListFileResponse, error)

func (*Client) ListMessages

func (c *Client) ListMessages(ctx context.Context, request *ListMessageOption) (*ListMessagesResponse, error)

func (*Client) ListRun

func (c *Client) ListRun(ctx context.Context, request *ListRunOption) (*ListRunResponse, error)

func (*Client) ListRunStep

func (c *Client) ListRunStep(ctx context.Context, opt *RunStepOption) (*RunStepListResponse, error)

func (*Client) RetrieveAssistantFiles

func (c *Client) RetrieveAssistantFiles(ctx context.Context, opt *AssistantListOption) (*AssistantFilesCreateResponse, error)

func (*Client) RetrieveAssistants

func (c *Client) RetrieveAssistants(ctx context.Context, assistantId string) (*AssistantRetrieveResponse, error)

func (*Client) RetrieveFile

func (c *Client) RetrieveFile(ctx context.Context, fileId int64) (*RetrieveFileResponse, error)

func (*Client) RetrieveMessages

func (c *Client) RetrieveMessages(ctx context.Context, request *MessageRetrieveRequest) (*MessageResponse, error)

func (*Client) RetrieveRun

func (c *Client) RetrieveRun(ctx context.Context, request *RunRetrieveRequest) (*RunResponse, error)

func (*Client) RetrieveRunStep

func (c *Client) RetrieveRunStep(ctx context.Context, request *RunStepRetrieveRequest) (*RunStepResponse, error)

func (*Client) RetrieveThreads

func (c *Client) RetrieveThreads(ctx context.Context, threadId string) (*Thread, error)

func (*Client) SumbmitToolOutputsRun

func (c *Client) SumbmitToolOutputsRun(ctx context.Context, request *SubmitRequest) (*RunResponse, error)

func (*Client) UploadFile added in v1.0.1

func (c *Client) UploadFile(ctx context.Context, request *FileRequest) (*FileResponse, error)

type CodeInterpreter

type CodeInterpreter struct {
	ID              string `json:"id"`
	Typ             string `json:"type"`
	CodeInterpreter struct {
		Input   string `json:"input"`
		Outputs any    `json:"outputs"`
	} `json:"code_interpreter"`
}

type CompletionProOption

type CompletionProOption func(*ChatCompletionProRequest)

func WithBotSetting

func WithBotSetting(rolePrompt string, settings ...[]BotSetting) CompletionProOption

func WithReplyConstraints

func WithReplyConstraints(v ReplyConstraints) CompletionProOption

type Config

type Config struct {
	BaseURL           string
	HTTPClient        *http.Client
	EmptyMessageLimit uint
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig(apiToken, groupID string) *Config

type Content

type Content struct {
	Typ       string       `json:"type"`
	Text      *TextContent `json:"text"`
	ImageFile *ImageFile   `json:"image_file"`
}

type CreateEmbeddingsRequest

type CreateEmbeddingsRequest struct {
	Model string `json:"model"`

	Texts []string `json:"texts"`
	Type  string   `json:"type"`
}

type CreateEmbeddingsResponse

type CreateEmbeddingsResponse struct {
	Vectors  [][]float32 `json:"vectors"`
	BaseResp BaseResp    `json:"base_resp"`
}

type CreateT2ARequest

type CreateT2ARequest struct {
	Model           string         `json:"model"`
	Text            string         `json:"text"`
	TimberWeights   []TimberWeight `json:"timber_weights,omitempty"`
	VoiceID         string         `json:"voice_id,omitempty"`
	Speed           float32        `json:"speed,omitempty"`
	Vol             float32        `json:"vol,omitempty"`
	Pitch           int            `json:"pitch,omitempty"`
	AudioSampleRate int            `json:"audio_sample_rate,omitempty"`
	Bitrate         int            `json:"bitrate,omitempty"`

	Path string `json:"-"`
	Name string `json:"-"`
}

type CreateT2AResponse

type CreateT2AResponse struct {
	TraceId      string    `json:"trace_id,omitempty"`
	BaseResp     BaseResp  `json:"base_resp,omitempty"`
	AudioFile    string    `json:"audio_file,omitempty"`
	SubtitleFile string    `json:"subtitle_file,omitempty"`
	ExtraInfo    ExtraInfo `json:"extra_info,omitempty"`
}

type DeleteFileRequest

type DeleteFileRequest struct {
	FileId int64 `json:"file_id"`
}

type DeleteFileResponse

type DeleteFileResponse struct {
	FileId   int64     `json:"file_id"`
	BaseResp *BaseResp `json:"base_resp"`
}

type ExtraInfo

type ExtraInfo struct {
	AudioLength     int64 `json:"audio_length,omitempty"`
	AudioSampleRate int64 `json:"audio_sample_rate,omitempty"`
	AudioSize       int64 `json:"audio_size,omitempty"`
	Bitrate         int64 `json:"bitrate,omitempty"`
	WordCount       int64 `json:"word_count,omitempty"`
}

type File

type File struct {
	FileId    int64  `json:"file_id"`
	Bytes     int64  `json:"bytes"`
	CreatedAt int64  `json:"created_at"`
	FileName  string `json:"filename"`
	Purpose   string `json:"purpose"`
}

type FileCitation

type FileCitation struct {
	FileId string `json:"file_id"`
	Quote  string `json:"quote"`
}

type FileRequest

type FileRequest struct {
	Purpose  PurposeType `json:"purpose"`
	FilePath string      `json:"-"`
}

type FileResponse

type FileResponse struct {
	File     *File     `json:"file"`
	BaseResp *BaseResp `json:"base_resp"`
}

type Function

type Function struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Parameters  Parameters `json:"parameters"`
}

type FunctionCall

type FunctionCall struct {
	Type      string `json:"type,omitempty"`
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

type Glyph

type Glyph struct {
	Type           string `json:"type"`
	RawGlyph       string `json:"raw_glyph"`
	JsonProperties any    `json:"json_properties,omitempty"`
}

type ImageFile

type ImageFile struct {
	FileId string `json:"file_id"`
}

type ListFileResponse

type ListFileResponse struct {
	Files    []*File   `json:"files"`
	BaseResp *BaseResp `json:"base_resp"`
}

type ListMessageOption

type ListMessageOption struct {
	ThreadId string `json:"thread_id"`
	Limit    int64  `json:"limit,omitempty"`
	Order    string `json:"order,omitempty"`
	After    string `json:"after,omitempty"`
	Before   string `json:"before,omitempty"`
}

type ListMessagesResponse

type ListMessagesResponse struct {
	Object   string         `json:"object"`
	Data     []*AsstMessage `json:"data"`
	FirstId  string         `json:"first_id"`
	LastId   string         `json:"last_id"`
	BaseResp *BaseResp      `json:"base_resp"`
}

type ListRunOption

type ListRunOption struct {
	ThreadId string `json:"thread_id"`
	Limit    int64  `json:"limit,omitempty"`
	Order    string `json:"order,omitempty"`
	After    string `json:"after,omitempty"`
	Before   string `json:"before,omitempty"`
}

type ListRunResponse

type ListRunResponse struct {
	*RunResponse
	BaseResp *BaseResp `json:"base_resp"`
}

type Message

type Message struct {
	SenderType string `json:"sender_type"`
	Text       string `json:"text"`
}

type MessageCreateRequest

type MessageCreateRequest struct {
	ThreadId string            `json:"thread_id"`
	Role     string            `json:"role"`
	Content  string            `json:"content"`
	FileIds  []string          `json:"file_ids,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type MessageCreation

type MessageCreation struct {
	MessageId string `json:"message_id"`
}

type MessageResponse

type MessageResponse struct {
	*AsstMessage
	BaseResp *BaseResp `json:"base_resp"`
}

type MessageRetrieveRequest

type MessageRetrieveRequest struct {
	MessageId string `json:"message_id"`
	ThreadId  string `json:"thread_id"`
}

type Parameters

type Parameters struct {
	Type       string   `json:"type"`
	Required   []string `json:"required"`
	Properties any      `json:"properties"`
}

type ProMessage

type ProMessage struct {
	SenderType string `json:"sender_type"`
	SenderName string `json:"sender_name"`
	Text       string `json:"text"`
}

type PurposeType

type PurposeType string
var (
	Retrieval       PurposeType = "retrieval"
	FineTune        PurposeType = "fine-tune"
	FineTuneResult  PurposeType = "fine-tune-result"
	VoiceClone      PurposeType = "voice_clone"
	Assistants      PurposeType = "assistants"
	RoleRecognition PurposeType = "role-recognition"
)

type ReplyConstraints

type ReplyConstraints struct {
	SenderType string `json:"sender_type"`
	SenderName string `json:"sender_name"`
	Glyph      *Glyph `json:"glyph,omitempty"`
}

type RequiredAction

type RequiredAction struct {
	Typ               string      `json:"type"`
	SubmitToolOutputs *ToolOutput `json:"submit_tool_outputs"`
}

type RetrieveFileResponse

type RetrieveFileResponse struct {
	File     *File     `json:"file"`
	BaseResp *BaseResp `json:"base_resp"`
}

type RoleMeta

type RoleMeta struct {
	UserName string `json:"user_name"`
	BotName  string `json:"bot_name"`
}

type Run

type Run struct {
	ID             string            `json:"id"`
	Object         string            `json:"object"`
	CreatedAt      int64             `json:"created_at"`
	AssistantId    string            `json:"assistant_id"`
	ThreadId       string            `json:"thread_id"`
	Status         string            `json:"status"`
	StartedAt      int64             `json:"started_at"`
	ExpiresAt      int64             `json:"expires_at"`
	CancelledAt    int64             `json:"cancelled_at"`
	FailedAt       int64             `json:"failed_at"`
	CompletedAt    int64             `json:"completed_at"`
	LastError      *RunError         `json:"last_error"`
	Model          string            `json:"model"`
	Instructions   string            `json:"instructions"`
	Tools          []*RunTool        `json:"tools"`
	FileIds        []string          `json:"file_ids"`
	RequiredAction any               `json:"required_action"`
	Metadata       map[string]string `json:"metadata"`
}

type RunCreateRequest

type RunCreateRequest struct {
	ThreadId     string            `json:"thread_id"`
	AssistantId  string            `json:"assistant_id"`
	Model        string            `json:"model,omitempty"`
	Instructions string            `json:"instructions,omitempty"`
	Tools        []*RunTool        `json:"tools,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

type RunError

type RunError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type RunFunction

type RunFunction struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Parameters  any    `json:"parameters"`
}

type RunResponse

type RunResponse struct {
	*Run
	BaseResp *BaseResp `json:"base_resp"`
}

type RunRetrieveRequest

type RunRetrieveRequest struct {
	ThreadId string `json:"thread_id"`
	RunId    string `json:"run_id"`
}

type RunStep

type RunStep struct {
	ID          string            `json:"id"`
	Object      string            `json:"object"`
	CreatedAt   int64             `json:"created_at"`
	AssistantId string            `json:"assistant_id"`
	ThreadId    string            `json:"thread_id"`
	Typ         string            `json:"type"`
	Status      string            `json:"status"`
	StartedAt   int64             `json:"started_at"`
	ExpiresAt   int64             `json:"expires_at"`
	CancelledAt int64             `json:"cancelled_at"`
	FailedAt    int64             `json:"failed_at"`
	CompletedAt int64             `json:"completed_at"`
	LastError   map[string]string `json:"last_error"`
	StepDetails *StepDetails      `json:"step_details"`
}

type RunStepListResponse

type RunStepListResponse struct {
	Object   string             `json:"object"`
	Data     []*RunStepResponse `json:"data"`
	BaseResp *BaseResp          `json:"base_resp"`
}

type RunStepOption

type RunStepOption struct {
	ThreadId string `json:"thread_id"`
	RunId    string `json:"run_id"`
	Limit    int64  `json:"limit,omitempty"`
	Order    string `json:"order,omitempty"`
	After    string `json:"after,omitempty"`
	Before   string `json:"before,omitempty"`
}

type RunStepResponse

type RunStepResponse struct {
	*RunStep
	BaseResp *BaseResp `json:"base_resp"`
}

type RunStepRetrieveRequest

type RunStepRetrieveRequest struct {
	ThreadId string `json:"thread_id"`
	RunId    string `json:"run_id"`
	StepId   string `json:"step_id"`
}

type RunTool

type RunTool struct {
	Typ      string       `json:"type"`
	Function *RunFunction `json:"function"`
}

type StepDetails

type StepDetails struct {
	Typ             string           `json:"type"`
	MessageCreation *MessageCreation `json:"message_creation"`
	ToolCalls       []*ToolCall      `json:"tool_calls"`
}

type SubmitRequest

type SubmitRequest struct {
	ThreadId   string     `json:"thread_id"`
	RunId      string     `json:"run_id"`
	ToolOutput []*RunTool `json:"tool_output"`
}

type TextContent

type TextContent struct {
	Value       string        `json:"value"`
	Annotations []*Annotation `json:"annotations"`
}

type Thread

type Thread struct {
	ID        string         `json:"id"`
	Object    string         `json:"object"`
	CreatedAt int64          `json:"created_at"`
	MetaData  map[string]any `json:"metadata,omitempty"`
	BaseResp  *BaseResp      `json:"base_resp"`
}

type TimberWeight

type TimberWeight struct {
	VoiceID string `json:"voice_id"`
	Weight  int    `json:"weight"`
}

type Tool

type Tool struct {
	Typ      string `json:"type,omitempty"`
	Function string `json:"function,omitempty"`
}

type ToolCall

type ToolCall struct {
	Typ             string           `json:"type"`
	CodeInterpreter *CodeInterpreter `json:"code_interpreter"`
	WebSearch       *WebSearch       `json:"web_search"`
	Retrieval       *CallRetrieval   `json:"retrieval"`
	Function        *CallFunction    `json:"function"`
}

type ToolOutput

type ToolOutput struct {
	ToolCallId string `json:"tool_call_id"`
	Output     string `json:"output"`
}

type Usage

type Usage struct {
	TotalTokens           int64 `json:"total_tokens"`
	TokensWithAddedPlugin int64 `json:"tokens_with_added_plugin"`
}

type WebCitation

type WebCitation struct {
	Url   string `json:"url"`
	Quote string `json:"quote"`
}

type WebSearch

type WebSearch struct {
	ID        string `json:"id"`
	Typ       string `json:"type"`
	WebSearch struct {
		Query   string `json:"query"`
		Outputs string `json:"outputs"`
	} `json:"web_search"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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