use crate::llm::api::{DeltaSender, LlmRequestPayload, LlmResult};
use crate::llm::mock::mock_llm_response;
use crate::llm::provider::{LlmProvider, LlmProviderChat};
use crate::value::VmError;
pub(crate) struct MockProvider;
impl LlmProvider for MockProvider {
fn name(&self) -> &'static str {
"mock"
}
fn is_mock(&self) -> bool {
true
}
fn requires_model(&self) -> bool {
false
}
}
impl LlmProviderChat for MockProvider {
fn chat<'a>(
&'a self,
request: &'a LlmRequestPayload,
delta_tx: Option<DeltaSender>,
) -> crate::llm::provider::ProviderChatFuture<'a> {
Box::pin(self.chat_impl(request, delta_tx))
}
}
impl MockProvider {
pub(crate) fn should_intercept(provider: &str) -> bool {
provider == "mock" || Self::fixture_active(crate::llm::mock::current_cli_llm_mock_scope())
}
pub(crate) fn should_intercept_request(request: &LlmRequestPayload) -> bool {
request.provider == "mock" || Self::fixture_active(request.cli_llm_mock_scope)
}
pub(crate) fn fixture_active(scope: Option<u64>) -> bool {
crate::llm::mock::cli_llm_mock_replay_active_for_scope(scope)
|| crate::llm::mock::builtin_llm_mock_active()
}
pub(crate) async fn chat_impl(
&self,
request: &LlmRequestPayload,
_delta_tx: Option<DeltaSender>,
) -> Result<LlmResult, VmError> {
mock_llm_response(request)
}
}