openai

package
v0.14.0-beta Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(logger *zap.Logger) base.IConnector

Types

type AudioTranscriptionInput

type AudioTranscriptionInput struct {
	Audio       string   `json:"audio"`
	Model       string   `json:"model"`
	Prompt      *string  `json:"prompt,omitempty"`
	Temperature *float64 `json:"temperature,omitempty"`
	Language    *string  `json:"language,omitempty"`
}

type AudioTranscriptionReq

type AudioTranscriptionReq struct {
	File        []byte   `json:"file"`
	Model       string   `json:"model"`
	Prompt      *string  `json:"prompt,omitempty"`
	Language    *string  `json:"language,omitempty"`
	Temperature *float64 `json:"temperature,omitempty"`
}

type AudioTranscriptionResp

type AudioTranscriptionResp struct {
	Text string `json:"text"`
}

type Choices

type Choices struct {
	Index        int           `json:"index"`
	FinishReason string        `json:"finish_reason"`
	Message      OutputMessage `json:"message"`
}

type Connector

type Connector struct {
	base.Connector
}

func (*Connector) CreateExecution

func (c *Connector) CreateExecution(defUID uuid.UUID, task string, config *structpb.Struct, logger *zap.Logger) (base.IExecution, error)

func (*Connector) Test

func (c *Connector) Test(_ uuid.UUID, config *structpb.Struct, logger *zap.Logger) (pipelinePB.Connector_State, error)

Test checks the connector state.

type Content

type Content struct {
	Type     string    `json:"type"`
	Text     *string   `json:"text,omitempty"`
	ImageURL *ImageURL `json:"image_url,omitempty"`
}

type Data

type Data struct {
	Object    string    `json:"object"`
	Embedding []float64 `json:"embedding"`
	Index     int       `json:"index"`
}

type Execution

type Execution struct {
	base.Execution
}

func (*Execution) Execute

func (e *Execution) Execute(inputs []*structpb.Struct) ([]*structpb.Struct, error)

type ImageGenerationsOutput

type ImageGenerationsOutput struct {
	Results []ImageGenerationsOutputResult `json:"results"`
}

type ImageGenerationsOutputResult

type ImageGenerationsOutputResult struct {
	Image         string `json:"image"`
	RevisedPrompt string `json:"revised_prompt"`
}

type ImageGenerationsReq

type ImageGenerationsReq struct {
	Prompt         string  `json:"prompt"`
	Model          string  `json:"model"`
	N              *int    `json:"n,omitempty"`
	Quality        *string `json:"quality,omitempty"`
	Size           *string `json:"size,omitempty"`
	Style          *string `json:"style,omitempty"`
	ResponseFormat string  `json:"response_format"`
}

type ImageGenerationsResp

type ImageGenerationsResp struct {
	Data []ImageGenerationsRespData `json:"data"`
}

type ImageGenerationsRespData

type ImageGenerationsRespData struct {
	Image         string `json:"b64_json"`
	RevisedPrompt string `json:"revised_prompt"`
}

type ImageURL

type ImageURL struct {
	URL string `json:"url"`
}

type ImagesGenerationInput

type ImagesGenerationInput struct {
	Prompt  string  `json:"prompt"`
	Model   string  `json:"model"`
	N       *int    `json:"n,omitempty"`
	Quality *string `json:"quality,omitempty"`
	Size    *string `json:"size,omitempty"`
	Style   *string `json:"style,omitempty"`
}

type ListModelsResponse

type ListModelsResponse struct {
	Object string  `json:"object"`
	Data   []Model `json:"data"`
}

type Message

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

type Model

type Model struct {
	ID         string            `json:"id"`
	Object     string            `json:"object"`
	Created    int               `json:"created"`
	OwnedBy    string            `json:"owned_by"`
	Permission []ModelPermission `json:"permission"`
	Root       string            `json:"root"`
}

Model represents a OpenAI Model

type ModelPermission

