Skip to content

API Reference parrot.clients.jev.client

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.clients.jev.client

View source

TypeSafe AI System One client (Jev) for AI-Parrot.

Jev is a System One model: it does not generate text. A request carries state (a string or JSON document) plus a map of typed questions (:class:~parrot.clients.jev.models.Noul, :class:~parrot.clients.jev.models.Choice, :class:~parrot.clients.jev.models.Score); the model answers every question in one parallel pass and returns structured answers with calibrated probabilities. There is no streaming, no tool calling and no free text.

This client maps that contract onto :class:~parrot.clients.base.AbstractClient:

  • :meth:JevClient.system_one is the raw API call (POST {base_url}/v1/systemone) and returns a :class:~parrot.clients.jev.models.SystemOneResponse.
  • :meth:JevClient.ask treats the prompt (plus optional system_prompt and rendered history) as the state; the questions come from the questions= kwarg, a Pydantic structured_output type, or the questions= configured at construction. It returns an AIMessage whose output / structured_output is the typed result.
  • :meth:JevClient.invoke derives the questions from output_type (see :mod:parrot.clients.jev.schema) and validates the answers back into it.
  • :meth:JevClient.ask_stream is a pseudo-stream (one text chunk, then the final AIMessage) so streaming consumers keep working.

No vendor SDK is used: the official typesafe-sdk is built on httpx2, which the codebase conventions forbid, so the wire protocol (Bearer auth, JSON body {"state", "model", "questions"}, retry-after handling and the status → error mapping) is implemented here over aiohttp with tenacity retries.

Alias AIMessage

Re-exported from parrot.models.AIMessage.

Alias AbstractClient

Re-exported from parrot.clients.base.AbstractClient.

Alias CompletionUsage

Re-exported from parrot.models.CompletionUsage.

Attribute DEFAULT_BASE_URL

Attribute DEFAULT_TIMEOUT

Alias HistoryMessage

Re-exported from parrot.memory.render.HistoryMessage.

Alias InvokeResult

Re-exported from parrot.models.responses.InvokeResult.

Alias JevAPIError

Re-exported from parrot.clients.jev.exceptions.JevAPIError.

Class JevClient

Client for TypeSafe AI's System One API (the Jev model).

Example::

client = JevClient()
response = await client.system_one(
    state={"document": "I was charged twice. Please fix this ASAP."},
    questions={
        "category": Choice(
            instructions="What is this ticket about?",
            criteria={"billing": None, "technical": None, "other": None},
        ),
    },
)
response.choices["category"].choice  # "billing"
Parameter Type Default Description
api_key Optional[str] None TypeSafe API key. Falls back to the TYPESAFE_API_KEY environment variable (resolved via navconfig.config). Checked lazily, on the first request.
base_url Optional[str] None API origin. Falls back to TYPESAFE_BASE_URL, then :data:DEFAULT_BASE_URL.
model Union[str, JevModel, None] None Model name or alias (see :class:JevModel). Falls back to TYPESAFE_DEFAULT_MODEL, then jev-latest. Versioned IDs such as jev-1.13.0 are accepted even when list_models() only lists the aliases.
timeout float DEFAULT_TIMEOUT Per-request timeout in seconds (default 10).
max_retries int 2 Retries after the initial attempt on 408/429/5xx and connection errors (default 2; 0 disables retries).
questions Optional[QuestionsInput] None Default question map used by :meth:ask when a call supplies neither questions= nor a structured output type.
noul_threshold float 0.5 Probability at or above which a noul answer becomes True when validated into a bool field (default 0.5).
**kwargs Any {} Forwarded to :class:~parrot.clients.base.AbstractClient.

Attributes:

Attribute Type Description
client_type str
client_name str
supports_tool_loop bool
provider_name str
provider_keys tuple[str, ...]
models type[Enum]
api_key Optional[str]
base_url str
timeout float
max_retries int
default_questions Optional[Dict[str, QuestionInput]]
noul_threshold float

Method JevClient.get_client

Build the per-event-loop aiohttp session.

Cached by :meth:~parrot.clients.base.AbstractClient._ensure_client and closed by :meth:~parrot.clients.base.AbstractClient.close.

get_client() -> aiohttp.ClientSession

Returns: aiohttp.ClientSession — A configured :class:aiohttp.ClientSession.

Method JevClient.system_one

Ask Jev a set of typed questions about state (POST /v1/systemone).

Jev accepts text only: a string, a JSON object, or an array of text values (pre-process images, audio or binaries into text first). The documented budget is 64k tokens for state plus all questions, and 32k for state plus the single longest question.

system_one(state: Any, questions: QuestionsInput, *, model: Union[str, JevModel, None] = None, extra_body: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None) -> SystemOneResponse

