本文へ移動
cccskills
無料GitHub で公開

clairic

Build typed extraction with the unofficial VianneyMI/clairic Python SDK for Cloudflare's Clairic model. Use for Clairic, AsyncClairic, Pydantic answer models, annotated field specs, null/confidence handling, estimates, or forecasts. Also trigger for Workers AI Clairic REST/bindings, SDK-versus-service differences, and offline MockTransport tests.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skillsスター 12(GitHub 12 + cccskills 0)
連携ツールCloudflare

実行スコア 未検証

インストール方法を見る

含まれるファイル(12)

  • SKILL.md8.3 KB
  • eval.yaml509 B
  • graders/check.py17.1 KB
  • instructions/invoice-extraction.md4.6 KB
  • references/clients-errors-and-testing.md8.7 KB
  • references/cloudflare-api-and-limits.md7.2 KB
  • references/sources-and-compatibility.md7.6 KB
  • references/typed-fields-and-results.md8.8 KB
  • rubrics/quality.md2.3 KB
  • scripts/offline_checks.py11.5 KB
  • solutions/reference-invoice4.0 KB
  • tests/test_eval_grader.py17.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Clairic — Unofficial Python SDK

Extract typed values and uncertainty metadata with clairic, the unofficial Python SDK maintained at VianneyMI/clairic, not by Cloudflare. The hosted model is Cloudflare Workers AI's @cf/cloudflare/clairic. This skill covers SDK 0.1.0, inspected at d4b0f3390a05e2310f0fc033803e65658abfcfae on 2026-10-26. The service is in preview; refresh its contract before rollout.

Quick Reference

NeedRead
All nine field types, specs, aliases, uncertainty, export/storageTyped fields and results
Auth, sync/async clients, errors, timeouts, offline checksClients, errors, and testing
Official REST/Workers binding, images/options, billing and limitsCloudflare API and limits
Pinned sources, ownership, known discrepancies, verification scopeSources and compatibility
Executable synthetic SDK contract checks, no inferenceOffline checks

Core Workflow

1. Choose the Correct Surface

  • Use this SDK for text extraction in Python 3.10+, with Pydantic 2 models.
  • Use the official REST API or Workers AI binding for images or options.include_quantiles / options.return_state_text. SDK 0.1.0 does not expose these arguments, even though its answer types can parse quantiles.
  • A Workers binding is not a JavaScript edition of this SDK. The Python client has no chat, embeddings, streaming, batch, or general decision-question API.
  • Extract evidence first. Do exact arithmetic, policy, authorization, and actions in ordinary code. Typed output is not proof that the values are correct.

2. Pin and Configure the SDK

python -m pip install "clairic==0.1.0"

Clairic() reads CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN, or accepts keyword-only account_id= / api_token=. It does not load .env automatically. The official model page's CLOUDFLARE_AUTH_TOKEN sample variable is not an SDK alias. Keep tokens server-side, out of source, browser code, and logs.

3. Declare Answer Models, Not Bare Value Models

from datetime import date
from typing import Annotated

from pydantic import BaseModel, Field
from clairic import Clairic, DateAnswer, Number, NumberAnswer, Result, TextAnswer


class InvoiceExtraction(BaseModel):
    invoice_number: TextAnswer
    total: Annotated[NumberAnswer[float], Number(unit="USD", decimals=2)]
    due_date: DateAnswer = Field(description="The invoice payment due date")


def extract_invoice(text: str, reference_day: date) -> Result[InvoiceExtraction]:
    # Calling this function performs real, metered Cloudflare inference.
    with Clairic(timeout=30.0) as client:
        result = client.extract(
            text,
            InvoiceExtraction,
            reference_date=reference_day,
        )
    if result.truncated:
        raise ValueError("Incomplete extraction requires review")
    return result

The model argument to extract() is the Pydantic class, not a model ID. Use Field(description=...) for field instructions, Annotated for matching specs, and keyword arguments for all specs. reference_date anchors relative dates; establish the intended date with the caller rather than silently guessing.

