use serde_json::{Map, Value};
use super::{embedding, llm, onnx, prompt, rerank, triton};
use crate::core::configs::op_config::{OpConfig, OpType};
use crate::core::exceptions::OperonError;
pub fn is_provider_kind(kind: OpType) -> bool {
matches!(
kind,
OpType::Llm
| OpType::Embedding
| OpType::Rerank
| OpType::Prompt
| OpType::Onnx
| OpType::Triton
)
}
pub async fn execute_provider_op(
op: &OpConfig,
inputs: Map<String, Value>,
) -> Result<Value, OperonError> {
match op.kind {
OpType::Llm => llm::execute(op, inputs).await,
OpType::Embedding => embedding::execute(op, inputs).await,
OpType::Rerank => rerank::execute(op, inputs).await,
OpType::Prompt => prompt::execute(inputs).await,
OpType::Onnx => onnx::execute(op, inputs).await,
OpType::Triton => triton::execute(op, inputs).await,
other => Err(OperonError::Runtime(format!(
"execute_provider_op: op type {:?} is not a provider op ({})",
other, op.full_name
))),
}
}