api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatPromptBuilder

type ChatPromptBuilder interface {
	/*
		CreatePrompt build a complete prompt using the existing session exchanges, and the new
		request from the user.

			@param ctxt context.Context - query context
			@param session persistence.ChatSession - current chat session
			@param newRequest string - new user request
			@return complete prompt for the text completion model
	*/
	CreatePrompt(
		ctxt context.Context, session persistence.ChatSession, newRequest string,
	) (string, error)
}

ChatPromptBuilder construct a text completion prompt to send

func GetSimpleChatPromptBuilder

func GetSimpleChatPromptBuilder() (ChatPromptBuilder, error)

GetSimpleChatPromptBuilder define a simple chat prompt builder

type ChatSessionHandler

type ChatSessionHandler interface {
	/*
		SendRequest send a new request within the session

			@param ctxt context.Context - query context
			@param prompt string - the prompt to send
			@param resp chan string - channel for sending out the responses from the model
	*/
	SendRequest(ctxt context.Context, prompt string, resp chan string) error

	/*
		Close close this session

			@param ctxt context.Context - query context
	*/
	Close(ctxt context.Context) error
}

ChatSessionHandler represents a chat session

func DefineChatSessionHandler

func DefineChatSessionHandler(
	ctxt context.Context,
	session persistence.ChatSession,
	client Client,
) (ChatSessionHandler, error)

DefineChatSessionHandler create chat session tracker

@param ctxt context.Context - query context
@param session persistence.ChatSession - chat session parameters
@param client GPTClient - OpenAI GPT model API client
@return new chat session tracker

type Client

type Client interface {
	/*
		MakeCompletionRequest make a completion request to the model

			@param ctxt context.Context - query context
			@param session persistence.ChatSession - chat session parameters
			@param prompt string - the prompt to send
			@param resp chan string - channel for sending out the responses from the model
	*/
	MakeCompletionRequest(
		ctxt context.Context, session persistence.ChatSession, prompt string, resp chan string,
	) error
}

Client OpenAI model API client

func GetClient

func GetClient(
	ctxt context.Context, user persistence.User, promptBuilder ChatPromptBuilder,
) (Client, error)

GetClient define new OpenA model API client

@param ctxt context.Context - query context
@param user persistence.User - the user parameter
@param promptBuilder ChatPromptBuilder - tool to construct a complete prompt for models
    whose input do not have a way to define user request and system response
@return client

Jump to

Keyboard shortcuts

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