Rust SDK for QWED Verification Protocol
Add to your Cargo.toml:
[dependencies]
qwed = "5.3.0"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }use qwed::QWEDClient;
#[tokio::main]
async fn main() -> Result<(), qwed::Error> {
let client = QWEDClient::new("qwed_your_api_key");
let result = client.verify("What is 2+2?").await?;
println!("Verified: {}", result.verified); // true
println!("Status: {:?}", result.status); // Verified
Ok(())
}let result = client.verify("Is 15% of 200 equal to 30?").await?;let result = client.verify_math("x**2 + 2*x + 1 = (x+1)**2").await?;let result = client.verify_logic("(AND (GT x 5) (LT y 10))").await?;
// result.result["satisfiability"] = "SAT"let result = client.verify_code(r#"
import os
os.system('rm -rf /')
"#, "python").await?;let result = client.verify_fact(
"Paris is the capital of France",
"France is a country in Europe. Its capital city is Paris.",
).await?;let result = client.verify_sql(
"SELECT * FROM users WHERE id = 1",
"CREATE TABLE users (id INT PRIMARY KEY, name TEXT)",
"postgresql",
).await?;use qwed::{BatchItem, VerificationType};
let items = vec![
BatchItem { query: "2+2=4".into(), r#type: Some(VerificationType::Math) },
BatchItem { query: "3*3=9".into(), r#type: Some(VerificationType::Math) },
];
let result = client.verify_batch(items).await?;
if let Some(summary) = result.summary {
println!("Success rate: {:.1}%", summary.success_rate);
}use std::time::Duration;
let client = QWEDClient::with_options(
"qwed_...",
"https://api.qwed.ai",
Duration::from_secs(60),
);use qwed::{QWEDClient, Error};
match client.verify("test").await {
Ok(result) => println!("Verified: {}", result.verified),
Err(Error::Auth) => eprintln!("Invalid API key"),
Err(Error::RateLimit) => eprintln!("Rate limit exceeded"),
Err(Error::Api { code, message }) => eprintln!("Error {}: {}", code, message),
Err(e) => eprintln!("Error: {}", e),
}| Type | Description |
|---|---|
VerificationType |
Enum: Math, Logic, Stats, Fact, Code, Sql, etc. |
VerificationStatus |
Enum: Verified, Failed, Corrected, Blocked, etc. |
VerificationResponse |
Full verification result |
BatchResponse |
Batch operation result |
Error |
Error enum with Auth, RateLimit, Api variants |
This crate requires tokio as the async runtime:
#[tokio::main]
async fn main() {
// ...
}Apache 2.0