Documentation
¶
Index ¶
- Constants
- type AIRowsGenerator
- type AutofillRequest
- type ColumnSchema
- type GenerateRowsRequest
- type ListTablesResponse
- type Rows
- type RowsGenerator
- type RowsGeneratorMock
- type TableColumnInfo
- type TableGenColumn
- type TableGenColumnSchema
- type TableGenRequest
- type TableInfo
- type TableService
- type TableServiceImpl
- func (t *TableServiceImpl) CreateTable(ctx context.Context, req *TableGenRequest) (string, 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) Truncate(ctx context.Context, table string) (int, error)
- type TableServiceMock
- func (mock *TableServiceMock) CreateTable(ctx context.Context, req *TableGenRequest) (string, error)
- func (mock *TableServiceMock) CreateTableCalls() []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) Truncate(ctx context.Context, table string) (int, error)
- func (mock *TableServiceMock) TruncateCalls() []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 ¶
This section is empty.
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 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 `json:""` in API only to send streaming results
Stream bool `json:"stream"`
Autofill AutofillRequest `json:"autofill"`
}
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 TableColumnInfo ¶
type TableGenColumn ¶
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"`
}
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 {
CreateTable(ctx context.Context, 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)
}
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
func (*TableServiceImpl) CreateTable ¶
func (t *TableServiceImpl) CreateTable(ctx context.Context, req *TableGenRequest) (string, error)
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)
type TableServiceMock ¶
type TableServiceMock struct {
// CreateTableFunc mocks the CreateTable method.
CreateTableFunc func(ctx context.Context, req *TableGenRequest) (string, 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)
// TruncateFunc mocks the Truncate method.
TruncateFunc func(ctx context.Context, table string) (int, 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{
CreateTableFunc: func(ctx context.Context, req *TableGenRequest) (string, error) {
panic("mock out the CreateTable 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")
},
TruncateFunc: func(ctx context.Context, table string) (int, error) {
panic("mock out the Truncate method")
},
}
// use mockedTableService in code that requires TableService
// and then make assertions.
}
func (*TableServiceMock) CreateTable ¶
func (mock *TableServiceMock) CreateTable(ctx context.Context, req *TableGenRequest) (string, error)
CreateTable calls CreateTableFunc.
func (*TableServiceMock) CreateTableCalls ¶
func (mock *TableServiceMock) CreateTableCalls() []struct { Ctx context.Context Req *TableGenRequest }
CreateTableCalls gets all the calls that were made to CreateTable. Check the length with:
len(mockedTableService.CreateTableCalls())
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) 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())