mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
Allow async js fn (#1439)
* updated PyPi version to 3.0.10 * updated PyPi version to 3.0.9b10 * fixes * updated PyPi version to 3.0.9b11 * fix update sript * changes
This commit is contained in:
parent
279df2322d
commit
188d8bc65d
@ -1,6 +1,6 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: gradio
|
||||
Version: 3.0.9
|
||||
Version: 3.0.9b11
|
||||
Summary: Python library for easily interacting with trained machine learning models
|
||||
Home-page: https://github.com/gradio-app/gradio
|
||||
Author: Abubakar Abid, Ali Abid, Ali Abdalla, Dawood Khan, Ahsen Khaliq, Pete Allen, Ömer Faruk Özdemir
|
||||
|
@ -1 +1 @@
|
||||
3.0.9
|
||||
3.0.9b11
|
2
setup.py
2
setup.py
@ -9,7 +9,7 @@ long_description = (this_directory / "README.md").read_text(encoding='utf8')
|
||||
|
||||
setup(
|
||||
name="gradio",
|
||||
version="3.0.9",
|
||||
version="3.0.9b11",
|
||||
include_package_data=True,
|
||||
description="Python library for easily interacting with trained machine learning models",
|
||||
long_description=long_description,
|
||||
|
@ -62,12 +62,14 @@
|
||||
let rootNode: Component = { id: layout.id, type: "column", props: {} };
|
||||
components.push(rootNode);
|
||||
|
||||
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
||||
dependencies.forEach((d) => {
|
||||
if (d.js) {
|
||||
try {
|
||||
d.frontend_fn = new Function(
|
||||
d.frontend_fn = new AsyncFunction(
|
||||
"__fn_args",
|
||||
`return ${d.outputs.length} === 1 ? [(${d.js})(...__fn_args)] : (${d.js})(...__fn_args)`
|
||||
`let result = await (${d.js})(...__fn_args);
|
||||
return ${d.outputs.length} === 1 ? [result] : result;`
|
||||
);
|
||||
} catch (e) {
|
||||
console.error("Could not parse custom js method.");
|
||||
|
@ -68,8 +68,9 @@ export const fn = async (
|
||||
) => {
|
||||
const fn_index = payload.fn_index;
|
||||
|
||||
console.log(">", frontend_fn);
|
||||
if (frontend_fn !== undefined) {
|
||||
payload.data = frontend_fn(payload.data.concat(output_data));
|
||||
payload.data = await frontend_fn(payload.data.concat(output_data));
|
||||
}
|
||||
if (backend_fn == false) {
|
||||
return payload;
|
||||
|
Loading…
Reference in New Issue
Block a user