mirror of
https://github.com/0xMassi/webclaw.git
synced 2026-05-13 17:02:36 +02:00
chore: rebrand webclaw to noxa
This commit is contained in:
parent
a4c351d5ae
commit
8674b60b4e
86 changed files with 781 additions and 2121 deletions
|
|
@ -1,48 +0,0 @@
|
|||
/// Shared test utilities for webclaw-llm.
|
||||
///
|
||||
/// Provides a configurable mock LLM provider for unit tests across
|
||||
/// extract, chain, and other modules that need a fake LLM backend.
|
||||
#[cfg(test)]
|
||||
pub(crate) mod mock {
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::error::LlmError;
|
||||
use crate::provider::{CompletionRequest, LlmProvider};
|
||||
|
||||
/// A mock LLM provider that returns a canned response or error.
|
||||
/// Covers the common test cases: success, failure, and availability.
|
||||
pub struct MockProvider {
|
||||
pub name: &'static str,
|
||||
pub response: Result<String, String>,
|
||||
pub available: bool,
|
||||
}
|
||||
|
||||
impl MockProvider {
|
||||
/// Shorthand for a mock that always succeeds with the given response.
|
||||
pub fn ok(response: &str) -> Self {
|
||||
Self {
|
||||
name: "mock",
|
||||
response: Ok(response.to_string()),
|
||||
available: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl LlmProvider for MockProvider {
|
||||
async fn complete(&self, _request: &CompletionRequest) -> Result<String, LlmError> {
|
||||
match &self.response {
|
||||
Ok(text) => Ok(text.clone()),
|
||||
Err(msg) => Err(LlmError::ProviderError(msg.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
async fn is_available(&self) -> bool {
|
||||
self.available
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
self.name
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue