client

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClients

func NewClients(cfg *config.Config, logger *zap.SugaredLogger) (map[string]ChatClient, error)

func NewOpenAIChatCompletionService

func NewOpenAIChatCompletionService(config *config.OpenAI) *openai.ChatCompletionService

Types

type ChatClient

type ChatClient interface {
	Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)
}

type ChatRequest

type ChatRequest struct {
	Messages        []*Message
	Temperature     float64
	Schema          *jsonschema.Schema
	Model           string
	MaxOutputTokens int64
	PresencePenalty float64
}

type ChatResponse

type ChatResponse struct {
	Content string `json:"content"`
	Tokens  int64  `json:"tokens"`
}

type Content added in v0.1.5

type Content struct {
	Type ContentType
	Data string
}

type ContentType added in v0.1.5

type ContentType string
const (
	ContentTypeText  ContentType = "text"
	ContentTypeImage ContentType = "image"
)

type ImageGenerateRequest

type ImageGenerateRequest struct {
	Prompt string
	Model  string
}

type ImageResponse

type ImageResponse struct {
	URL     string `json:"url"`
	Content string `json:"content"`
	Tokens  int    `json:"tokens"`
}

type Message

type Message struct {
	Role    string
	Content []Content
}

func AssistantMessage

func AssistantMessage(content string) *Message

func SystemMessage

func SystemMessage(content string) *Message

func UserMessage

func UserMessage(content string) *Message

func UserMessageWithImages added in v0.1.5

func UserMessageWithImages(content string, images map[string]string) *Message

type OpenAIClient

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

func NewOpenAIClient

func NewOpenAIClient(completionService oaiChatCompletionService, logger *zap.SugaredLogger) *OpenAIClient

func (*OpenAIClient) Chat

func (c *OpenAIClient) Chat(ctx context.Context, request *ChatRequest) (*ChatResponse, error)

Jump to

Keyboard shortcuts

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