Parameter Type Default Description
state Any Text, a JSON object/array, or a Pydantic model describing the situation the questions are about.
questions QuestionsInput Questions keyed by the id their answers are returned under.
model Union[str, JevModel, None] None Model route; defaults to the configured model.
extra_body Optional[Mapping[str, Any]] None Extra top-level fields merged into the request body.
timeout Optional[float] None Per-call timeout override, in seconds.

Returns: SystemOneResponse — The parsed :class:SystemOneResponse.

Raises:

  • JevConfigurationError — Empty/invalid questions, bad state, no API key.
  • JevAPIError — Non-2xx response (see subclasses).
  • JevConnectionError — No HTTP response could be obtained.
  • JevError — The 2xx body did not match the response schema.

Method JevClient.list_models

List the models available to the account (GET /v1/models).

The API currently lists the aliases (jev-latest, jev-preview); versioned IDs such as jev-1.13.0 are accepted by the model field whether or not they appear here.

list_models(*, timeout: Optional[float] = None) -> List[ModelMetadata]

Parameter Type Default Description
timeout Optional[float] None Per-call timeout override, in seconds.

Returns: List[ModelMetadata] — class:ModelMetadata per model or alias.

Method JevClient.ask

Evaluate typed questions against the prompt and return an AIMessage.

The prompt is the state (see :meth:_build_state) unless state= is given explicitly. max_tokens, temperature, files, tools and use_tools exist for interface parity only — System One has no sampling, no generated tokens, no attachments and no tool loop.

ask(prompt: str, model: Union[str, JevModel, None] = None, max_tokens: Optional[int] = None, temperature: float = 0.0, files: Optional[List[Union[str, Path]]] = None, system_prompt: Optional[str] = None, history: Optional[Sequence[HistoryMessage]] = None, structured_output: Union[type, StructuredOutputConfig, None] = None, tools: Optional[List[Dict[str, Any]]] = None, use_tools: Optional[bool] = None, questions: Optional[QuestionsInput] = None, state: Any = None, **kwargs: Any) -> AIMessage

Parameter Type Default Description
prompt str The user input; becomes the state (or state["input"]).
model Union[str, JevModel, None] None Model route override.
max_tokens Optional[int] None Ignored (no generated output).
temperature float 0.0 Ignored (no sampling).
files Optional[List[Union[str, Path]]] None Ignored, with a warning.
system_prompt Optional[str] None Background instructions, sent as state["context"].
history Optional[Sequence[HistoryMessage]] None Rendered conversation history, sent as state["conversation"].
structured_output Union[type, StructuredOutputConfig, None] None A Pydantic model class (or :class:StructuredOutputConfig) whose fields define the questions; the answers are validated back into it.
tools Optional[List[Dict[str, Any]]] None Ignored, with a warning.
use_tools Optional[bool] None Ignored, with a warning.
questions Optional[QuestionsInput] None Explicit question map; takes precedence over structured_output and the constructor default.
state Any None Explicit state, replacing the prompt-derived one.
**kwargs Any {} Accepted for interface parity and ignored.

Returns: AIMessage — class:AIMessage with output / structured_output set to the validated structured_output instance (when given) or the class:SystemOneResponse, data set to the plain answer values, response set to their JSON rendering, and per-answer detail (probabilities, confidence) under metadata["answers"].

Method JevClient.ask_stream

Pseudo-stream: one text chunk (the JSON answer values) then the final AIMessage.

System One answers in a single pass, so there is nothing to stream incrementally; this keeps streaming consumers working unchanged.

ask_stream(prompt: str, model: Union[str, JevModel, None] = None, max_tokens: Optional[int] = None, temperature: float = 0.0, files: Optional[List[Union[str, Path]]] = None, system_prompt: Optional[str] = None, history: Optional[Sequence[HistoryMessage]] = None, tools: Optional[List[Dict[str, Any]]] = None, deep_research: bool = False, agent_config: Optional[Dict[str, Any]] = None, lazy_loading: bool = False, **kwargs: Any) -> AsyncIterator[Union[str, AIMessage]]

Parameter Type Default Description
prompt str See :meth:ask.
model Union[str, JevModel, None] None See :meth:ask.
max_tokens Optional[int] None Ignored.
temperature float 0.0 Ignored.
files Optional[List[Union[str, Path]]] None Ignored, with a warning.
system_prompt Optional[str] None See :meth:ask.
history Optional[Sequence[HistoryMessage]] None See :meth:ask.
tools Optional[List[Dict[str, Any]]] None Ignored, with a warning.
deep_research bool False Ignored.
agent_config Optional[Dict[str, Any]] None Ignored.
lazy_loading bool False Ignored.
**kwargs Any {} questions=, state= and structured_output= are forwarded to :meth:ask.

