Documentation ¶
Overview ¶
Package bot contains the core logic for TorontoBot which is shared across host platforms.
Index ¶
- Constants
- Variables
- type ChartSelectResponse
- type ChartType
- type DataTable
- type MsgTemplate
- type SQLResponse
- type TorontoBot
- func (b *TorontoBot) HasGraphStore() bool
- func (b *TorontoBot) LoadResults(sqlQuery string, isCurrency bool) (string, error)
- func (b *TorontoBot) SQLAnalysis(ctx context.Context, table *DataTable, question string) (*SQLResponse, error)
- func (b *TorontoBot) SaveToGraph(ctx context.Context, id, title, body, chartJS, featureImage, user string) (string, error)
- func (b *TorontoBot) SelectChart(ctx context.Context, question, dataTable string) (*ChartSelectResponse, error)
- func (b *TorontoBot) SelectTable(ctx context.Context, question string) (*DataTable, error)
Constants ¶
View Source
const ( // Model is the openai model to query. GPT-4 is expensive, so we use GPT-3.5. //Model = openai.GPT4 Model = openai.GPT3Dot5Turbo // RespTemp is the response temperature we want from the model. Default temp is 1.0 and higher // is more "creative". RespTemp = 0.1 )
Variables ¶
View Source
var ChartSelectFunction = openai.FunctionDefinition{ Name: "select_chart", Description: "Selects a chart type and foramts data to be used in the chart.", Parameters: jsonschema.Definition{ Type: jsonschema.Object, Properties: map[string]*jsonschema.Definition{ "type": { Type: jsonschema.String, Description: "Selected type of chart for this data.", Enum: []string{"bar", "stacked-bar", "line", "pie"}, }, "title": { Type: jsonschema.String, Description: "Title for the chart.", }, "data": { Type: jsonschema.Array, Items: &jsonschema.Definition{ Type: jsonschema.Object, Properties: map[string]*jsonschema.Definition{ "name": { Type: jsonschema.String, Description: "Name of the data entry.", }, "date": { Type: jsonschema.Number, Description: "Year of the data entry.", }, "value": { Type: jsonschema.Number, Description: "Value of the data entry.", }, }, Required: []string{"value"}, }, }, "is_currency": { Type: jsonschema.Boolean, Description: "Whether the data value represents money/currency amount or not.", }, }, Required: []string{"type", "title", "data", "is_currency"}, }, }
View Source
var SQLAnalysisFunction = openai.FunctionDefinition{ Name: "sql_analysis", Description: "Accepts SQL query analysis derived from user queries.", Parameters: jsonschema.Definition{ Type: jsonschema.Object, Properties: map[string]*jsonschema.Definition{ "schema": { Type: jsonschema.String, Description: "1 to 2 sentences about which columns from the schema to use.", }, "applicability": { Type: jsonschema.String, Description: "1 to 2 sentences about which columns and enums are relevant, or which ones are missing.", }, "sql": { Type: jsonschema.String, Description: "A single-line SQL query to run. Remember to escape any special characters", }, "result_is_currency": { Type: jsonschema.Boolean, Description: "Whether the result of the query is a currency value.", }, }, Required: []string{"schema", "applicability", "sql", "result_is_currency"}, }, }
Functions ¶
This section is empty.
Types ¶
type ChartSelectResponse ¶
type DataTable ¶
type DataTable struct { Name string `json:"name"` Desc string `json:"description"` Schema string `json:"schema"` Enums map[string][]interface{} `json:"enums"` Hints map[string]map[string]string `json:"hints"` Instructions string `json:"instructions"` }
func (*DataTable) EmbeddingText ¶
type MsgTemplate ¶
type MsgTemplate struct { Role string `json:"role"` Name string `json:"name"` Content string `json:"content"` FunctionCall *openai.FunctionCall `json:"function_call"` // contains filtered or unexported fields }
func (*MsgTemplate) Parse ¶
func (t *MsgTemplate) Parse() error
type SQLResponse ¶
type TorontoBot ¶
type TorontoBot struct { Hostname string // contains filtered or unexported fields }
func (*TorontoBot) HasGraphStore ¶
func (b *TorontoBot) HasGraphStore() bool
func (*TorontoBot) LoadResults ¶
func (b *TorontoBot) LoadResults(sqlQuery string, isCurrency bool) (string, error)
func (*TorontoBot) SQLAnalysis ¶
func (b *TorontoBot) SQLAnalysis(ctx context.Context, table *DataTable, question string) (*SQLResponse, error)
func (*TorontoBot) SaveToGraph ¶
func (*TorontoBot) SelectChart ¶
func (b *TorontoBot) SelectChart(ctx context.Context, question, dataTable string) (*ChartSelectResponse, error)
func (*TorontoBot) SelectTable ¶
Click to show internal directories.
Click to hide internal directories.