Skip to content

Commit

Permalink
feat(lib): add url lib
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Sep 2, 2024
1 parent ac2d942 commit e748836
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/url.ai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
version: 0.1.0
type: lib
description: |-
the simple fetch web page content from url.
It can be used in prompt. eg, `user: "think about the following web content: @url(https://www.example.com)"`
tag:
- url
- loader
- prompt
- lib
input:
- 0 # The url passed by the prompt(position argument)
- content # The url passed by the prompt
- onlyContent: {type: "boolean"} # Only return the content
output: # the web page content
type: "string"
---
!fn |-
async function loadUrl() {
let url = this.content || this[0]
const content = await fetch(url).then(res => res.text())
return `web url: ${url}\nweb content:\n${content}`
}
$loadUrl

0 comments on commit e748836

Please sign in to comment.