Merge pull request #795 from gradio-app/blocks-hotfix

fixed predict body issue
This commit is contained in:
Abubakar Abid 2022-03-08 20:04:03 -06:00 committed by GitHub
commit 523bbfc9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple
from gradio import utils
from gradio.context import Context
from gradio.launchable import Launchable
from gradio.routes import PredictBody
class Block:
@ -81,9 +82,9 @@ class Blocks(Launchable, BlockContext):
self.fns = []
self.dependencies = []
def process_api(self, data: Dict[str, Any], username: str = None) -> Dict[str, Any]:
raw_input = data["data"]
fn_index = data["fn_index"]
def process_api(self, data: PredictBody, username: str = None) -> Dict[str, Any]:
raw_input = data.data
fn_index = data.fn_index
fn = self.fns[fn_index]
dependency = self.dependencies[fn_index]

View File

@ -71,6 +71,7 @@ class PredictBody(BaseModel):
example_id: Optional[int]
data: List[Any]
state: Optional[Any]
fn_index: Optional[int]
class FlagData(BaseModel):