Skip to content

Commit

Permalink
feat(lib): filepath can use env variable replace now in file.ai
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Aug 18, 2024
1 parent 9aa2db5 commit a8b7924
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/file.ai.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: 0.1.0
type: lib
description: "the file loader used in prompt. eg, 'user: summary the following file content: @file(document.md)'"
description: "the simple text file loader used in prompt. eg, `user: summary the following file content: @file(document.md)`"
tag:
- file
- loader
Expand All @@ -17,7 +17,8 @@ output:
const fs = await import('fs');
const path = await import('path');
const filename = path.basename(this.result);
const content = fs.readFileSync(this.result, 'utf8');
const filepath = expandPath(this.result)
const content = fs.readFileSync(filepath, 'utf8');
return `filename: ${filename}\nfile content:\n${content}`
}
$loadFile

0 comments on commit a8b7924

Please sign in to comment.