Skip to content

Commit

Permalink
Add PR descriptor script for automated pull request descriptions📄✨ (#764
Browse files Browse the repository at this point in the history
)

* Add PR descriptor script for generating pull request descriptions 📄✨

* Refactor script and format pull request description 📝

* Update PR generation script to include changes in the current branch 🚀

* Add task planning instruction to PR description script 📝

* Update prompts, cost rendering, and add brevity instruction 📝💰
  • Loading branch information
pelikhan authored Oct 9, 2024
1 parent c2b059a commit 085e70b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/runpromptcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ export function createChatGenerationContext(
async (_) => {
if (typeof fn === "string") _.writeText(dedent(fn))
else await fn(_, args)
_.$`- Assume that your answer will be analyzed by an LLM, not a human.
_.$`Make a plan and solve this task.
- Assume that your answer will be analyzed by an LLM, not a human.
- If you are missing information, reply "MISSING_INFO: <what is missing>".
- If you cannot answer the query, return "NO_ANSWER: <reason>".
- Be concise. Minimize output to the most relevant information to save context tokens.`
Expand Down
11 changes: 6 additions & 5 deletions packages/core/src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ export function estimateCost(modelId: string, usage: ChatCompletionUsage) {
}

export function renderCost(value: number) {
return value !== undefined
? value <= 0.1
? `${(value * 100).toFixed(2)}¢`
: `${value.toFixed(2)}$`
: ""
if (isNaN(value)) return ""
return value <= 0.01
? `${(value * 100).toFixed(3)}¢`
: value <= 0.1
? `${(value * 100).toFixed(2)}¢`
: `${value.toFixed(2)}$`
}

export class GenerationStats {
Expand Down
4 changes: 4 additions & 0 deletions packages/sample/genaisrc/prd-min.genai.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
script({ tools: ["agent_fs", "agent_git"] })

$`Generate a pull request description for the changes in the current branch.
Make a plan and solve this task. Keep it short.`

0 comments on commit 085e70b

Please sign in to comment.