client

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 9 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 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 string
}

func AssistantMessage

func AssistantMessage(content string) *Message

func SystemMessage

func SystemMessage(content string) *Message

func UserMessage

func UserMessage(content 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