|
|
|
|
| package requestexecution
|
|
|
| import (
|
| "fmt"
|
| "io"
|
| "strconv"
|
| "time"
|
|
|
| "entgo.io/ent/dialect/sql"
|
| "entgo.io/ent/dialect/sql/sqlgraph"
|
| )
|
|
|
| const (
|
|
|
| Label = "request_execution"
|
|
|
| FieldID = "id"
|
|
|
| FieldCreatedAt = "created_at"
|
|
|
| FieldUpdatedAt = "updated_at"
|
|
|
| FieldProjectID = "project_id"
|
|
|
| FieldRequestID = "request_id"
|
|
|
| FieldChannelID = "channel_id"
|
|
|
| FieldDataStorageID = "data_storage_id"
|
|
|
| FieldExternalID = "external_id"
|
|
|
| FieldModelID = "model_id"
|
|
|
| FieldFormat = "format"
|
|
|
| FieldRequestBody = "request_body"
|
|
|
| FieldResponseBody = "response_body"
|
|
|
| FieldResponseChunks = "response_chunks"
|
|
|
| FieldErrorMessage = "error_message"
|
|
|
| FieldStatus = "status"
|
|
|
| FieldStream = "stream"
|
|
|
| FieldMetricsLatencyMs = "metrics_latency_ms"
|
|
|
| FieldMetricsFirstTokenLatencyMs = "metrics_first_token_latency_ms"
|
|
|
| FieldRequestHeaders = "request_headers"
|
|
|
| EdgeRequest = "request"
|
|
|
| EdgeChannel = "channel"
|
|
|
| EdgeDataStorage = "data_storage"
|
|
|
| Table = "request_executions"
|
|
|
| RequestTable = "request_executions"
|
|
|
|
|
| RequestInverseTable = "requests"
|
|
|
| RequestColumn = "request_id"
|
|
|
| ChannelTable = "request_executions"
|
|
|
|
|
| ChannelInverseTable = "channels"
|
|
|
| ChannelColumn = "channel_id"
|
|
|
| DataStorageTable = "request_executions"
|
|
|
|
|
| DataStorageInverseTable = "data_storages"
|
|
|
| DataStorageColumn = "data_storage_id"
|
| )
|
|
|
|
|
| var Columns = []string{
|
| FieldID,
|
| FieldCreatedAt,
|
| FieldUpdatedAt,
|
| FieldProjectID,
|
| FieldRequestID,
|
| FieldChannelID,
|
| FieldDataStorageID,
|
| FieldExternalID,
|
| FieldModelID,
|
| FieldFormat,
|
| FieldRequestBody,
|
| FieldResponseBody,
|
| FieldResponseChunks,
|
| FieldErrorMessage,
|
| FieldStatus,
|
| FieldStream,
|
| FieldMetricsLatencyMs,
|
| FieldMetricsFirstTokenLatencyMs,
|
| FieldRequestHeaders,
|
| }
|
|
|
|
|
| func ValidColumn(column string) bool {
|
| for i := range Columns {
|
| if column == Columns[i] {
|
| return true
|
| }
|
| }
|
| return false
|
| }
|
|
|
| var (
|
|
|
| DefaultCreatedAt func() time.Time
|
|
|
| DefaultUpdatedAt func() time.Time
|
|
|
| UpdateDefaultUpdatedAt func() time.Time
|
|
|
| DefaultProjectID int
|
|
|
| DefaultFormat string
|
|
|
| DefaultStream bool
|
| )
|
|
|
|
|
| type Status string
|
|
|
|
|
| const (
|
| StatusPending Status = "pending"
|
| StatusProcessing Status = "processing"
|
| StatusCompleted Status = "completed"
|
| StatusFailed Status = "failed"
|
| StatusCanceled Status = "canceled"
|
| )
|
|
|
| func (s Status) String() string {
|
| return string(s)
|
| }
|
|
|
|
|
| func StatusValidator(s Status) error {
|
| switch s {
|
| case StatusPending, StatusProcessing, StatusCompleted, StatusFailed, StatusCanceled:
|
| return nil
|
| default:
|
| return fmt.Errorf("requestexecution: invalid enum value for status field: %q", s)
|
| }
|
| }
|
|
|
|
|
| type OrderOption func(*sql.Selector)
|
|
|
|
|
| func ByID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByProjectID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldProjectID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByRequestID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldRequestID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByChannelID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldChannelID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByDataStorageID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldDataStorageID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByExternalID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldExternalID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByModelID(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldModelID, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByFormat(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldFormat, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByErrorMessage(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldErrorMessage, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByStream(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldStream, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByMetricsLatencyMs(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldMetricsLatencyMs, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByMetricsFirstTokenLatencyMs(opts ...sql.OrderTermOption) OrderOption {
|
| return sql.OrderByField(FieldMetricsFirstTokenLatencyMs, opts...).ToFunc()
|
| }
|
|
|
|
|
| func ByRequestField(field string, opts ...sql.OrderTermOption) OrderOption {
|
| return func(s *sql.Selector) {
|
| sqlgraph.OrderByNeighborTerms(s, newRequestStep(), sql.OrderByField(field, opts...))
|
| }
|
| }
|
|
|
|
|
| func ByChannelField(field string, opts ...sql.OrderTermOption) OrderOption {
|
| return func(s *sql.Selector) {
|
| sqlgraph.OrderByNeighborTerms(s, newChannelStep(), sql.OrderByField(field, opts...))
|
| }
|
| }
|
|
|
|
|
| func ByDataStorageField(field string, opts ...sql.OrderTermOption) OrderOption {
|
| return func(s *sql.Selector) {
|
| sqlgraph.OrderByNeighborTerms(s, newDataStorageStep(), sql.OrderByField(field, opts...))
|
| }
|
| }
|
| func newRequestStep() *sqlgraph.Step {
|
| return sqlgraph.NewStep(
|
| sqlgraph.From(Table, FieldID),
|
| sqlgraph.To(RequestInverseTable, FieldID),
|
| sqlgraph.Edge(sqlgraph.M2O, true, RequestTable, RequestColumn),
|
| )
|
| }
|
| func newChannelStep() *sqlgraph.Step {
|
| return sqlgraph.NewStep(
|
| sqlgraph.From(Table, FieldID),
|
| sqlgraph.To(ChannelInverseTable, FieldID),
|
| sqlgraph.Edge(sqlgraph.M2O, true, ChannelTable, ChannelColumn),
|
| )
|
| }
|
| func newDataStorageStep() *sqlgraph.Step {
|
| return sqlgraph.NewStep(
|
| sqlgraph.From(Table, FieldID),
|
| sqlgraph.To(DataStorageInverseTable, FieldID),
|
| sqlgraph.Edge(sqlgraph.M2O, true, DataStorageTable, DataStorageColumn),
|
| )
|
| }
|
|
|
|
|
| func (e Status) MarshalGQL(w io.Writer) {
|
| io.WriteString(w, strconv.Quote(e.String()))
|
| }
|
|
|
|
|
| func (e *Status) UnmarshalGQL(val interface{}) error {
|
| str, ok := val.(string)
|
| if !ok {
|
| return fmt.Errorf("enum %T must be a string", val)
|
| }
|
| *e = Status(str)
|
| if err := StatusValidator(*e); err != nil {
|
| return fmt.Errorf("%s is not a valid Status", str)
|
| }
|
| return nil
|
| }
|
|
|