Do not use Optional[TextAnswer], bare str / float, arbitrary nested models, or list[TextAnswer] as extraction fields. Scalar answer .value is already nullable. Use TextListAnswer or parameterized ListAnswer for lists.

4. Handle Absence, Uncertainty, and Incomplete Input Separately

For scalar answers, inspect:

  • .value: the extracted value, possibly None.
  • .p_null: probability that no appropriate value exists.
  • .confidence: correctness conditional on a value existing.
  • .guess: a candidate, not permission to replace a missing value.

null_threshold changes the service's absence decision, not a confidence threshold. Never silently use answer.value or answer.guess: it mishandles both missing values and valid zero values. Check is None explicitly.

Estimates and forecasts have distributions/intervals, not scalar confidence or p_null. A p10–p90 interval is the model's central 80% interval, not guaranteed real-world coverage. Calibrate acceptance/review rules on representative data; keep arithmetic, payment approval, and other consequential actions outside the model. A non-null amount alone is not an approved payment.

5. Export Values or Preserve the Full Result Deliberately

class InvoiceValues(BaseModel):
    invoice_number: str | None
    total: float | None
    due_date: date | None


def export_invoice(result: Result[InvoiceExtraction]) -> InvoiceValues:
    if result.truncated:
        raise ValueError("Incomplete extraction requires review")
    return result.values_as(InvoiceValues)

values_as() uses matching Python attribute names and runs target Pydantic validation. Nonnullable target fields can reject a missing value. Exporting values discards uncertainty metadata; apply review policy before acting on them.

For storage, use result.model_dump_json() and Result[InvoiceExtraction].model_validate_json(stored_json). A raw Cloudflare REST envelope is not a serialized SDK Result.

6. Reuse Clients and Make Reliability Policy Explicit

Use with Clairic(...) or async with AsyncClairic(...); await the async extract(). Reuse a client across related calls. The default HTTPX timeout is 30 seconds, not a separate total deadline. A supplied HTTP client owns its own timeout and must be closed by its caller.

The SDK has no automatic retries. Handle configuration/model errors separately from API/transport failures; cap any application retries and budget for repeat inference. HTTP 403 and 429 use generic APIError, not special permission or rate-limit exception classes. See the client reference for the full mapping.

7. Verify Offline Before Authorized Live Testing

python skills/clairic/scripts/offline_checks.py
python3 -m unittest discover -s skills/clairic/tests -v
./scripts/run-evals.sh clairic --validate

The first command requires the pinned SDK and uses only synthetic HTTPX MockTransport responses with dummy credentials. The grader tests use the Python standard library. The skillgrade reference-validation command is separate; environment/tooling failures must be reported, not called passing evaluations.

Do not run upstream live tests to “check imports.” Even their invalid-token test can send a network request without real credentials. Wrangler local development can still invoke the hosted model and incur usage. Offline checks do not measure model accuracy, calibration, real billing, or live permissions.

Anti-Patterns to Avoid

  • Calling this the official Cloudflare SDK, or inventing a JavaScript SDK/CLI.
  • Passing an image, stream=True, options=, or a model ID to SDK extract().
  • Treating nullable values, guesses, confidence, and p_null as interchangeable.
  • Using null_threshold as a confidence cutoff or hardcoding universal policy thresholds.
  • Declaring an integer estimate without a whole-number step.
  • Using a raw REST envelope as Result[MyModel] JSON or remapping aliases implicitly.
  • Assuming one request means one billed pass, free retries, or guaranteed latency.
  • Logging response/error bodies indiscriminately; they may contain extracted data.
  • Promising self-hosted weights, privacy guarantees, or unsupported API compatibility.

When to Use / Not Use

Use for Python Clairic extraction, field/schema design, uncertainty-aware result handling, SDK troubleshooting, and selecting between the SDK and official API.

