Skip to content

Commit

Permalink
feat(lib): add onlyContent to load file lib
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Aug 29, 2024
1 parent 5ccd88b commit 2fa68ef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/file.ai.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 0.1.0
version: 0.2.0
type: lib
description: |-
the simple text file loader. You can use environment variables in file path, eg, "$HOME/documents/document.md".
Expand All @@ -11,7 +11,8 @@ tag:
- prompt
- lib
input:
- content: {required: true} # The file path passed by the prompt
- content: {required: true} # The file path passed by the prompt
- onlyContent: {type: "boolean"} # Only return the content
output: # the file content
type: "string"
---
Expand All @@ -22,6 +23,7 @@ output: # the file content
const filename = path.basename(this.content);
const filepath = expandPath(this.content)
const content = fs.readFileSync(filepath, 'utf8');
if (this.onlyContent) return content;
return `filename: ${filename}\nfile content:\n${content}`
}
$loadFile

0 comments on commit 2fa68ef

Please sign in to comment.