mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-31 09:23:54 +00:00
Simplified the preprocessing interface.
This commit is contained in:
parent
1eeba2cc8a
commit
ad4cf97604
8 changed files with 31 additions and 43 deletions
|
|
@ -45,7 +45,6 @@ from llama_stack.apis.preprocessing import (
|
|||
Preprocessing,
|
||||
PreprocessingDataElement,
|
||||
PreprocessorChain,
|
||||
PreprocessorOptions,
|
||||
PreprocessorResponse,
|
||||
)
|
||||
from llama_stack.apis.safety import RunShieldResponse, Safety
|
||||
|
|
@ -714,22 +713,6 @@ class PreprocessingRouter(Preprocessing):
|
|||
pass
|
||||
|
||||
async def preprocess(
|
||||
self,
|
||||
preprocessor_id: str,
|
||||
preprocessor_inputs: List[PreprocessingDataElement],
|
||||
options: Optional[PreprocessorOptions] = None,
|
||||
) -> PreprocessorResponse:
|
||||
logcat.debug(
|
||||
"core",
|
||||
f"PreprocessingRouter.preprocess: {preprocessor_id}, {len(preprocessor_inputs)} inputs, options={options}",
|
||||
)
|
||||
return await self.routing_table.get_provider_impl(preprocessor_id).preprocess(
|
||||
preprocessor_id=preprocessor_id,
|
||||
preprocessor_inputs=preprocessor_inputs,
|
||||
options=options,
|
||||
)
|
||||
|
||||
async def chain_preprocess(
|
||||
self,
|
||||
preprocessors: PreprocessorChain,
|
||||
preprocessor_inputs: List[PreprocessingDataElement],
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ from itertools import pairwise
|
|||
from typing import List
|
||||
|
||||
from llama_stack.apis.preprocessing import (
|
||||
Preprocessing,
|
||||
PreprocessingDataElement,
|
||||
PreprocessorChain,
|
||||
PreprocessorResponse,
|
||||
)
|
||||
from llama_stack.providers.datatypes import PreprocessorsProtocolPrivate
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def validate_chain(chain_impls: List[Preprocessing]) -> bool:
|
||||
def validate_chain(chain_impls: List[PreprocessorsProtocolPrivate]) -> bool:
|
||||
if len(chain_impls) == 0:
|
||||
log.error("Empty preprocessing chain was provided")
|
||||
return False
|
||||
|
|
@ -37,7 +37,7 @@ def validate_chain(chain_impls: List[Preprocessing]) -> bool:
|
|||
|
||||
async def execute_preprocessor_chain(
|
||||
preprocessor_chain: PreprocessorChain,
|
||||
preprocessor_chain_impls: List[Preprocessing],
|
||||
preprocessor_chain_impls: List[PreprocessorsProtocolPrivate],
|
||||
preprocessor_inputs: List[PreprocessingDataElement],
|
||||
) -> PreprocessorResponse:
|
||||
if not validate_chain(preprocessor_chain_impls):
|
||||
|
|
@ -50,7 +50,7 @@ async def execute_preprocessor_chain(
|
|||
# TODO: replace with a parallel implementation
|
||||
for i, current_params in enumerate(preprocessor_chain):
|
||||
current_impl = preprocessor_chain_impls[i]
|
||||
response = await current_impl.preprocess(
|
||||
response = await current_impl.do_preprocess(
|
||||
preprocessor_id=current_params.preprocessor_id,
|
||||
preprocessor_inputs=current_inputs,
|
||||
options=current_params.options,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue