Skip to content

Commit

Permalink
fix: use isomorphic-fetch to fix read_page in non-pyodide environ…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
CNSeniorious000 committed Nov 9, 2024
1 parent 6d81a89 commit 9843141
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"pyyaml~=6.0.1",
"html-text~=0.6.2",
"html2text2~=1.0.0",
"isomorphic-fetch~=0.0.0.0.dev2",
]

[build-system]
Expand Down
10 changes: 4 additions & 6 deletions reasonify-headless/reasonify/tools/fetch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Literal

from pyodide.http import pyfetch
from isomorphic_fetch import fetch

from ..utils.html import Strategy, post_process, pre_process
from ..utils.tool import tool
Expand Down Expand Up @@ -30,10 +30,8 @@ async def read_page(url: str, parse_as: Literal["innerText", "plain", "markdown"

async def _fetch(url: str, strategy: Strategy):
try:
res = await pyfetch(url)
res = await fetch(url)
except OSError:
res = await pyfetch(f"/api/proxy?url={url}")
res = await fetch(f"/api/proxy?url={url}")

content = await res.text()

return res.status, post_process(pre_process(content, strategy))
return res.status, post_process(pre_process(res.text, strategy))
2 changes: 1 addition & 1 deletion reasonify-headless/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.2"
__version__ = "0.2.3"

1 comment on commit 9843141

@vercel
Copy link

@vercel vercel bot commented on 9843141 Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

reasonify – ./

reasonify-git-main-promplate.vercel.app
reasonify-promplate.vercel.app
reasonify.vercel.app

Please sign in to comment.