Documentation
¶
Index ¶
- Constants
- func ErrColumnNotFound(input string) error
- type AIRowsGenerator
- type AutofillRequest
- type ColumnSchema
- type CreateRowsRequest
- type GenerateRowsRequest
- type ListTablesResponse
- type Rows
- type RowsGenerator
- type RowsGeneratorMock
- type SharedSource
- type TableColumnInfo
- type TableGenColumn
- type TableGenColumnSchema
- type TableGenRequest
- type TableInfo
- type TableService
- type TableServiceImpl
- func (t *TableServiceImpl) Create(ctx context.Context, req *TableGenRequest) (string, error)
- func (t *TableServiceImpl) CreateRows(ctx context.Context, table string, rows []map[string]any) error
- func (t *TableServiceImpl) Delete(ctx context.Context, table string) (int, error)
- func (t *TableServiceImpl) Genetate(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error)
- func (t *TableServiceImpl) GetTableDetail(ctx context.Context, table string) (*TableInfo, error)
- func (t *TableServiceImpl) Import(ctx context.Context, table string, reader io.Reader) (string, error)
- func (t *TableServiceImpl) ListTables(ctx context.Context) (*ListTablesResponse, error)
- func (t *TableServiceImpl) Rows(ctx context.Context, table string) (*Rows, error)
- func (t *TableServiceImpl) SharedSources(ctx context.Context) []*SharedSource
- func (t *TableServiceImpl) Truncate(ctx context.Context, table string) (int, error)
- func (t *TableServiceImpl) Update(ctx context.Context, table string, req *TableGenRequest) (string, error)
- type TableServiceMock
- func (mock *TableServiceMock) Create(ctx context.Context, req *TableGenRequest) (string, error)
- func (mock *TableServiceMock) CreateCalls() []struct{ ... }
- func (mock *TableServiceMock) CreateRows(ctx context.Context, table string, rows []map[string]any) error
- func (mock *TableServiceMock) CreateRowsCalls() []struct{ ... }
- func (mock *TableServiceMock) Delete(ctx context.Context, table string) (int, error)
- func (mock *TableServiceMock) DeleteCalls() []struct{ ... }
- func (mock *TableServiceMock) Genetate(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error)
- func (mock *TableServiceMock) GenetateCalls() []struct{ ... }
- func (mock *TableServiceMock) GetTableDetail(ctx context.Context, table string) (*TableInfo, error)
- func (mock *TableServiceMock) GetTableDetailCalls() []struct{ ... }
- func (mock *TableServiceMock) Import(ctx context.Context, table string, reader io.Reader) (string, error)
- func (mock *TableServiceMock) ImportCalls() []struct{ ... }
- func (mock *TableServiceMock) ListTables(ctx context.Context) (*ListTablesResponse, error)
- func (mock *TableServiceMock) ListTablesCalls() []struct{ ... }
- func (mock *TableServiceMock) Rows(ctx context.Context, table string) (*Rows, error)
- func (mock *TableServiceMock) RowsCalls() []struct{ ... }
- func (mock *TableServiceMock) SharedSources(ctx context.Context) []*SharedSource
- func (mock *TableServiceMock) SharedSourcesCalls() []struct{ ... }
- func (mock *TableServiceMock) Truncate(ctx context.Context, table string) (int, error)
- func (mock *TableServiceMock) TruncateCalls() []struct{ ... }
- func (mock *TableServiceMock) Update(ctx context.Context, table string, req *TableGenRequest) (string, error)
- func (mock *TableServiceMock) UpdateCalls() []struct{ ... }
Constants ¶
const ( CREATE_TABLE_TEMPERATURE = 0.1 CREATE_TABLE_MAX_TOKENS = 3000 GENERATE_DATA_TEMPERATURE = 0.6 GENERATE_DATA_MAX_TOKENS = 6000 )
Variables ¶
This section is empty.
Functions ¶
func ErrColumnNotFound ¶ added in v0.0.8
Types ¶
type AIRowsGenerator ¶
type AIRowsGenerator struct {
// contains filtered or unexported fields
}
func NewRowsGenerator ¶
func NewRowsGenerator(ctx context.Context, params GenerateRowsRequest, db *ent.Client, ai ai.AiService, logger *zap.SugaredLogger) (*AIRowsGenerator, error)
func (*AIRowsGenerator) Table ¶
func (g *AIRowsGenerator) Table() *ent.TableMeta
type AutofillRequest ¶ added in v0.0.6
type ColumnSchema ¶
type CreateRowsRequest ¶ added in v0.0.7
type GenerateRowsRequest ¶ added in v0.0.2
type GenerateRowsRequest struct {
Table string `json:"table"`
SaveTo string `json:"save_to"`
Count int `json:"count"`
Batch int `json:"batch"`
Temperature float64 `json:"temperature"`
Model string `json:"model"`
// used in API only to send streaming results
Stream bool `json:"stream"`
Autofill AutofillRequest `json:"autofill"`
// contains filtered or unexported fields
}
type ListTablesResponse ¶
type Rows ¶
type Rows struct {
Columns []*ent.TableColumn `json:"columns"`
Rows []*ent.TableRow `json:"rows"`
}
type RowsGenerator ¶
type RowsGeneratorMock ¶
type RowsGeneratorMock struct {
// NextFunc mocks the Next method.
NextFunc func(ctx context.Context) ([]map[string]*schema.CellValue, error)
// TableFunc mocks the Table method.
TableFunc func() *ent.TableMeta
// contains filtered or unexported fields
}
RowsGeneratorMock is a mock implementation of RowsGenerator.
func TestSomethingThatUsesRowsGenerator(t *testing.T) {
// make and configure a mocked RowsGenerator
mockedRowsGenerator := &RowsGeneratorMock{
NextFunc: func(ctx context.Context) ([]map[string]*schema.CellValue, error) {
panic("mock out the Next method")
},
TableFunc: func() *ent.TableMeta {
panic("mock out the Table method")
},
}
// use mockedRowsGenerator in code that requires RowsGenerator
// and then make assertions.
}
func (*RowsGeneratorMock) NextCalls ¶
func (mock *RowsGeneratorMock) NextCalls() []struct { Ctx context.Context }
NextCalls gets all the calls that were made to Next. Check the length with:
len(mockedRowsGenerator.NextCalls())
func (*RowsGeneratorMock) Table ¶
func (mock *RowsGeneratorMock) Table() *ent.TableMeta
Table calls TableFunc.
func (*RowsGeneratorMock) TableCalls ¶
func (mock *RowsGeneratorMock) TableCalls() []struct { }
TableCalls gets all the calls that were made to Table. Check the length with:
len(mockedRowsGenerator.TableCalls())
type SharedSource ¶ added in v0.1.0
type SharedSource struct {
Columns []string `json:"columns"`
}
type TableColumnInfo ¶
type TableGenColumn ¶
type TableGenColumn struct {
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
FillMode string `json:"fill_mode"`
Source string `json:"source"`
Random bool `json:"random"`
Replacement bool `json:"replacement"`
Repeat int `json:"repeat"`
ContextLength int `json:"context_length"`
LinkedColumn string `json:"linked_column"`
LinkedContextColumns []string `json:"linked_context_columns"`
}
type TableGenColumnSchema ¶
type TableGenRequest ¶
type TableGenRequest struct {
Name string `json:"name"`
Model string `json:"model"`
Description string `json:"description"`
Columns []TableGenColumn `json:"columns"`
Sources []json.RawMessage `json:"sources"`
// contains filtered or unexported fields
}
func (*TableGenRequest) APIRequest ¶ added in v0.1.0
func (r *TableGenRequest) APIRequest() bool
func (*TableGenRequest) MarkAPIRequest ¶ added in v0.1.0
func (r *TableGenRequest) MarkAPIRequest()
type TableInfo ¶ added in v0.0.3
type TableInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Model string `json:"model"`
Columns []TableColumnInfo `json:"columns"`
}
type TableService ¶
type TableService interface {
Create(ctx context.Context, req *TableGenRequest) (string, error)
Update(ctx context.Context, table string, req *TableGenRequest) (string, error)
ListTables(ctx context.Context) (*ListTablesResponse, error)
GetTableDetail(ctx context.Context, table string) (*TableInfo, error)
Genetate(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error)
Rows(ctx context.Context, table string) (*Rows, error)
Truncate(ctx context.Context, table string) (int, error)
Delete(ctx context.Context, table string) (int, error)
Import(ctx context.Context, table string, reader io.Reader) (string, error)
CreateRows(ctx context.Context, table string, rows []map[string]any) error
}
type TableServiceImpl ¶
type TableServiceImpl struct {
// contains filtered or unexported fields
}
func NewTableService ¶
func NewTableService(config *config.Config, db *ent.Client, ai ai.AiService, logger *zap.SugaredLogger) (*TableServiceImpl, error)
func (*TableServiceImpl) Create ¶ added in v0.1.4
func (t *TableServiceImpl) Create(ctx context.Context, req *TableGenRequest) (string, error)
func (*TableServiceImpl) CreateRows ¶ added in v0.0.7
func (*TableServiceImpl) Genetate ¶
func (t *TableServiceImpl) Genetate(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error)
func (*TableServiceImpl) GetTableDetail ¶ added in v0.0.3
func (*TableServiceImpl) ListTables ¶
func (t *TableServiceImpl) ListTables(ctx context.Context) (*ListTablesResponse, error)
func (*TableServiceImpl) SharedSources ¶ added in v0.1.0
func (t *TableServiceImpl) SharedSources(ctx context.Context) []*SharedSource
func (*TableServiceImpl) Update ¶ added in v0.1.4
func (t *TableServiceImpl) Update(ctx context.Context, table string, req *TableGenRequest) (string, error)
type TableServiceMock ¶
type TableServiceMock struct {
// CreateFunc mocks the Create method.
CreateFunc func(ctx context.Context, req *TableGenRequest) (string, error)
// CreateRowsFunc mocks the CreateRows method.
CreateRowsFunc func(ctx context.Context, table string, rows []map[string]any) error
// DeleteFunc mocks the Delete method.
DeleteFunc func(ctx context.Context, table string) (int, error)
// GenetateFunc mocks the Genetate method.
GenetateFunc func(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error)
// GetTableDetailFunc mocks the GetTableDetail method.
GetTableDetailFunc func(ctx context.Context, table string) (*TableInfo, error)
// ImportFunc mocks the Import method.
ImportFunc func(ctx context.Context, table string, reader io.Reader) (string, error)
// ListTablesFunc mocks the ListTables method.
ListTablesFunc func(ctx context.Context) (*ListTablesResponse, error)
// RowsFunc mocks the Rows method.
RowsFunc func(ctx context.Context, table string) (*Rows, error)
SharedSourcesFunc func(ctx context.Context) []*SharedSource
// TruncateFunc mocks the Truncate method.
TruncateFunc func(ctx context.Context, table string) (int, error)
// UpdateFunc mocks the Update method.
UpdateFunc func(ctx context.Context, table string, req *TableGenRequest) (string, error)
// contains filtered or unexported fields
}
TableServiceMock is a mock implementation of TableService.
func TestSomethingThatUsesTableService(t *testing.T) {
// make and configure a mocked TableService
mockedTableService := &TableServiceMock{
CreateFunc: func(ctx context.Context, req *TableGenRequest) (string, error) {
panic("mock out the Create method")
},
CreateRowsFunc: func(ctx context.Context, table string, rows []map[string]any) error {
panic("mock out the CreateRows method")
},
DeleteFunc: func(ctx context.Context, table string) (int, error) {
panic("mock out the Delete method")
},
GenetateFunc: func(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error) {
panic("mock out the Genetate method")
},
GetTableDetailFunc: func(ctx context.Context, table string) (*TableInfo, error) {
panic("mock out the GetTableDetail method")
},
ImportFunc: func(ctx context.Context, table string, reader io.Reader) (string, error) {
panic("mock out the Import method")
},
ListTablesFunc: func(ctx context.Context) (*ListTablesResponse, error) {
panic("mock out the ListTables method")
},
RowsFunc: func(ctx context.Context, table string) (*Rows, error) {
panic("mock out the Rows method")
},
SharedSourcesFunc: func(ctx context.Context) []*SharedSource {
panic("mock out the SharedSources method")
},
TruncateFunc: func(ctx context.Context, table string) (int, error) {
panic("mock out the Truncate method")
},
UpdateFunc: func(ctx context.Context, table string, req *TableGenRequest) (string, error) {
panic("mock out the Update method")
},
}
// use mockedTableService in code that requires TableService
// and then make assertions.
}
func (*TableServiceMock) Create ¶ added in v0.1.4
func (mock *TableServiceMock) Create(ctx context.Context, req *TableGenRequest) (string, error)
Create calls CreateFunc.
func (*TableServiceMock) CreateCalls ¶ added in v0.1.4
func (mock *TableServiceMock) CreateCalls() []struct { Ctx context.Context Req *TableGenRequest }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedTableService.CreateCalls())
func (*TableServiceMock) CreateRows ¶ added in v0.0.7
func (mock *TableServiceMock) CreateRows(ctx context.Context, table string, rows []map[string]any) error
CreateRows calls CreateRowsFunc.
func (*TableServiceMock) CreateRowsCalls ¶ added in v0.0.7
func (mock *TableServiceMock) CreateRowsCalls() []struct { Ctx context.Context Table string Rows []map[string]any }
CreateRowsCalls gets all the calls that were made to CreateRows. Check the length with:
len(mockedTableService.CreateRowsCalls())
func (*TableServiceMock) DeleteCalls ¶
func (mock *TableServiceMock) DeleteCalls() []struct { Ctx context.Context Table string }
DeleteCalls gets all the calls that were made to Delete. Check the length with:
len(mockedTableService.DeleteCalls())
func (*TableServiceMock) Genetate ¶
func (mock *TableServiceMock) Genetate(ctx context.Context, params GenerateRowsRequest) (RowsGenerator, error)
Genetate calls GenetateFunc.
func (*TableServiceMock) GenetateCalls ¶
func (mock *TableServiceMock) GenetateCalls() []struct { Ctx context.Context Params GenerateRowsRequest }
GenetateCalls gets all the calls that were made to Genetate. Check the length with:
len(mockedTableService.GenetateCalls())
func (*TableServiceMock) GetTableDetail ¶ added in v0.0.3
GetTableDetail calls GetTableDetailFunc.
func (*TableServiceMock) GetTableDetailCalls ¶ added in v0.0.3
func (mock *TableServiceMock) GetTableDetailCalls() []struct { Ctx context.Context Table string }
GetTableDetailCalls gets all the calls that were made to GetTableDetail. Check the length with:
len(mockedTableService.GetTableDetailCalls())
func (*TableServiceMock) Import ¶
func (mock *TableServiceMock) Import(ctx context.Context, table string, reader io.Reader) (string, error)
Import calls ImportFunc.
func (*TableServiceMock) ImportCalls ¶
func (mock *TableServiceMock) ImportCalls() []struct { Ctx context.Context Table string Reader io.Reader }
ImportCalls gets all the calls that were made to Import. Check the length with:
len(mockedTableService.ImportCalls())
func (*TableServiceMock) ListTables ¶
func (mock *TableServiceMock) ListTables(ctx context.Context) (*ListTablesResponse, error)
ListTables calls ListTablesFunc.
func (*TableServiceMock) ListTablesCalls ¶
func (mock *TableServiceMock) ListTablesCalls() []struct { Ctx context.Context }
ListTablesCalls gets all the calls that were made to ListTables. Check the length with:
len(mockedTableService.ListTablesCalls())
func (*TableServiceMock) RowsCalls ¶
func (mock *TableServiceMock) RowsCalls() []struct { Ctx context.Context Table string }
RowsCalls gets all the calls that were made to Rows. Check the length with:
len(mockedTableService.RowsCalls())
func (*TableServiceMock) SharedSources ¶ added in v0.1.0
func (mock *TableServiceMock) SharedSources(ctx context.Context) []*SharedSource
SharedSources calls SharedSourcesFunc.
func (*TableServiceMock) SharedSourcesCalls ¶ added in v0.1.0
func (mock *TableServiceMock) SharedSourcesCalls() []struct { Ctx context.Context }
SharedSourcesCalls gets all the calls that were made to SharedSources. Check the length with:
len(mockedTableService.SharedSourcesCalls())
func (*TableServiceMock) TruncateCalls ¶
func (mock *TableServiceMock) TruncateCalls() []struct { Ctx context.Context Table string }
TruncateCalls gets all the calls that were made to Truncate. Check the length with:
len(mockedTableService.TruncateCalls())
func (*TableServiceMock) Update ¶ added in v0.1.4
func (mock *TableServiceMock) Update(ctx context.Context, table string, req *TableGenRequest) (string, error)
Update calls UpdateFunc.
func (*TableServiceMock) UpdateCalls ¶ added in v0.1.4
func (mock *TableServiceMock) UpdateCalls() []struct { Ctx context.Context Table string Req *TableGenRequest }
UpdateCalls gets all the calls that were made to Update. Check the length with:
len(mockedTableService.UpdateCalls())