Implementation:1jehuang Jcode JevClient
| Knowledge Sources | |
|---|---|
| Domains | LLM_Applications, Decision_Systems |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete tool for making typed Decisions API calls to classify state into typed answers through multiple provider routes, provided by the jcode base crate.
Description
The JevClient struct is the transport for jcode's typed Decisions API. It resolves a provider (Jcode subscription, Typesafe, OpenRouter, or AIMLAPI) based on environment variables and credential availability, then sends bounded POST requests with typed questions (noul, choice, score) and validates the returned answers. The client supports three purposes: Memory (recall relevance), Browser (action selection), and Voice (intent classification), each with independent provider routing.
Key design properties: credentials are isolated per provider (no cross-account fallback on failure), request size is bounded (80 KiB), response size is bounded (256 KiB), transient overload responses (429/502/503/504/529) are retried with bounded backoff, and auth/billing/redirect errors never retry. The Jcode subscription provider checks live entitlement via GET /me before each evaluation.
Usage
- Memory recall:
JevClient::new()creates a memory-purpose client. - Browser handoff:
JevClient::for_browser()creates a browser-purpose client (separate gateway budget). - Voice intent:
JevClient::for_voice()creates a voice-purpose client (hedged requests). - Availability check:
JevClient::available()checks if a credential route exists.
Code Reference
Source Location
- Repository: jcode
- File: crates/jcode-base/src/jev.rs
Signature
pub struct JevClient { /* private fields */ }
impl JevClient {
pub fn available() -> bool
pub fn new() -> Result<Self>
pub fn for_browser() -> Result<Self>
pub fn for_voice() -> Result<Self>
pub fn provider_name(&self) -> &str
pub fn model_id(&self) -> &str
pub(crate) fn max_questions(&self) -> usize
pub async fn evaluate(
&self,
state: Value,
questions: Map<String, Value>,
) -> Result<Value>
}
// Provider selection env vars:
// JCODE_MEMORY_JEV_PROVIDER (default: "auto" or config)
// JCODE_BROWSER_JEV_PROVIDER (default: "auto")
// JCODE_VOICE_JEV_PROVIDER (default: "auto")
Import
use jcode_base::jev::JevClient;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| state | Value | Yes | Text, object, or array describing the classification context |
| questions | Map<String, Value> | Yes | 1-24 typed questions (noul/choice/score) |
| JCODE_MEMORY_JEV_PROVIDER | env | No /// Provider: auto, jcode, typesafe, openrouter, aimlapi |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Result<Value> | Full typed Decisions response with answers and usage |
| answers | Map | One answer per question, type-matched, with noul probability or choice selection |
Usage Examples
Memory Relevance Scoring
use jcode_base::jev::JevClient;
use serde_json::{json, Map};
let client = JevClient::new()?;
let questions = json!({
"m0": {
"type": "noul",
"instructions": "Is this memory relevant to the query?",
"criteria": {"true": "Useful", "false": "Irrelevant"}
}
}).as_object().unwrap().clone();
let response = client.evaluate(
json!("How do I configure authentication?"),
questions,
).await?;
let prob = response["answers"]["m0"]["noul"].as_f64().unwrap();
println!("Relevance: {}", prob);
Browser Action Selection
let client = JevClient::for_browser()?;
let questions = json!({
"action": {
"type": "choice",
"instructions": "Choose the next browser action",
"criteria": {
"click": "Click the submit button",
"type": "Type into the form field",
"stop": "Return control to main agent"
}
}
}).as_object().unwrap().clone();
let response = client.evaluate(
json!({"page": page_state}),
questions,
).await?;
let action = response["answers"]["action"]["choice"].as_str().unwrap();
Related Pages
Implements Principle
- Principle:1jehuang_Jcode_Jev_Typed_Decisions
- Principle:1jehuang_Jcode_Browser_Task_Handoff
- Principle:1jehuang_Jcode_Memory_Recall_Without_Embeddings