Returns: AsyncIterator[Union[str, AIMessage]]

Method JevClient.invoke

Stateless typed evaluation of prompt.

With output_type (a Pydantic model) the questions are derived from its fields and the answers validated back into an instance — the provider-native structured output of System One. Without one, questions= (or the constructor default) is used and output is the :class:SystemOneResponse.

Emits BeforeClientCallEvent before the System One request and exactly one terminal event: AfterClientCallEvent (tokens, duration, response.model, finish_reason="completed") when the request returns, or ClientCallFailedEvent when system_one raises. Errors while resolving questions or state (before the request) and parse errors (after it) emit no failed event.

invoke(prompt: str, *, output_type: Optional[type] = None, structured_output: Optional[StructuredOutputConfig] = None, model: Optional[str] = None, system_prompt: Optional[str] = None, max_tokens: Optional[int] = None, temperature: float = 0.0, use_tools: bool = False, tools: Optional[list] = None, questions: Optional[QuestionsInput] = None, state: Any = None) -> InvokeResult

Parameter Type Default Description
prompt str The state text (or state["input"] when system_prompt is set).
output_type Optional[type] None Pydantic model to derive questions from and parse into.
structured_output Optional[StructuredOutputConfig] None Explicit config; its output_type wins.
model Optional[str] None Model route override.
system_prompt Optional[str] None Background instructions sent as state["context"]. Unlike text LLM clients no default system prompt is injected.
max_tokens Optional[int] None Ignored (no generated output).
temperature float 0.0 Ignored (no sampling).
use_tools bool False Ignored.
tools Optional[list] None Ignored.
questions Optional[QuestionsInput] None Explicit question map (overrides output_type derivation).
state Any None Explicit state, replacing the prompt-derived one.

Returns: InvokeResult — class:InvokeResult; raw_response carries the full API response (answers with probabilities and confidence).

Raises:

  • InvokeError — Wrapping any failure (configuration, schema, API, transport).

Method JevClient.resume

Not supported: System One has no tool-calling loop to resume.

resume(session_id: str, user_input: str, state: Dict[str, Any]) -> MessageResponse

Parameter Type Default Description
session_id str
user_input str
state Dict[str, Any]

Returns: MessageResponse

Raises:

  • NotImplementedError — Always.

Method JevClient.batch_ask

Run several :meth:ask calls concurrently.

batch_ask(requests: List[Dict[str, Any]]) -> List[AIMessage]

Parameter Type Default Description
requests List[Dict[str, Any]] Keyword-argument dicts, one per :meth:ask call.

Returns: List[AIMessage] — The AIMessage for each request, in order.

Alias JevConfigurationError

Re-exported from parrot.clients.jev.exceptions.JevConfigurationError.

Alias JevConnectionError

Re-exported from parrot.clients.jev.exceptions.JevConnectionError.

Alias JevError

Re-exported from parrot.clients.jev.exceptions.JevError.

Alias JevModel

Re-exported from parrot.clients.jev.models.JevModel.

Alias ListModelsResponse

Re-exported from parrot.clients.jev.models.ListModelsResponse.

Attribute MAX_RETRY_AFTER

Attribute MODELS_PATH

Alias MessageResponse

Re-exported from parrot.clients.base.MessageResponse.

Alias ModelMetadata

Re-exported from parrot.clients.jev.models.ModelMetadata.

Alias QuestionInput

Re-exported from parrot.clients.jev.models.QuestionInput.

Attribute QuestionsInput

Alias REQUEST_ID_HEADER

Re-exported from parrot.clients.jev.exceptions.REQUEST_ID_HEADER.

Attribute RETRYABLE_STATUSES

Attribute SYSTEM_ONE_PATH

Alias StateContent

Re-exported from parrot.clients.jev.models.JSONContent.

Alias StructuredOutputConfig

Re-exported from parrot.models.StructuredOutputConfig.

Alias SystemOneResponse

Re-exported from parrot.clients.jev.models.SystemOneResponse.

Alias answers_to_type

Re-exported from parrot.clients.jev.schema.answers_to_type.

Alias api_error

Re-exported from parrot.clients.jev.exceptions.api_error.

Alias current_session_id

Re-exported from parrot.observability.context.current_session_id.

Alias current_user_id

Re-exported from parrot.observability.context.current_user_id.

Alias normalize_questions

Re-exported from parrot.clients.jev.models.normalize_questions.

Alias questions_from_type

Re-exported from parrot.clients.jev.schema.questions_from_type.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally