Skip to content

Commit bc0fc24

Browse files
committed
Upgraded SDK
1 parent b630765 commit bc0fc24

File tree

6 files changed

+272
-19
lines changed

6 files changed

+272
-19
lines changed

go-libs/llnotes/gen.go

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package llnotes
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

8+
"github.com/databricks/databricks-sdk-go"
79
"github.com/databricks/databricks-sdk-go/client"
810
"github.com/databricks/databricks-sdk-go/config"
911
"github.com/databricks/databricks-sdk-go/listing"
1012
"github.com/databricks/databricks-sdk-go/logger"
13+
"github.com/databricks/databricks-sdk-go/service/serving"
1114
"github.com/databrickslabs/sandbox/go-libs/github"
1215
)
1316

@@ -18,7 +21,7 @@ type ChangeDetector struct {
1821
Model string
1922
}
2023

21-
func (c *ChangeDetector) Run(ctx context.Context) ([]any, error) {
24+
func (c *ChangeDetector) Run(ctx context.Context) ([]string, error) {
2225
versions, err := listing.ToSlice(ctx, c.GitHub.Versions(ctx, c.Org, c.Repo))
2326
if err != nil {
2427
return nil, fmt.Errorf("versions: %w", err)
@@ -39,11 +42,39 @@ func (c *ChangeDetector) Run(ctx context.Context) ([]any, error) {
3942
if c.Model == "" {
4043
c.Model = "databricks-mixtral-8x7b-instruct"
4144
}
42-
client, err := client.New(c.Databricks)
45+
return c.tryChat2(ctx, commits)
46+
}
47+
48+
func (c *ChangeDetector) tryChat2(ctx context.Context, commits []github.RepositoryCommit) ([]string, error) {
49+
w, err := databricks.NewWorkspaceClient((*databricks.Config)(c.Databricks))
4350
if err != nil {
44-
return nil, fmt.Errorf("databricks client: %w", err)
51+
return nil, err
52+
}
53+
x := []string{}
54+
for _, c := range commits {
55+
x = append(x, c.Commit.Message)
56+
}
57+
response, err := w.ServingEndpoints.Query(ctx, serving.QueryEndpointInput{
58+
Name: c.Model,
59+
Messages: []serving.ChatMessage{
60+
{
61+
Role: "system",
62+
Content: blogPrompt,
63+
},
64+
{
65+
Role: "user",
66+
Content: strings.Join(x, "\n"),
67+
},
68+
},
69+
})
70+
if err != nil {
71+
return nil, err
72+
}
73+
out := []string{}
74+
for _, v := range response.Choices {
75+
out = append(out, v.Message.Content)
4576
}
46-
return []any{}, c.tryChat(ctx, client, commits)
77+
return out, nil
4778
}
4879

4980
func (c *ChangeDetector) tryChat(ctx context.Context, client *client.DatabricksClient, commits []github.RepositoryCommit) error {

go-libs/llnotes/prompts.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package llnotes
2+
3+
const prPrompt = `You are a staff software engineer, and you are reviewing code in a pull request. If new methods are added, explain what these methods are doing.
4+
If this pull request has changes to tests, give a summary of scenarios that are tested. Please summarize this pull request in one paragraph.
5+
Changes related to tests should be in a separate paragraph.`
6+
7+
const blogPrompt = `SYSTEM:
8+
You are professional technical writer and you receive draft release notes for v0.11.0 of project called UCX by Databricks Labs in a markdown format from multiple team members. ucx project can be described as "Your best companion for upgrading to Unity Catalog. UCX will guide you, the Databricks customer, through the process of upgrading your account, groups, workspaces, jobs etc. to Unity Catalog."
9+
10+
You write a long post announcement that takes 5 minutes to read, summarize the most important features, and mention them on top. Keep the markdown links when relevant.
11+
Do not use headings. Write fluent paragraphs, that are at least few sentences long. Blog post title should nicely summarize the feature increments of this release.
12+
13+
Don't abuse lists. paragraphs should have at least 3-4 sentences. The title should be one-sentence summary of the incremental updates for this release
14+
15+
You aim at driving more adoption of the project on Medium.
16+
17+
USER:
18+
`

0 commit comments

Comments
 (0)