Do not use as a general chat/agent framework, a PDF/document-file loader, a TypeSafe/Jev primitive adapter, an exact arithmetic engine, or an authorization system. Images require the official surface, not invented Python SDK support.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Adaption AI SDK for synthetic data augmentation and dataset adaptation. Use when building data pipelines with the Adaption Python SDK, uploading datasets (local files, Hugging Face, Kaggle), running augmentation/adaptation jobs, configuring brand controls (hallucination mitigation, safety categories, length), recipe specifications (reasoning traces, deduplication, preference pairs, prompt rephrase), evaluating dataset quality, downloading results, or any workflow involving `pip install adaption`, `from adaption import Adaption`, Adaptive Data, or the adaptionlabs.ai API. Also trigger when the user mentions synthetic data generation for fine-tuning, dataset augmentation pipelines, DPO preference pair generation, or grounding-based hallucination reduction on training data.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年10月26日 更新

Design and review intuitive, scalable, maintainable HTTP APIs. Use this skill whenever the user wants to design a new REST API, review an existing API or spec, write OpenAPI 3.x definitions, or work with HTTP semantics (GET/POST/PUT/PATCH/DELETE), status codes, idempotency (Idempotency-Key), error envelopes (RFC 7807 problem+json), pagination, filtering, versioning, or API auth (API keys, OAuth2 client credentials, rate limits). Also trigger for "API design", "RESTful", "endpoints", "OpenAPI", "Swagger", "ReDoc", "contract testing", or GraphQL and gRPC design questions.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年10月26日 更新

Design relational database schemas (and choose when to go NoSQL) that stay maintainable and fast. Use this skill whenever the user mentions tables, DDL, entities and relationships, normalization (1NF/2NF/3NF), primary and foreign keys, UUID vs bigint IDs, indexes (B-tree, composite, covering, partial), EXPLAIN, constraints (CHECK, UNIQUE, exclusion), transactions and isolation levels, migrations (Alembic, Prisma, Flyway, expand-contract, backfilling), or SQL vs NoSQL (MongoDB, DynamoDB, Cassandra, graph databases). Also trigger for "design the database", "model this domain", "which database should I use", or writing ORM models and migration files for PostgreSQL, MySQL, SQLite, or SQL Server.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年10月26日 更新

ddd

無料

Domain-Driven Design system for software development. Use when designing new systems with DDD principles, refactoring existing codebases toward DDD, generating code scaffolding (entities, aggregates, repositories, domain events), facilitating Event Storming sessions, creating bounded context maps, or performing code reviews with a DDD lens. Covers both strategic design (bounded contexts, subdomains, context maps, ubiquitous language) and tactical design (entities, value objects, aggregates, domain services, repositories). Supports all major architecture patterns (Hexagonal/Ports & Adapters, CQRS, Event Sourcing, Clean Architecture) with language-agnostic guidance and concrete examples in Python and TypeScript.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年10月26日 更新

genai-tk

無料

Build GenAI and agentic apps with genai-tk (tclatos/genai-tk), a YAML-driven IoC toolkit over LangChain, DeepAgents, DeerFlow, and Prefect. Use this skill whenever the user mentions genai-tk, genai_tk, `cli init`, `cli agents run`, `LangchainAgent`, `create_harness`, `get_llm`, `global_config()`, `model_id@provider`, `agents:`/`agent_defaults:` profiles, `RetrieverFactory`, `cli workflow`, or BAML extraction. Also trigger for app_conf.yaml, GENAITK_PROFILE, CodeAct, OpenSandbox, decision models, or "the toolkit".

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年10月26日 更新

langchain

無料

Build AI agents with LangChain v1 and LangGraph in Python. Use this skill whenever the user mentions LangChain, LangGraph, create_agent, init_chat_model, @tool, ToolRuntime, agent middleware, human-in-the-loop, structured output, MCP tools (langchain.mcp, MCPAdapter), RAG, multi-agent handoffs or subagents, checkpointers, Deep Agents (create_deep_agent) or Managed Deep Agents (mda, define_deep_agent). Also trigger for migrating from create_react_agent, LLMChain, AgentExecutor or langchain-mcp-adapters, stream_events, SummarizationMiddleware, and langchain-classic.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年10月26日 更新

svngoku のスキルをすべて見る

このスキルの問題を報告する