Skip to content

Commit 95a3369

Browse files
feat: remove pollution from httpx
1 parent 5169152 commit 95a3369

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "promplate-pyodide"
3-
version = "0.0.3.5"
3+
version = "0.0.4"
44
description = "patches for promplate-core for running in pyodide runtime"
55
authors = [{ name = "Muspi Merol", email = "[email protected]" }]
66
dependencies = ["promplate>=0.3.3.4,<0.4"]

src/promplate_pyodide/__init__.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,9 @@ async def patch_openai(fallback_import_url: str = "https://esm.sh/openai"):
9595

9696

9797
def patch_httpx():
98-
with suppress(ModuleNotFoundError):
99-
import httpx # noqa: F401
100-
101-
return
102-
103-
from pyodide.code import run_js
104-
from pyodide.ffi import register_js_module
98+
import promplate.llm.openai.v1 as o
10599

106-
register_js_module("httpx", run_js("({ Client() { return null }, AsyncClient() { return null } })"))
100+
o._get_client = o._get_aclient = lambda: None # type: ignore
107101

108102

109103
async def patch_all():

src/promplate_pyodide/utils/check.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def is_fake_openai():
88

99

1010
def is_fake_httpx():
11-
import httpx
12-
13-
return isinstance(httpx, JsProxy)
11+
try:
12+
import httpx
13+
except ModuleNotFoundError:
14+
return True
15+
else:
16+
return isinstance(httpx, JsProxy)

0 commit comments

Comments
 (0)