Skip to content

Commit

Permalink
update generated_by comment with code (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 12, 2024
1 parent b86c656 commit 09d5d7d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
34 changes: 34 additions & 0 deletions demo/genaisrc/az-poetry.genai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
defTool("search_files", "search files in the workspace", {
type: "object",
properties: {
search: {
type: "string",
description: "Search string using glob patterns"
}
}
}, async args => {
const { search} = args
const files = await workspace.findFiles(search)
return files.map(f => f.filename).join("\n")
})
defTool("read_file", "read the content of a file", {
type: "object",
properties: {
file: {
type: "string",
description: "File path"
}
}
}, async args => {
const { file } = args
const content = await workspace.readText(file)
return content.content
})

$`You are an expert at Azure Bicep and development of azure resources.
Generate a state graph of all recursively the .bicep files used in the workspace.Use mermaid.
- use more emojis
`

10 changes: 7 additions & 3 deletions packages/core/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ export async function githubUpdatePullRequestDescription(
return r
}

function generatedByFooter(script: PromptScript, info: GithubConnectionInfo) {
return `\n\n> generated by ${link(script.id, info.runUrl)}\n\n`
function generatedByFooter(
script: PromptScript,
info: GithubConnectionInfo,
code?: string
) {
return `\n\n> generated by ${link(script.id, info.runUrl)}${code ? ` \`${code}\` ` : ""}\n\n`
}

function appendGeneratedComment(
Expand All @@ -138,7 +142,7 @@ function appendGeneratedComment(
return prettifyMarkdown(
`<!-- genaiscript ${severity} ${code || ""} -->
${message}
${generatedByFooter(script, info)}`
${generatedByFooter(script, info, code)}`
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sample/genaisrc/pr-describe.genai.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script({
model: "openai:gpt-4",
model: "openai:gpt-4-32k",
files: [],
title: "pr-describe",
system: ["system", "system.fs_find_files", "system.fs_read_file"],
Expand Down
2 changes: 1 addition & 1 deletion packages/sample/genaisrc/pr-review-commit.genai.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script({
model: "openai:gpt-4",
model: "openai:gpt-4-32k",
files: [],
title: "pull request commit review",
system: [
Expand Down
2 changes: 1 addition & 1 deletion packages/sample/genaisrc/pr-review.genai.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script({
model: "openai:gpt-4",
model: "openai:gpt-4-32k",
files: [],
title: "pull request review",
system: ["system", "system.typescript"],
Expand Down

0 comments on commit 09d5d7d

Please sign in to comment.