src

package
v0.0.0-...-5338690 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func Check

func Check(e error)

func CheckEmpty

func CheckEmpty(name string) (bool, error)

func ConnectDB

func ConnectDB()

func Index

func Index(c *gin.Context)

=================== Serializers =================== * Home serializer * Login serializer * Score Summary serializer * Parsification/Scoring serializer * Score suggestion serializer

func LoginPage

func LoginPage(c *gin.Context)

func Parsification

func Parsification(c *gin.Context)

TODO: need to update how failure is handled and logging write method for triggering scores perspective api res loaded into tmp schema.go and saved to db

func Suggestion

func Suggestion(c *gin.Context)

FIXME: update once template implemented will be for giving ai model feedback on returned scores so we can consistently enhance our UX.

func Upload

func Upload(c *gin.Context)

for uploading files, parsification/score suggestions for running action actions (remove route logic from parse/suggest - hold as functions that work in this route here)

Types

type AnalyzeRequest

type AnalyzeRequest struct {
	Comment AnalyzeRequestComment            `json:"comment"`
	ReqAttr map[Attribute]AnalyzeRequestAttr `json:"requestedAttributes"`

	//Indicates if the request should return spans that describe the scores for each part of the text (currently done at per-sentence level).
	SpanAnnotations bool `json:"spanAnnotations,omitempty"`
	//Stored comments will be used for future research
	DoNotStore bool `json:"doNotStore,omitempty"`
	//(optional) Example: "en", "es", "fr", "de", etc. If unspecified, the API will auto-detect the comment language.
	Languages []string `json:"languages,omitempty"`
	//(optional) An opaque token that is echoed back in the response. (Note: This is not the clientId, which is automatically set through Google Cloud. This is a field users can set to help them keep track of their requests.)
	ClientToken string `json:"clientToken,omitempty"`
	//(optional) An opaque session ID. This should be set for authorship experiences by the client side so that groups of requests can be grouped together into a session.
	SessionID string `json:"sessionId,omitempty"`
	//(optional) An opaque identifier associating this comment with a particular community within your platform.
	CommunityID string `json:"communityId,omitempty"`
}

FIXME: SuggestRequst is the data for the API's analyze method.

type AnalyzeRequestAttr

type AnalyzeRequestAttr struct {
	//(optional) Currently, only "PROBABILITY" is supported.
	ScoreType string `json:"scoreType,omitempty"`
	//(optional)The API won't return scores that are below this threshold for this attribute.
	ScoreThreshold float32 `json:"scoreThreshold,omitempty"`
}

AnalyzeRequestAttr is a type for AnalyzeRequest struct.

type AnalyzeRequestComment

type AnalyzeRequestComment struct {
	Text string `json:"text"`
	//(optional) Type must be either "PLAIN_TEXT" or "HTML". Currently only "PLAIN_TEXT" is supported.
	Type string `json:"type,omitempty"`
}

AnalyzeRequestComment is a type for AnalyzeRequest struct.

type AnalyzeResponse

type AnalyzeResponse struct {
	//The attribute names will mirror the request's requestedAttributes.
	AttributeScores map[Attribute]AttributeScore `json:"attributeScores"`
	//Mirrors the request's languages. If no languages were specified, the API returns the auto-detected language.
	Languages []string `json:"languages"`
	Error     ErrorRes `json:"error"`
}

AnalyzeResponse is the response data from the API's analyze method.

type AttributeScore

type AttributeScore struct {
	SummaryScore Score       `json:"summaryScore"`
	SpanScores   []SpanScore `json:"spanScores"`
}

type ErrorRes

type ErrorRes struct {
	Code    int                      `json:"code"`
	Message string                   `json:"message"`
	Status  string                   `json:"status"`
	Details []map[string]interface{} `json:"details"`
}

ErrorRes is the mapped API error response.

type Score

type Score struct {
	Value float32 `json:"value"`
	Type  string  `json:"type,omitempty"`
}

type Scores

type Scores struct {
	ID      uint   `json:"id" gorm:"primary_key"`
	User    string `json:"user"`
	Text    string `json:"text"`
	Harmful string `json:"harmful"`
}

type SpanScore

type SpanScore struct {
	Begin int   `json:"begin"`
	End   int   `json:"end"`
	Score Score `json:"score"`
}

type Specialist

type Specialist struct {
	ID         uint   `json:"id" gorm:"primary_key"`
	First_name string `json:"first_name"`
	Last_name  string `json:"last_name"`
	Email      string `json:"email"`
}

TODO:

type SuggestRequest

type SuggestRequest struct {
	Comment AnalyzeRequestComment `json:"comment"`

	//This holds the attribute scores that the client believes the comment should have. It has the same format as the attributeScores.
	AttributeScores map[Attribute]AttributeScore `json:"attributeScores"`
	//(optional) Example: "en", "es", "fr", "de", etc. If unspecified, the API will auto-detect the comment language.
	Languages []string `json:"languages,omitempty"`
	//(optional) An opaque identifier associating this comment with a particular community within your platform.
	CommunityID string `json:"communityId,omitempty"`
	//(optional) An opaque token that is echoed back in the response. (Note: This is not the clientId, which is automatically set through Google Cloud. This is a field users can set to help them keep track of their requests.)
	ClientToken string `json:"clientToken,omitempty"`
}

SuggestRequst is the data for the API's suggest method.

type SuggestResposne

type SuggestResposne struct {
	ClientToken string   `json:"clientToken"`
	Error       ErrorRes `json:"error"`
}

AnalyzeResponse is the response data from the API's suggest method.

Jump to

Keyboard shortcuts

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