LLMの出力をPydanticモデルで型安全に扱うためのPythonライブラリ
Project description
dariko
LLMの出力をPydanticモデルで型安全に扱うためのPythonライブラリ。
特徴
- LLMの出力をPydanticモデルで型安全に扱える
- 型アノテーションから自動的に出力モデルを推論
- バッチ処理に対応
- シンプルなAPI
インストール
pip install dariko
使用方法
基本的な使い方
from pydantic import BaseModel
from dariko import ask, configure
# APIキーの設定
configure("your-api-key") # または環境変数 DARIKO_API_KEY を設定
# 出力モデルの定義
class Person(BaseModel):
name: str
age: int
dummy: bool
api_key: str
# 型アノテーションから自動的にモデルを推論
result: Person = ask("test")
print(result.name) # "test"
print(result.age) # 20
print(result.dummy) # True
明示的にモデルを指定
result = ask("test", output_model=Person)
バッチ処理
from dariko import ask_batch
prompts = ["test1", "test2"]
results = ask_batch(prompts, output_model=Person)
開発
セットアップ
git clone https://github.com/yourusername/dariko.git
cd dariko
pip install -e .
テスト
pytest tests/
ライセンス
MIT License
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
Release history Release notifications | RSS feed
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.2.2.tar.gz
(8.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dariko-0.2.2.tar.gz.
File metadata
- Download URL: dariko-0.2.2.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8ef218ea2009e53ab03af611b0fa4e83a4e8da8b028fab441b8fdbafcdd3692
|
|
| MD5 |
af082bfd5a2a642fd3447c9dc5ae9b12
|
|
| BLAKE2b-256 |
cc00fff56ea00f6134235f248aa6580a788c9e9cd6ed4de881c82d1459a2149c
|
File details
Details for the file dariko-0.2.2-py3-none-any.whl.
File metadata
- Download URL: dariko-0.2.2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fb6563b2113f81133e006c4d902e05bd4a352d202fdccacae1410d2ef37ac03
|
|
| MD5 |
227e7bf25dea3e2095cc78f9538cdcf8
|
|
| BLAKE2b-256 |
830fb36dfe6ee9a9661de39f51c557190d1d30c191057b61590c04e5095cb7bd
|