openaitransport

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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalChat

type LocalChat struct {
	Model    string         `json:"model"`
	Messages []LocalMessage `json:"messages"`
	Stream   bool           `json:"stream"`
	Format   string         `json:"format"`
}

type LocalMessage

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

type LocalOptions

type LocalOptions struct {
	NumPredict int `json:"num_predict"`
}

type LocalRequest

type LocalRequest struct {
	Model   string       `json:"model"`
	Prompt  string       `json:"prompt"`
	System  string       `json:"system"`
	Stream  bool         `json:"stream"`
	Options LocalOptions `json:"options"`
}

type LocalResponse

type LocalResponse struct {
	Model     string `json:"model"`
	CreatedAt string `json:"created_at"`
	Response  string `json:"response"`
	Done      bool   `json:"done"`
}

type MessageInput

type MessageInput struct {
	Messages []LocalMessage `json:"messages"`
	Model    string         `json:"model"`
}

type OpenAIHandler

type OpenAIHandler struct {
	ThreadSSEChannels map[uuid.UUID]chan string
	Mutex             *sync.RWMutex

	// CancelFuncs stores the cancel functions for each thread ID
	CancelFuncs    map[uuid.UUID]context.CancelFunc
	CancelFuncsLLM map[uuid.UUID]context.CancelFunc
	// contains filtered or unexported fields
}

func NewOpenAIHandler

func NewOpenAIHandler(openAIService *openaibusiness.OpenAIService) *OpenAIHandler

NewOpenAIHandler creates a new instance of OpenAIHandler.

func (*OpenAIHandler) CreateTransaction

func (h *OpenAIHandler) CreateTransaction(c *gin.Context)

CreateTransaction handles the creation of a new OpenAI transaction (HTTP Handler).

func (*OpenAIHandler) DeleteTransaction

func (h *OpenAIHandler) DeleteTransaction(c *gin.Context)

DeleteTransaction handles the deletion of an OpenAI transaction.

func (*OpenAIHandler) FetchDrawing

func (h *OpenAIHandler) FetchDrawing(c *gin.Context)

FetchSuggestion handles the request to fetch suggestions from OpenAI.

func (*OpenAIHandler) FetchSuggestion

func (h *OpenAIHandler) FetchSuggestion(c *gin.Context)

FetchSuggestion handles the request to fetch suggestions from OpenAI.

func (*OpenAIHandler) GenerateHint

func (h *OpenAIHandler) GenerateHint(c *gin.Context)

FetchSuggestion handles the request to fetch suggestions from OpenAI.

func (*OpenAIHandler) GetTransactionByID

func (h *OpenAIHandler) GetTransactionByID(c *gin.Context)

GetTransactionByID handles fetching a specific transaction by its ID.

func (*OpenAIHandler) GetTransactionsByUserID

func (h *OpenAIHandler) GetTransactionsByUserID(c *gin.Context)

GetTransactionsByUserID handles fetching transactions for a specific user.

func (*OpenAIHandler) MessageHanlder

func (h *OpenAIHandler) MessageHanlder(c *gin.Context)

MessageHandler handles the incoming messages.

func (*OpenAIHandler) SSEHandler

func (h *OpenAIHandler) SSEHandler(c *gin.Context)

func (*OpenAIHandler) StopGeneration

func (h *OpenAIHandler) StopGeneration(threadID uuid.UUID) error

func (*OpenAIHandler) UpdateTransaction

func (h *OpenAIHandler) UpdateTransaction(c *gin.Context)

UpdateTransaction handles the updating of an existing OpenAI transaction.

func (*OpenAIHandler) WebSocketHandler

func (h *OpenAIHandler) WebSocketHandler(c *gin.Context)

WebSocketHandler is the Gin handler for WebSocket connections

type Options

type Options struct {
	Temperature float64
	NumPredict  int
	NumCtx      int
}

type Response

type Response struct {
	Model     string       `json:"model"`
	CreatedAt string       `json:"created_at"`
	Message   LocalMessage `json:"message"`
	Done      bool         `json:"done"`
}

Jump to

Keyboard shortcuts

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