http

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLabelSize = 100 // NOTE: chosen arbitrarily
)

Variables

This section is empty.

Functions

func FetchEmbeddings

func FetchEmbeddings(ctx context.Context, embedder any, req *v1.EmbeddingsUpdate) ([]v1.Embedding, error)

FetchEmbeddings fetches embeddings using the provided embedder. It returns the fetched embeddings or fails with error.

Types

type Option

type Option func(*Options)

Option is functional graph option.

func WithAssets

func WithAssets(a embed.FS) Option

WithAssets

func WithIdleTimeout

func WithIdleTimeout(t time.Duration) Option

WithIdleTimeout

func WithReadTimeout

func WithReadTimeout(t time.Duration) Option

WithReadTimeout

func WithWriteTimeout

func WithWriteTimeout(t time.Duration) Option

WithWriteTimeout

type Options

type Options struct {
	IdleTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	Assets       embed.FS
}

type Server

type Server struct {

	// Addr is bind address
	Addr string
	// ProvidersService provides access to Provider enpoints.
	ProvidersService v1.ProvidersService
	// Embedders
	// NOTE: this is a major hack
	Embedders map[string]any
	// contains filtered or unexported fields
}

Server is an HTTP server used to provide REST API access for various Graph API endpoints.

func NewServer

func NewServer(options ...Option) (*Server, error)

NewServer creates a new Server and returns it.

func (*Server) Close

func (s *Server) Close(ctx context.Context) error

Close gracefully shuts down the server.

func (*Server) ComputeProviderProjections

func (s *Server) ComputeProviderProjections(c *fiber.Ctx) error

ComputeProviderProjections recomputes provider projections from scratch by UID. @Summary Recompute embeddings projections for a provider by UID and return them. @Description Recompute provider projections. @Tags providers @Accept json @Produce json @Param id path string true "Provider UID" @Param provider body v1.ProjectionsUpdate true "Update embeddings projections" @Success 200 {object} v1.ProjectionsResponse @Success 200 {object} v1.Embedding @Failure 400 {object} v1.ErrorResponse @Failure 404 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers/{uid}/projections [patch]

func (*Server) DropProviderEmbeddings

func (s *Server) DropProviderEmbeddings(c *fiber.Ctx) error

DropProviderEmbeddings drops all embeddings of the provider with the given uid. @Summary Delete embeddings by provider UID. @Description Delete embeddings by provider UID. This also drops projections. @Tags providers @Produce json @Param uid path string true "Provider UID" @Success 204 {string} status "Provider embeddings deleted successfully" @Failure 400 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers/{uid}/embeddings [delete]

func (*Server) GetAllProviders

func (s *Server) GetAllProviders(c *fiber.Ctx) error

GetAllProviders returns all available embeddings providers. @Summary Get all embeddings providers. @Description Get all available providers. @Tags providers @Produce json @Param offset query int false "Result offset" @Param limit query int false "Result limit" @Success 200 {object} v1.ProvidersResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers [get]

func (*Server) GetChunks

func (s *Server) GetChunks(c *fiber.Ctx) error

GetChunks chunks the given input using recursice character splitter (RCS) and returns indices of the chunks. RCS split separators are defined as: ["\n\n", "\n", " ", ""]. See: https://python.langchain.com/docs/modules/data_connection/document_transformers/recursive_text_splitter @Summary Get chunks from the given input. @Description Get chunks from the given input @Tags providers @Accept json @Produce json @Param input body v1.ChunkingInput true "Get input chunks" @Success 200 {object} []v1.ChunkingResponse @Failure 400 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/chunks [post]

func (*Server) GetProviderByUID

func (s *Server) GetProviderByUID(c *fiber.Ctx) error

GetProviderByUID returns the embeddings provider with the given UID. @Summary Get embeddings provider by UID. @Description Returns embeddings provider with the given UID. @Tags providers @Produce json @Param id path string true "Provider UID" @Success 200 {object} v1.Provider @Failure 400 {object} v1.ErrorResponse @Failure 404 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers/{uid} [get]

func (*Server) GetProviderEmbeddings

func (s *Server) GetProviderEmbeddings(c *fiber.Ctx) error

GetProviderEmbeddings returns all embeddings for the provider with the given UID. @Summary Get embeddings by provider UID. @Description Returns embeddings for the provider with the given UID. @Tags providers @Produce json @Param id path string true "Provider UID" @Param offset query int false "Result offset" @Param limit query int false "Result limit" @Success 200 {object} v1.EmbeddingsResponse @Failure 400 {object} v1.ErrorResponse @Failure 404 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers/{uid}/embeddings [get]

func (*Server) GetProviderProjections

func (s *Server) GetProviderProjections(c *fiber.Ctx) error

GetProviderProjections returns all stored embedding projections for the given provider. @Summary Get embeddings projections by provider UID. @Description Returns embedding projections for the provider with the given UID. @Tags providers @Produce json @Param id path string true "Provider UID" @Param offset query int false "Result offset" @Param limit query int false "Result limit" @Success 200 {object} v1.ProjectionsResponse @Failure 400 {object} v1.ErrorResponse @Failure 404 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers/{uid}/projections [get]

func (*Server) Listen

func (s *Server) Listen() error

Listen validates the server options and binds to the given address.

func (*Server) UpdateProviderEmbeddings

func (s *Server) UpdateProviderEmbeddings(c *fiber.Ctx) error

UpdateProviderEmbeddings fetches embeddings and updates provider records. @Summary Fetch and store embeddings for the provider with the given UID. @Description Update provider embeddings. @Tags providers @Accept json @Produce json @Param id path string true "Provider UID" @Param provider body v1.EmbeddingsUpdate true "Update provider embeddings" @Success 200 {object} []v1.Embedding @Failure 400 {object} v1.ErrorResponse @Failure 404 {object} v1.ErrorResponse @Failure 500 {object} v1.ErrorResponse @Router /v1/providers/{uid}/embeddings [put]

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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