core

package
v0.0.0-...-335761d Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Map

func Map[T, U any](data []T, f func(T) U) []U

Types

type AccessTokenData

type AccessTokenData struct {
	Token string `json:"token"`
}

type AuthService

type AuthService interface {
	GenerateAuthToken(user User, expiry int64) (string, error)
	VerifyAuthToken(token string) (User, error)
}

type ChatGptService

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

func GetNewService

func GetNewService(dbService DbService, authService AuthService, llmService LLMService) *ChatGptService

func (*ChatGptService) CreateNewConversation

func (srv *ChatGptService) CreateNewConversation(userId int, conversationName string) ([]Conversation, error)

func (*ChatGptService) GenerateAccessToken

func (srv *ChatGptService) GenerateAccessToken(token string) (AccessTokenData, error)

func (*ChatGptService) GetConversationsForUser

func (c *ChatGptService) GetConversationsForUser(userId int) ([]Conversation, error)

Generate GetConversationsForUser function. It is a function over ChatGptStruct It takes userid as the parameter and fetches conversation using GetConversationByUser function of dbService present in struct

func (*ChatGptService) GetQueriesForConversation

func (srv *ChatGptService) GetQueriesForConversation(conversationId int) ([]Query, error)

func (*ChatGptService) GetTemplates

func (s *ChatGptService) GetTemplates(userId int) ([]Template, error)

func (*ChatGptService) GetUserDetails

func (s *ChatGptService) GetUserDetails(userId int) (User, error)

func (*ChatGptService) QueryLLM

func (srv *ChatGptService) QueryLLM(query string, conversationId int, isContext bool) ([]Query, error)

func (*ChatGptService) StoreTemplate

func (s *ChatGptService) StoreTemplate(userId int, templateName string, parts []string, params []string) ([]Template, error)

func (*ChatGptService) VerifyAccessToken

func (s *ChatGptService) VerifyAccessToken(token string) (User, error)

type ChatRequest

type ChatRequest struct {
	Query string `json:"query"`
}

define the request

type ChatResponse

type ChatResponse struct {
	Response string `json:"response"`
}

define the response structure

type Conversation

type Conversation struct {
	ID        uint   `json:"id"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
}

type DbService

type DbService interface {
	GetOrCreateUser(email string, name string) (User, error)
	GetUserById(userId int) (User, error)
	GetConversationByUser(userId int) ([]Conversation, error)
	GetQueriesByConversation(conversationId int) ([]Query, error)
	CreateNewConversation(userId int, conversationName string) error
	StoreQueryForConversation(conversationID int, query string, response []byte, context int) error
	GetContextForQuery(conversationId int, maxContext int) ([]Query, error)
	GetTemplatesByUserId(userId int) ([]Template, error)
	StoreTemplate(templateName string, userId int, parts []string, params []string) error
}

type GoogleUserInfo

type GoogleUserInfo struct {
	Email   string `json:"email"`
	Name    string `json:"name"`
	Picture string `json:"picture"`
	HD      string `json:"hd"`
}

type InvalidAuthToken

type InvalidAuthToken struct {
	Issue string
}

func (InvalidAuthToken) Error

func (i InvalidAuthToken) Error() string

type LLMPrompt

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

type LLMResponse

type LLMResponse struct {
	Response  []LLMPrompt `json:"response"`
	Id        string      `json:"id"`
	CreatedAt string      `json:"created_at"`
	Model     string      `json:"model"`
	Usage     string      `json:"usage"`
}

type LLMService

type LLMService interface {
	Query(prompt []LLMPrompt) ([]byte, error)
	ResponseToLLMPrompt(response []byte) (LLMPrompt, error)
}

type Query

type Query struct {
	ID             uint   `json:"id"`
	ConversationId uint   `json:"conversation_id"`
	Query          string `json:"query"`
	Response       string `json:"response"`
	IsContext      string `json:"is_context"`
	CreatedAt      string `json:"created_at"`
}

type Service

type Service interface {
	QueryLLM(query string, conversationId int, isContext bool) ([]Query, error)
	GenerateAccessToken(token string) (AccessTokenData, error)
	VerifyAccessToken(token string) (User, error)
	GetUserDetails(userId int) (User, error)
	GetConversationsForUser(userId int) ([]Conversation, error)
	GetQueriesForConversation(conversationId int) ([]Query, error)
	CreateNewConversation(userId int, conversationName string) ([]Conversation, error)
	GetTemplates(userId int) ([]Template, error)
	StoreTemplate(userId int, templateName string, parts []string, params []string) ([]Template, error)
}

type Template

type Template struct {
	ID     uint     `json:"id"`
	Name   string   `json:"name"`
	Parts  []string `json:"parts"`
	Params []string `json:"params"`
}

type UnauthorizedError

type UnauthorizedError struct {
}

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

type User

type User struct {
	ID      uint   `json:"id"`
	Email   string `json:"email"`
	Name    string `json:"name"`
	Picture string `json:"picture"`
}

Jump to

Keyboard shortcuts

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