openaimodel

package
v0.0.0-...-435fad9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

openaimodel defines the data structures used for OpenAI interactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model            string    `json:"model"`
	Messages         []Message `json:"messages"`
	Temperature      float64   `json:"temperature"`
	TopP             float64   `json:"top_p"`
	FrequencyPenalty float64   `json:"frequency_penalty"`
	PresencePenalty  float64   `json:"presence_penalty"`
	MaxTokens        int       `json:"max_tokens"`
	N                int       `json:"n"`
}

type ChatCompletionResponse

type ChatCompletionResponse struct {
	Choices []struct {
		Message struct {
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
}

type Message

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

type OpenAITransaction

type OpenAITransaction struct {
	ID            uuid.UUID `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()"`
	UserID        uuid.UUID `gorm:"type:uuid"`
	ThreadID      uuid.UUID `gorm:"type:uuid;index"`
	MessageID     uuid.UUID `gorm:"type:uuid"`
	Model         string    `gorm:"type:varchar(255)"`
	Role          string    `gorm:"type:varchar(50);not null"`
	MessageLength int       `gorm:"type:int"` // Tracks the length of the user's message
	ProcessTime   time.Time `gorm:"default:now()"`
}

OpenAITransaction represents a record of an interaction with the OpenAI API.

func (OpenAITransaction) TableName

func (OpenAITransaction) TableName() string

TableName overrides the table name used by OpenAITransaction.

type OpenAITransactionInput

type OpenAITransactionInput struct {
	ThreadID string `json:"threadID"`
	Message  string `json:"message"`
	Model    string `json:"model"`
	Role     string `json:"role"`
}

OpenAITransactionInput represents the input data for creating a new OpenAI transaction.

Jump to

Keyboard shortcuts

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