type ModelPermission struct {
	ID                 string `json:"id"`
	Object             string `json:"object"`
	Created            int    `json:"created"`
	AllowCreateEngine  bool   `json:"allow_create_engine"`
	AllowSampling      bool   `json:"allow_sampling"`
	AllowLogprobs      bool   `json:"allow_logprobs"`
	AllowSearchIndices bool   `json:"allow_search_indices"`
	AllowView          bool   `json:"allow_view"`
	AllowFineTuning    bool   `json:"allow_fine_tuning"`
	Organization       string `json:"organization"`
	IsBlocking         bool   `json:"is_blocking"`
}

type MultiModalMessage

type MultiModalMessage struct {
	Role    string    `json:"role"`
	Content []Content `json:"content"`
}

type OutputMessage

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

type ResponseFormatStruct

type ResponseFormatStruct struct {
	Type string `json:"type,omitempty"`
}

type TextCompletionInput

type TextCompletionInput struct {
	Prompt           string                `json:"prompt"`
	Images           []string              `json:"images"`
	ChatHistory      []*TextMessage        `json:"chat_history,omitempty"`
	Model            string                `json:"model"`
	SystemMessage    *string               `json:"system_message,omitempty"`
	Temperature      *float32              `json:"temperature,omitempty"`
	TopP             *float32              `json:"top_p,omitempty"`
	N                *int                  `json:"n,omitempty"`
	Stop             *string               `json:"stop,omitempty"`
	MaxTokens        *int                  `json:"max_tokens,omitempty"`
	PresencePenalty  *float32              `json:"presence_penalty,omitempty"`
	FrequencyPenalty *float32              `json:"frequency_penalty,omitempty"`
	ResponseFormat   *ResponseFormatStruct `json:"response_format,omitempty"`
}

type TextCompletionOutput

type TextCompletionOutput struct {
	Texts []string `json:"texts"`
}

type TextCompletionReq

type TextCompletionReq struct {
	Model            string                `json:"model"`
	Messages         []interface{}         `json:"messages"`
	Temperature      *float32              `json:"temperature,omitempty"`
	TopP             *float32              `json:"top_p,omitempty"`
	N                *int                  `json:"n,omitempty"`
	Stop             *string               `json:"stop,omitempty"`
	MaxTokens        *int                  `json:"max_tokens,omitempty"`
	PresencePenalty  *float32              `json:"presence_penalty,omitempty"`
	FrequencyPenalty *float32              `json:"frequency_penalty,omitempty"`
	ResponseFormat   *ResponseFormatStruct `json:"response_format,omitempty"`
}

type TextCompletionResp

type TextCompletionResp struct {
	ID      string    `json:"id"`
	Object  string    `json:"object"`
	Created int       `json:"created"`
	Choices []Choices `json:"choices"`
	Usage   Usage     `json:"usage"`
}

type TextEmbeddingsInput

type TextEmbeddingsInput struct {
	Text  string `json:"text"`
	Model string `json:"model"`
}

type TextEmbeddingsOutput

type TextEmbeddingsOutput struct {
	Embedding []float64 `json:"embedding"`
}

type TextEmbeddingsReq

type TextEmbeddingsReq struct {
	Model string   `json:"model"`
	Input []string `json:"input"`
}

type TextEmbeddingsResp

type TextEmbeddingsResp struct {
	Object string `json:"object"`
	Data   []Data `json:"data"`
	Model  string `json:"model"`
	Usage  Usage  `json:"usage"`
}

type TextMessage

type TextMessage struct {
	Role    string    `json:"role"`
	Content []Content `json:"content"`
}

type TextToSpeechInput

type TextToSpeechInput struct {
	Text           string   `json:"text"`
	Model          string   `json:"model"`
	Voice          string   `json:"voice"`
	ResponseFormat *string  `json:"response_format,omitempty"`
	Speed          *float64 `json:"speed,omitempty"`
}

type TextToSpeechOutput

type TextToSpeechOutput struct {
	Audio string `json:"audio"`
}

type TextToSpeechReq

type TextToSpeechReq struct {
	Input          string   `json:"input"`
	Model          string   `json:"model"`
	Voice          string   `json:"voice"`
	ResponseFormat *string  `json:"response_format,omitempty"`
	Speed          *float64 `json:"speed,omitempty"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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