Skip to main content

Minimal type-checked LLM helper (experimental)

Project description

dariko

Minimal type-checked LLM helper (experimental)

インストール

pip install dariko

使用方法

基本的な使い方

from dariko import configure, ask
from pydantic import BaseModel

# APIキーを設定
configure("your-api-key")  # または環境変数 DARIKO_API_KEY を設定

# 型定義
class Person(BaseModel):
    name: str
    age: int

# 型アノテーションから自動推論
result: Person = ask("名前と年齢を教えて")
print(result.name)  # "Alice"
print(result.age)   # 30

関数の戻り値型から推論

def get_person(prompt: str) -> Person:
    return ask(prompt)  # 戻り値型から自動推論

result = get_person("名前と年齢を教えて")

明示的な型指定

result = ask("名前と年齢を教えて", output_model=Person)

バッチ処理

from dariko import ask_batch

prompts = [
    "名前と年齢を教えて",
    "別の人の名前と年齢を教えて"
]
results: list[Person] = ask_batch(prompts)

エラーハンドリング

from dariko import ValidationError

try:
    result: Person = ask("無効な応答を返して")
except ValidationError as e:
    print(f"型検証エラー: {e}")

型ヒントのサポート

  • Pydantic BaseModel
  • 基本的な型(str, int, float, bool)
  • コレクション型(list, dict)
  • Optional, Union などの型
  • ネストされた構造
  • 再帰的な型

ライセンス

MIT

from pydantic import BaseModel
from dariko import ask

class Person(BaseModel):
    name: str
    age: int

result: Person = ask("次の JSON を返して: {name:'Alice', age:30}")
print(result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dariko-0.0.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dariko-0.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file dariko-0.0.2.tar.gz.

File metadata

  • Download URL: dariko-0.0.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for dariko-0.0.2.tar.gz
Algorithm Hash digest
SHA256 19ef75206a3eb66a7a3a1ee307f30b6d3deaa842f2617d67638971fd507faad5
MD5 35abe922eaa8fe7b32cdf4ed595cff31
BLAKE2b-256 bcd459a2a3e6f1882c99310c69f9a668b40dee54a9b44b9cec39f32cb8e344e6

See more details on using hashes here.

File details

Details for the file dariko-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: dariko-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for dariko-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee04556d41ec2f38cdcea5f2666dae2b667843e91556607e3c8de28e07f18269
MD5 f3c6015f3d294d4356a6cb2a374024cf
BLAKE2b-256 7ffc25250cca6dcb82da60ece2a740487e616171ca2f6608f18d9bfe23812f46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page