Skip to content

Commit

Permalink
Merge branch 'canary' into zce/remove-debug-log
Browse files Browse the repository at this point in the history
  • Loading branch information
zce authored Sep 6, 2024
2 parents 61aa15d + a5f30e6 commit 1f41402
Show file tree
Hide file tree
Showing 516 changed files with 10,142 additions and 5,000 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
CARGO_WORKSPACE_DIR = { value = "", relative = true }
TURBO_PNPM_WORKSPACE_DIR = { value = "", relative = true }

[alias]
xtask = "run --package xtask --"

[build]
rustflags = [
"--cfg",
Expand Down

Large diffs are not rendered by default.

229 changes: 0 additions & 229 deletions .github/actions/next-repo-actions/lib/types.ts

This file was deleted.

4 changes: 2 additions & 2 deletions .github/actions/next-repo-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/github": "6.0.0",
"@ai-sdk/openai": "^0.0.54",
"@ai-sdk/openai": "^0.0.55",
"@slack/web-api": "^7.3.4",
"ai": "^3.3.19",
"ai": "^3.3.26",
"slack-block-builder": "^2.8.0",
"zod": "^3.23.8"
},
Expand Down
35 changes: 17 additions & 18 deletions .github/actions/next-repo-actions/src/triage-issues-with-ai.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { WebClient } from '@slack/web-api'
import { info, setFailed } from '@actions/core'
import { context } from '@actions/github'
import { generateText, tool } from 'ai'
import { generateObject } from 'ai'
import { openai } from '@ai-sdk/openai'
import { z } from 'zod'
import { BlockCollection, Divider, Section } from 'slack-block-builder'

import { getLatestCanaryVersion, getLatestVersion } from '../lib/util.mjs'
import { issueSchema } from '../lib/types'

async function main() {
if (!process.env.OPENAI_API_KEY) throw new TypeError('OPENAI_API_KEY not set')
Expand All @@ -19,9 +19,6 @@ async function main() {
const channel = '#next-info'

const issue = context.payload.issue
const html_url = issue.html_url
const number = issue.number
const title = issue.title

let latestVersion: string
let latestCanaryVersion: string
Expand All @@ -42,15 +39,17 @@ async function main() {

const guidelines = await res.text()

const result = await generateText({
const {
object: { explanation, isSevere, number, title, url },
} = await generateObject({
model: openai(model),
maxToolRoundtrips: 1,
tools: {
report_to_slack: tool({
description: 'Report to Slack.',
parameters: issueSchema,
}),
},
schema: z.object({
explanation: z.string().describe('The explanation of the severity.'),
isSevere: z.boolean().describe('Whether the issue is severe.'),
number: z.number().describe('The issue number.'),
title: z.string().describe('The issue title.'),
url: z.string().describe('The issue URL.'),
}),
system:
'Your job is to determine the severity of a GitHub issue using the triage guidelines and the latest versions of Next.js. Succinctly explain why you chose the severity, without paraphrasing the triage guidelines. Report to Slack the explanation only if the severity is considered severe.',
prompt:
Expand All @@ -61,14 +60,14 @@ async function main() {
})

// the ai determined that the issue was severe enough to report on slack
if (result.roundtrips.length > 1) {
if (isSevere) {
const blocks = BlockCollection([
Section({
text: `:github2: <${html_url}|#${number}>: ${title}\n_Note: This issue was evaluated and reported on Slack with *${model}*._`,
text: `:github2: <${url}|#${number}>: ${title}\n_Note: This issue was evaluated and reported on Slack with *${model}*._`,
}),
Divider(),
Section({
text: `_${result.text}_`,
text: `_${explanation}_`,
}),
])

Expand All @@ -79,12 +78,12 @@ async function main() {
username: 'GitHub Notifier',
})

info('Posted to Slack!')
info('Reported to Slack!')
}

// the ai will also provide a reason why the issue was not severe enough to report on slack
info(
`result.text: ${result.text}\nhtml_url: ${html_url}\nnumber: ${number}\ntitle: ${title}`
`Explanation: ${explanation}\nhtml_url: ${url}\nnumber: ${number}\ntitle: ${title}`
)
} catch (error) {
setFailed(error)
Expand Down
Loading

0 comments on commit 1f41402

Please sign in to comment.