util

package
v0.0.0-...-ab17b8d Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JsonErroFoundUnknownField = "Found unknown field"
)

Variables

This section is empty.

Functions

func ParseEmbeddingProviderSettings

func ParseEmbeddingProviderSettings(providerType types.EmbeddingProviderType, settingsJSON json.RawMessage) (types.EmbeddingProviderSettings, error)

func ParseLLMProviderSettings

func ParseLLMProviderSettings(providerType types.LLMProviderType, settingsJSON json.RawMessage) (types.LLMProviderSettings, error)

func ParseSettings

func ParseSettings(sourceType types.DatasourceType, settingsJSON json.RawMessage) (types.DatasourceSettings, error)

func SendAPIErrorResponse

func SendAPIErrorResponse(w http.ResponseWriter, statusCode int, err *APIError)

SendAPIErrorResponse sends a success response with data

func SendErrorResponse

func SendErrorResponse(w http.ResponseWriter, statusCode int, message string, logger *logrus.Logger, span trace.Span)

SendErrorResponse sends an error response with a message @deprecated

func SendSuccessResponse

func SendSuccessResponse(w http.ResponseWriter, statusCode int, data interface{}, logger *logrus.Logger, span trace.Span)

SendSuccessResponse sends a success response with data

Types

type APIError

type APIError struct {
	Message string `json:"message"`
	Err     string `json:"error"`
	// contains filtered or unexported fields
}

func DecodeJSONBody

func DecodeJSONBody(r *http.Request, v interface{}) *APIError

func NewAPIError

func NewAPIError(message string, err error) *APIError

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) GetRawError

func (e *APIError) GetRawError() error

type Response

type Response struct {
	Data  interface{} `json:"data,omitempty"`
	Error string      `json:"error,omitempty"`
}

Response is a generic response structure for API responses

Jump to

Keyboard shortcuts

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