Skip to content

Commit

Permalink
feat: ✨ support workspaceFiles and expand file formats
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jan 7, 2025
1 parent 38e5e82 commit 2574ab0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/promptrunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ async function resolveExpansionVars(
const files: WorkspaceFile[] = []
const templateFiles = arrayify(template.files)
const referenceFiles = fragment.files.slice(0)
const workspaceFiles = fragment.workspaceFiles?.slice(0) || []
const filenames = await expandFiles(
referenceFiles?.length ? referenceFiles : templateFiles
referenceFiles.length || workspaceFiles.length
? referenceFiles
: templateFiles
)
for (let filename of filenames) {
filename = relativePath(root, filename)
Expand All @@ -53,8 +56,8 @@ async function resolveExpansionVars(
files.push(file)
}

if (fragment.workspaceFiles?.length)
for (const wf of fragment.workspaceFiles) {
if (workspaceFiles.length)
for (const wf of workspaceFiles) {
if (!files.find((f) => f.filename === wf.filename)) {
await resolveFileContent(wf)
files.push(wf)
Expand Down
3 changes: 2 additions & 1 deletion packages/sample/genaisrc/summarize.genai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ script({
title: "summarize all files",
model: "small",
files: "src/rag/markdown.md",
accept: ".txt,.pdf,.md,.ts,.prompty",
tests: [
{
files: "src/rag/markdown.md",
Expand All @@ -13,7 +14,7 @@ script({
def("FILE", env.files)

$`
Summarize all files in FILE in a single paragraph.
Summarize the content in <FILE> in a single paragraph.
- Keep it short.
- At most 3 paragraphs.
- Consider all files at once, do NOT summarize files individually.
Expand Down

0 comments on commit 2574ab0

Please sign in to comment.