Skip to content

Commit

Permalink
feat(lib): add the file loader lib used in prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Aug 14, 2024
1 parent 0b27ca2 commit c4adec7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/file.ai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
type: lib
description: the file loader used in prompt
tag:
- file
- loader
- prompt
- lib
input:
- result: {required: true} # the file path
output:
type: "string"
---
!fn |-
async function loadFile() {
const fs = await import('fs');
const path = await import('path');
const filename = path.basename(this.result);
const content = fs.readFileSync(this.result, 'utf8');
return `filename: ${filename}\nfile content:\n${content}`
}
$loadFile

0 comments on commit c4adec7

Please sign in to comment.