gpt

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatChoice added in v0.12.0

type ChatChoice struct {
	Index        int         `json:"index"`
	Message      ChatMessage `json:"message"`
	LogProbs     bool        `json:"log_probs"`
	FinishReason string      `json:"finish_reason"`
}

type ChatMessage added in v0.12.0

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

type ChatMessages added in v0.12.0

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

type ChatPrompt added in v0.12.0

type ChatPrompt struct {
	Messages []ChatMessages `json:"messages"`
}

type ChatPromptTokensDetails added in v0.12.0

type ChatPromptTokensDetails struct {
	CachedTokens int `json:"cached_tokens"`
}

type ChatResponse added in v0.12.0

type ChatResponse struct {
	Id      string       `json:"id"`
	Object  string       `json:"object"`
	Created int64        `json:"created"`
	Model   string       `json:"model"`
	Choices []ChatChoice `json:"choices"`
	Usage   ChatUsage    `json:"usage"`
}

type ChatUsage added in v0.12.0

type ChatUsage struct {
	PromptTokens        int                     `json:"prompt_tokens"`
	CompletionTokens    int                     `json:"completion_tokens"`
	TotalTokens         int                     `json:"total_tokens"`
	PromptTokensDetails ChatPromptTokensDetails `json:"prompt_tokens_details"`
}

type Config

type Config struct {
	Provider string
	Api      string
	Model    string
	Key      string
}

func DefaultConfig

func DefaultConfig() *Config

type DoubaoChat added in v0.12.0

type DoubaoChat struct {
	Api   string
	Model string
	Key   string
}

func (*DoubaoChat) Deinit added in v0.12.0

func (c *DoubaoChat) Deinit(_ context.Context) error

func (*DoubaoChat) Init added in v0.12.0

func (c *DoubaoChat) Init(_ context.Context) error

func (*DoubaoChat) Run added in v0.12.0

func (c *DoubaoChat) Run(_ context.Context, content string) ([]string, error)

type DoubaoVision added in v0.12.0

type DoubaoVision struct {
	Api   string
	Model string
	Key   string
}

func (*DoubaoVision) Deinit added in v0.12.0

func (v *DoubaoVision) Deinit(_ context.Context) error

func (*DoubaoVision) Init added in v0.12.0

func (v *DoubaoVision) Init(_ context.Context) error

func (*DoubaoVision) Run added in v0.12.0

func (v *DoubaoVision) Run(_ context.Context, content string) ([]string, error)

type Gpt

type Gpt interface {
	Init(context.Context) error
	Deinit(context.Context) error
	Run(context.Context, string) ([]string, error)
}

func New

func New(_ context.Context, cfg *Config) Gpt

type VisionChoice added in v0.12.0

type VisionChoice struct {
	Index        int           `json:"index"`
	Message      VisionMessage `json:"message"`
	LogProbs     bool          `json:"log_probs"`
	FinishReason string        `json:"finish_reason"`
}

type VisionContent added in v0.12.0

type VisionContent struct {
	Type     string         `json:"type"`
	Text     string         `json:"text"`
	ImageUrl VisionImageUrl `json:"image_url"`
}

type VisionImageUrl added in v0.12.0

type VisionImageUrl struct {
	Url string `json:"url"`
}

type VisionMessage added in v0.12.0

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

type VisionMessages added in v0.12.0

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

type VisionPrompt added in v0.12.0

type VisionPrompt struct {
	Messages []VisionMessages `json:"messages"`
}

type VisionResponse added in v0.12.0

type VisionResponse struct {
	Id      string         `json:"id"`
	Object  string         `json:"object"`
	Created int64          `json:"created"`
	Model   string         `json:"model"`
	Choices []VisionChoice `json:"choices"`
	Usage   VisionUsage    `json:"usage"`
}

type VisionUsage added in v0.12.0

type VisionUsage 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