-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate chart yaml using AI #4323
Conversation
74af5f5
to
e32e9a3
Compare
Replace the data field in vega lite json with, | ||
{ "name": "table" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With metrics view generation, it seemed that less fixed rule were better. So maybe consider saying "don't add a 'data' field". And then just add this programmatically afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I am seeing is chatgpt does a good job of giving proper indentation. Parsing, updating and reformatting will lose this. So probably it might be good to keep it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, you can keep if you want. But note that Go's JSON encoder is able to output indented JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While true, I dont think any library can do partial indentation like,
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": { "name": "table" },
"mark": "arc",
"encoding": {
"theta": {"field": "total_records", "type": "quantitative"},
"color": {"field": "publisher", "type": "nominal"}
},
"width": 300,
"height": 300
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably true :) Makes sense
b2bb265
to
a4d5fdc
Compare
d0e92c6
to
024e3a0
Compare
d3fdec9
to
8a0f5a8
Compare
proto/rill/runtime/v1/api.proto
Outdated
rpc GenerateResolver(GenerateResolverRequest) returns (GenerateResolverResponse) { | ||
option (google.api.http) = { | ||
post: "/v1/instances/{instance_id}/files/generate-resolver", | ||
body: "*" | ||
}; | ||
} | ||
|
||
rpc GenerateChartSpec(GenerateChartSpecRequest) returns (GenerateChartSpecResponse) { | ||
option (google.api.http) = { | ||
post: "/v1/instances/{instance_id}/files/generate-chart", | ||
body: "*" | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add a docstring for each API (can be short, like for the other APIs) :)
- Since these endpoints don't generate files, they shouldn't use the
/files
/ path. For consistency between all the generator APIs, you might also consider refactoringGenerateMetricsViewFile
toGenerateMetricsView
and have the frontend write the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for 2 will raise a separate PR to refactor GenerateMetricsViewFile
. This PR is already getting large.
proto/rill/runtime/v1/api.proto
Outdated
string table = 3; | ||
string connector = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: define connector
before table
– that's the order in all other protos with these two props
string prompt = 2; | ||
string table = 3; | ||
string connector = 4; | ||
string metrics_view = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment that if this is set, both connector
and table
should be empty
runtime/resolver.go
Outdated
@@ -86,7 +95,7 @@ type ResolveOptions struct { | |||
} | |||
|
|||
// Resolve resolves a query using the given options. | |||
func (r *Runtime) Resolve(ctx context.Context, opts *ResolveOptions) ([]byte, error) { | |||
func (r *Runtime) Resolve(ctx context.Context, opts *ResolveOptions) (*CachedResolverResult, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would suggest not using a pointer, this is a very light struct
runtime/resolver.go
Outdated
// CachedResolverResult is subset of ResolverResult that is cached | ||
type CachedResolverResult struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would suggest calling this ResolveResult
because it is a result returned from Resolve
(note: not "resolve", not "resolver"). And then move the definition to after the
ResolveOptions` struct.
"Cached" is an implementation detail, and it will actually not always have been served from cache :)
Replace the data field in vega lite json with, | ||
{ "name": "table" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, you can keep if you want. But note that Go's JSON encoder is able to output indented JSON.
runtime/server/generate_chart.go
Outdated
func marshalResolverProperties(resolverProperties map[string]interface{}) string { | ||
if sql, ok := resolverProperties["sql"]; ok { | ||
if sqlStr, ok := sql.(string); ok { | ||
return sqlStr | ||
} | ||
} | ||
|
||
if api, ok := resolverProperties["api"]; ok { | ||
if apiStr, ok := api.(string); ok { | ||
return apiStr | ||
} | ||
} | ||
|
||
return "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of the resolver abstraction is to avoid resolver-specific switches littered across the codebase. So can we change this to a normal JSON serialization?
runtime/server/generate_resolver.go
Outdated
attribute.String("args.connector", req.Connector), | ||
attribute.String("args.table", req.Table), | ||
attribute.String("args.metrics_view", req.MetricsView), | ||
// attribute.String("args.prompt", req.Prompt), // Adding this might be a privacy issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as in the other API
runtime/server/generate_resolver.go
Outdated
|
||
start := time.Now() | ||
|
||
sql, err := s.generateResolverForTable(ctx, req.InstanceId, req.Prompt, tbl.Name, dialect, tbl.Schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would suggest returning resolver, resolverProps, err
here instead of sql
(otherwise the function should be generateSQLResolverForTable
)
runtime/server/generate_resolver.go
Outdated
sql, err := s.generateResolverForMetricsView(ctx, req.InstanceId, req.Prompt, req.MetricsView, dialect, q.Result.Schema) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment – mismatch between func name and return value
07263f8
to
ca7fd31
Compare
46a9209
to
61c03ea
Compare
These will have a follow up PR