Skip to content
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

[v14] Fix assist audit query prompt #33581

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions gen/go/eventschema/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func (d *TableSchemaDetails) CreateView() string {
return sb.String()
}

func sqlViewNameForEvent(eventName string) string {
// SQLViewNameForEvent returns a SQL compatible view name for a given event.
// [event code] -> [athena view name]
// session.start -> session_start
func SQLViewNameForEvent(eventName string) string {
viewName := strings.ReplaceAll(eventName, ".", "_")
return strings.ReplaceAll(viewName, "-", "_")
}
Expand Down Expand Up @@ -152,7 +155,7 @@ func GetViewsDetails() ([]*TableSchemaDetails, error) {
return nil, trace.Wrap(err)
}
tb.Name = eventName
tb.SQLViewName = sqlViewNameForEvent(eventName)
tb.SQLViewName = SQLViewNameForEvent(eventName)
out = append(out, tb)
}
return out, nil
Expand Down
2 changes: 1 addition & 1 deletion lib/ai/model/tools/auditquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Today's date is DATE('%s')`, time.Now().Format("2006-01-02")),
},
{
Role: openai.ChatMessageRoleUser,
Content: fmt.Sprintf("The schema of the table `%s` is:\n\n%s", eventType, tableSchema),
Content: fmt.Sprintf("The schema of the table `%s` is:\n\n%s", eventschema.SQLViewNameForEvent(eventType), tableSchema),
},
{
Role: openai.ChatMessageRoleUser,
Expand Down