Genflux Python SDK の完全な API リファレンスです。 このドキュメントはソースコードの docstring・型ヒントから自動生成されています。
⚠️ このファイルは自動生成物です。直接編集しないでください。 変更が必要な場合は、ソースコードの docstring を更新してからmake docsを実行してください。
from genflux import GenFlux
client = GenFlux() # GENFLUX_API_KEY 環境変数を使用
evaluator = client.evaluation()
result = evaluator.faithfulness(
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is a high-level programming language..."],
)
print(f"Score: {result.score}") # 0.0 ~ 1.0graph TB
User["Your Code"] --> GF["Genflux Client"]
GF --> CC["client.configs<br/><small>ConfigClient</small>"]
GF --> JC["client.jobs<br/><small>JobsClient</small>"]
GF --> RC["client.reports<br/><small>ReportsClient</small>"]
GF --> EC["client.evaluation()<br/><small>EvaluationClient</small>"]
CC --> API["Genflux Backend API"]
JC --> API
RC --> API
EC --> API
API --> Queue["Job Queue"]
Queue --> Result["MetricResult<br/><small>score / reason</small>"]
style GF fill:#4A90D9,color:#fff
style EC fill:#7B68EE,color:#fff
style API fill:#2E8B57,color:#fff
| クライアント | アクセス方法 | 説明 |
|---|---|---|
GenFlux |
GenFlux() |
メインクライアント(認証・サブクライアント管理) |
EvaluationClient |
client.evaluation() |
8 種類のメトリックによる評価実行 |
ConfigClient |
client.configs |
RAG API 設定の CRUD |
JobsClient |
client.jobs |
非同期ジョブの作成・監視・キャンセル |
ReportsClient |
client.reports |
評価レポートの取得(サマリー/詳細) |
| メトリック | メソッド | contexts |
ground_truth |
スコア |
|---|---|---|---|---|
| Faithfulness | evaluator.faithfulness() |
必須 | — | 0〜1(高いほど良い) |
| Answer Relevancy | evaluator.answer_relevancy() |
任意 | — | 0〜1(高いほど良い) |
| Contextual Relevancy | evaluator.contextual_relevancy() |
必須 | — | 0〜1(高いほど良い) |
| Contextual Precision | evaluator.contextual_precision() |
必須 | — | 0〜1(高いほど良い) |
| Contextual Recall | evaluator.contextual_recall() |
必須 | 必須 | 0〜1(高いほど良い) |
| Hallucination | evaluator.hallucination() |
必須 | — | 0〜1(低いほど良い) |
| Toxicity | evaluator.toxicity() |
任意 | — | 0〜1(低いほど良い) |
| Bias | evaluator.bias() |
任意 | — | 0〜1(低いほど良い) |
GenFlux APIクライアント。
| 属性 | 型 | 説明 |
|---|---|---|
api_key |
str | None |
(default: None) |
base_url |
str | None |
(default: None) |
environment |
str | None |
(default: None) |
timeout |
float |
(default: 60.0) |
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
api_key |
str | None |
No | API key for authentication. If not provided, uses GENFLUX_API_KEY env var. |
base_url |
str | None |
No | Base URL for the GenFlux API. If not provided, uses GENFLUX_API_BASE_URL env var or constructs from environment setting. |
environment |
str | None |
No | Environment name ("local", "dev", or "prod"). Uses GENFLUX_ENVIRONMENT env var if not provided. Defaults to "prod". |
timeout |
float |
No | Request timeout in seconds (default: 60.0) |
from genflux import GenFlux
# Production (default)
client = GenFlux(api_key="pk_xxx")
# Development
client = GenFlux(api_key="pk_xxx", environment="dev")
# Local development
client = GenFlux(api_key="dev_test_key", environment="local")指定された設定で評価クライアントを作成します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
config_id |
str | None |
No | Config ID to use for evaluations (optional, uses default if not provided) |
戻り値: EvaluationClient instance
例:
# With explicit config
client = GenFlux(api_key="pk_xxx")
evaluator = client.evaluation(config_id="config_123")
result = evaluator.faithfulness(
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is..."],
)
# Without config (uses default)
evaluator = client.evaluation()
result = evaluator.faithfulness(
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is..."],
)継承: BaseClient
評価設定管理用クライアント。
新しい設定を作成します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
config |
ConfigCreate |
Yes | Config creation parameters |
戻り値: Created config
例外:
ValidationError: If config parameters are invalidAPIError: If request failed
例:
from genflux import ConfigClient
from genflux.models.config import ConfigCreate
client = ConfigClient(api_key="your_api_key")
config = client.create(
ConfigCreate(
name="My Config",
api_endpoint="https://api.openai.com/v1/chat/completions",
auth_type="bearer_token",
auth_token="your_token",
evaluation_metrics={
"faithfulness": True,
"answer_relevancy": True,
},
total_prompt_count=10,
)
)
print(f"Created config: {config.id}")設定を削除します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
config_id |
str | UUID |
Yes | Config ID |
戻り値: True if deleted successfully
例外:
NotFoundError: If config not foundAPIError: If request failed
例:
success = client.delete("550e8400-e29b-41d4-a716-446655440000")
print(f"Deleted: {success}")IDで設定を取得します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
config_id |
str | UUID |
Yes | Config ID |
戻り値: Config object
例外:
NotFoundError: If config not foundAPIError: If request failed
例:
config = client.get("550e8400-e29b-41d4-a716-446655440000")
print(f"Config name: {config.name}")すべての設定を一覧取得します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
limit |
int |
No | Maximum number of configs to return |
offset |
int |
No | Number of configs to skip |
戻り値: List of configs
例外:
APIError: If request failed
例:
configs = client.list()
for config in configs.configs:
print(f"- {config.name} ({config.id})")設定を更新します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
config_id |
str | UUID |
Yes | Config ID |
config_update |
ConfigUpdate |
Yes | Config update parameters |
戻り値: Updated config
例外:
NotFoundError: If config not foundValidationError: If update parameters are invalidAPIError: If request failed
例:
from genflux.models.config import ConfigUpdate
updated_config = client.update(
config_id="550e8400-e29b-41d4-a716-446655440000",
config_update=ConfigUpdate(
name="Updated Config Name",
description="New description",
),
)
print(f"Updated: {updated_config.name}")ジョブ(実行)管理用クライアント。
実行中のジョブをキャンセルします。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
job_id |
str |
Yes | Job ID to cancel |
戻り値: Cancelled Job object
例外:
NotFoundError: If job not foundValidationError: If job cannot be cancelledAPIError: If API request fails
例:
job = client.jobs.cancel("job_123")
print(job.status)
'cancelled'create(execution_type: str, config_id: str | None = None, data: dict[str, Any] | None = None) -> Job
新しいジョブを作成します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
execution_type |
str |
Yes | Execution type (e.g., 'quick_evaluate', 'evaluation') |
config_id |
str | None |
No | Config ID (optional, uses default if not provided) |
data |
dict[str, Any] | None |
No | Additional data for the job (for quick_evaluate) |
戻り値: Created Job object
例外:
APIError: If API request failsValidationError: If request validation fails
例:
# With explicit config
job = client.jobs.create(
execution_type="quick_evaluate",
config_id="config_123",
data={"metric": "faithfulness", "question": "...", ...}
)
# Without config (uses default)
job = client.jobs.create(
execution_type="quick_evaluate",
data={"metric": "faithfulness", "question": "...", ...}
)IDでジョブを取得します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
job_id |
str |
Yes | Job ID |
戻り値: Job object
例外:
NotFoundError: If job not foundAPIError: If API request fails
例:
job = client.jobs.get("job_123")
print(job.status)
'running'ジョブ一覧を取得します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
status |
str | None |
No | Filter by status (e.g., 'completed', 'running', 'failed') |
execution_type |
str | None |
No | Filter by execution type (e.g., 'quick_evaluate', 'redteam_static', 'oss') |
limit |
int |
No | Maximum number of jobs to return (not yet implemented in backend) |
戻り値: List of Job objects
例外:
APIError: If API request fails
例:
# Get all jobs
jobs = client.jobs.list()
# Get completed jobs only
completed_jobs = client.jobs.list(status="completed")
# Get RedTeam jobs
redteam_jobs = client.jobs.list(execution_type="redteam_static")wait(job_id: str, timeout: int = 600, poll_interval: float = 5.0, callback: Union[Callable[Job, None], None] = None) -> Job
ジョブの完了を待機します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
job_id |
str |
Yes | Job ID to wait for |
timeout |
int |
No | Maximum wait time in seconds (default: 600) |
poll_interval |
float |
No | Polling interval in seconds (default: 5.0) |
callback |
Union[Callable[Job, None], None] |
No | Optional callback function called on each poll with Job object |
戻り値: Completed Job object
例外:
TimeoutError: If job doesn't complete within timeoutJobFailedError: If job failsNotFoundError: If job not found
例:
def on_progress(job):
print(f"Progress: {job.progress.percentage}%")
job = client.jobs.wait(
"job_123",
timeout=300,
callback=on_progress
)継承: BaseClient
レポートAPI用クライアント。
IDでレポートを取得します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
report_id |
str | UUID |
Yes | Report ID (= Job ID) |
view |
Literal[summary, details] |
No | View level - "summary": CI判定用の指標のみ - "details": 失敗ケース上位N件 + カテゴリ別集計 |
戻り値: Report object
例外:
NotFoundError: If report not foundValidationError: If report not ready (job not completed)
例:
from genflux import GenFlux
client = GenFlux(api_key="genflux_xxx")
# Get summary report
report = client.reports.get(
report_id="job_uuid",
view="summary"
)
print(f"Success Rate: {report.summary.evaluation.success_rate}")
# Get detailed report
report = client.reports.get(
report_id="job_uuid",
view="details"
)
for failed_case in report.details.failed_cases:
print(f"Failed: {failed_case.reason}")評価操作用クライアント。
同期スタイルのインターフェースを提供し、 内部的にJobベースの非同期実行を使用します。
answer_relevancy(question: str, answer: str, contexts: list[str] | None = None, timeout: int = 300) -> MetricResult
回答の関連性を評価します(回答が質問に対応しているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] | None |
No | Context/retrieval texts (optional) |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with answer relevancy score
例:
result = evaluator.answer_relevancy(
question="What is Python?",
answer="Python is a programming language.",
)bias(question: str, answer: str, contexts: list[str] | None = None, timeout: int = 300) -> MetricResult
バイアスを評価します(回答に偏りのあるコンテンツが含まれているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] | None |
No | Context/retrieval texts (optional) |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with bias score (lower is better)
contextual_precision(question: str, answer: str, contexts: list[str], timeout: int = 300) -> MetricResult
コンテキストの精度を評価します(関連するコンテキストが上位にランクされているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] |
Yes | Context/retrieval texts (order matters) |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with contextual precision score
contextual_recall(question: str, answer: str, contexts: list[str], ground_truth: str, timeout: int = 300) -> MetricResult
コンテキストの再現率を評価します(回答がコンテキストに帰属できるか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] |
Yes | Context/retrieval texts |
ground_truth |
str |
Yes | Ground truth answer (required for contextual_recall) |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with contextual recall score
contextual_relevancy(question: str, answer: str, contexts: list[str], timeout: int = 300) -> MetricResult
コンテキストの関連性を評価します(コンテキストが質問に関連しているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] |
Yes | Context/retrieval texts |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with contextual relevancy score
例:
result = evaluator.contextual_relevancy(
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is a high-level programming language..."],
)evaluate(metric: str, question: str, answer: str, contexts: list[str] | None = None, ground_truth: str | None = None, timeout: int = 300, callback: Union[Callable[Job, None], None] = None, show_progress: bool = True) -> MetricResult
単一の質問-回答ペアを評価します。
このメソッドは内部的にジョブを作成し、完了を待機して結果を返す 同期スタイルのAPIを提供します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
metric |
str |
Yes | Metric name to evaluate. Valid values - 'faithfulness', 'answer_relevancy', 'context_relevancy', 'llm_context_precision', 'context_recall', 'hallucination', 'toxicity', 'bias'. (メソッド名と内部メトリック名の対応: contextual_relevancy() → 'context_relevancy', contextual_precision() → 'llm_context_precision', contextual_recall() → 'context_recall') |
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] | None |
No | Context/retrieval texts (optional) |
ground_truth |
str | None |
No | Ground truth answer (required for contextual_recall) |
timeout |
int |
No | Maximum wait time in seconds (default: 300) |
callback |
Union[Callable[Job, None], None] |
No | Optional progress callback (overrides show_progress) |
show_progress |
bool |
No | Show progress bar (default: True, ignored if callback is provided) |
戻り値: MetricResult with score and reason
例外:
TimeoutError: If evaluation doesn't complete within timeoutJobFailedError: If evaluation failsValidationError: If request validation fails
例:
client = GenFlux(api_key="pk_xxx")
evaluator = client.evaluation(config_id="config_123")
result = evaluator.evaluate(
metric="faithfulness",
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is a high-level programming language..."],
)
print(f"Score: {result.score}, Reason: {result.reason}")faithfulness(question: str, answer: str, contexts: list[str], timeout: int = 300, on_progress: Union[Callable[Job, None], None] = None) -> MetricResult
忠実性を評価します(回答がコンテキストに基づいているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] |
Yes | Context/retrieval texts |
timeout |
int |
No | Maximum wait time in seconds |
on_progress |
Union[Callable[Job, None], None] |
No | Optional progress callback |
戻り値: MetricResult with faithfulness score
例:
result = evaluator.faithfulness(
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is a high-level programming language..."],
)ハルシネーションを評価します(回答にコンテキストにない情報が含まれているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] |
Yes | Context/retrieval texts |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with hallucination score (lower is better)
toxicity(question: str, answer: str, contexts: list[str] | None = None, timeout: int = 300) -> MetricResult
有害性を評価します(回答に有害なコンテンツが含まれているか)。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
question |
str |
Yes | Question text |
answer |
str |
Yes | Answer text |
contexts |
list[str] | None |
No | Context/retrieval texts (optional) |
timeout |
int |
No | Maximum wait time in seconds |
戻り値: MetricResult with toxicity score (lower is better)
継承: BaseModel
完全な設定オブジェクト。
| 属性 | 型 | 説明 |
|---|---|---|
id |
UUID |
|
tenant_id |
UUID |
|
user_id |
UUID |
|
name |
str |
|
description |
str | None |
|
locale |
str |
|
api_settings |
ApiSettings | None |
|
rag_quality_config |
RagQualityConfig | None |
|
redteam_config |
RedteamConfig | None |
|
policy_check_config |
PolicyCheckConfig | None |
|
created_at |
datetime |
|
updated_at |
datetime |
継承: BaseModel
設定作成用のリクエストモデル。
| 属性 | 型 | 説明 |
|---|---|---|
name |
str |
Config name |
description |
str | None |
Config description |
locale |
str |
Locale (ja/en) |
api_endpoint |
str |
API endpoint URL |
auth_type |
str |
Authentication type |
auth_header |
str | None |
Auth header name |
auth_token |
str | None |
Auth token |
request_format |
dict[str, Any] | None |
Request format |
response_format |
dict[str, Any] | None |
Response format |
evaluation_metrics |
dict[str, Any] | None |
Evaluation metrics |
total_prompt_count |
int | None |
Total prompt count |
prompt_category_ratios |
dict[str, Any] | None |
Category ratios |
manual_prompts |
list[str] | None |
Manual prompts |
evaluation_success_rate_threshold |
float | None |
Success rate threshold (%) |
redteam_objectives |
list[str] | None |
RedTeam objectives |
redteam_max_turns |
int | None |
Max turns |
redteam_defense_rate_threshold |
float | None |
Defense rate threshold (%) |
compliance_frameworks |
list[str] | None |
Compliance frameworks |
policy_compliance_rate_threshold |
float | None |
Compliance rate threshold (%) |
継承: BaseModel
設定更新用のリクエストモデル。
| 属性 | 型 | 説明 |
|---|---|---|
name |
str | None |
|
description |
str | None |
|
locale |
str | None |
|
api_endpoint |
str | None |
|
auth_type |
str | None |
|
auth_header |
str | None |
|
auth_token |
str | None |
|
request_format |
dict[str, Any] | None |
|
response_format |
dict[str, Any] | None |
|
evaluation_metrics |
dict[str, Any] | None |
|
total_prompt_count |
int | None |
|
prompt_category_ratios |
dict[str, Any] | None |
|
manual_prompts |
list[str] | None |
|
evaluation_success_rate_threshold |
float | None |
|
redteam_objectives |
list[str] | None |
|
redteam_max_turns |
int | None |
|
redteam_defense_rate_threshold |
float | None |
|
compliance_frameworks |
list[str] | None |
|
policy_compliance_rate_threshold |
float | None |
継承: BaseModel
設定一覧取得用のレスポンスモデル。
| 属性 | 型 | 説明 |
|---|---|---|
configs |
list[Config] |
|
total |
int |
継承: BaseModel
API設定。
| 属性 | 型 | 説明 |
|---|---|---|
api_endpoint |
str |
|
auth_type |
str |
|
auth_header |
str | None |
|
auth_token |
str | None |
|
request_format |
dict[str, Any] | None |
|
response_format |
dict[str, Any] | None |
継承: BaseModel
RAG品質評価の設定。
| 属性 | 型 | 説明 |
|---|---|---|
evaluation_metrics |
dict[str, Any] |
|
total_prompt_count |
int | None |
|
prompt_category_ratios |
dict[str, Any] | None |
|
manual_prompts |
list[str] | None |
|
evaluation_success_rate_threshold |
float | None |
継承: BaseModel
RedTeam評価の設定。
| 属性 | 型 | 説明 |
|---|---|---|
redteam_objectives |
list[str] | None |
|
redteam_max_turns |
int | None |
|
redteam_defense_rate_threshold |
float | None |
継承: BaseModel
ポリシーチェックの設定。
| 属性 | 型 | 説明 |
|---|---|---|
compliance_frameworks |
list[str] | None |
|
policy_compliance_rate_threshold |
float | None |
ジョブ(実行)モデル。
| 属性 | 型 | 説明 |
|---|---|---|
id |
str |
|
tenant_id |
str |
|
user_id |
str |
|
config_id |
str |
|
execution_type |
str |
|
status |
str |
|
current_step |
str | None |
|
progress_count |
int |
|
total_count |
int |
|
progress |
JobProgress | None |
|
results |
dict[str, Any] | None |
|
error_message |
str | None |
|
started_at |
datetime | None |
|
completed_at |
datetime | None |
|
created_at |
datetime | None |
|
updated_at |
datetime | None |
APIレスポンスの辞書からJobを作成します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
cls |
Yes | ||
data |
dict[str, Any] |
Yes | API response dictionary |
戻り値: Job instance
ジョブが完了したかどうかを確認します。
ジョブが失敗したかどうかを確認します。
ジョブが待機中(キュー待ちまたはペンディング)かどうかを確認します。
ジョブが実行中かどうかを確認します。
ジョブの進捗情報。
| 属性 | 型 | 説明 |
|---|---|---|
percentage |
float |
|
message |
str |
単一メトリックの評価結果。
| 属性 | 型 | 説明 |
|---|---|---|
metric |
str |
|
score |
float |
|
reason |
str | None |
|
engine |
str |
|
execution_time_seconds |
float | None |
(default: None) |
継承: BaseModel
レポートモデル。
| 属性 | 型 | 説明 |
|---|---|---|
report_id |
UUID |
|
job_id |
UUID |
|
config_id |
UUID | None |
|
type |
str |
|
status |
Literal[completed, partial] |
|
created_at |
datetime |
|
summary |
ReportSummary |
|
details |
ReportDetails | None |
継承: BaseModel
レポートサマリ(全タイプ共通)
| 属性 | 型 | 説明 |
|---|---|---|
evaluation |
EvaluationSummary | None |
|
redteam |
RedTeamSummary | None |
|
policy |
PolicySummary | None |
継承: BaseModel
レポート詳細(view=details用)
| 属性 | 型 | 説明 |
|---|---|---|
failed_cases |
list[FailedCase] |
失敗ケース(最大10件) |
top_violations |
list[Violation] |
重大違反(上位) |
recommendations |
list[str] |
改善推奨事項 |
継承: BaseModel
評価サマリ
| 属性 | 型 | 説明 |
|---|---|---|
success_rate |
float |
|
total_tests |
int |
|
passed |
int |
|
failed |
int |
|
category_breakdown |
list[CategoryBreakdown] |
継承: BaseModel
RedTeamサマリ
| 属性 | 型 | 説明 |
|---|---|---|
attack_success_rate |
float |
|
risk_level |
Literal[low, medium, high, critical] |
|
total_attacks |
int |
|
successful_attacks |
int |
|
category_breakdown |
list[CategoryBreakdown] |
継承: BaseModel
ポリシーサマリ
| 属性 | 型 | 説明 |
|---|---|---|
compliance_rate |
float |
|
total_checks |
int |
|
violations_count |
int |
|
framework_breakdown |
list[CategoryBreakdown] |
継承: BaseModel
カテゴリ別内訳
| 属性 | 型 | 説明 |
|---|---|---|
category |
str |
|
success_rate |
float | None |
|
compliance_rate |
float | None |
|
count |
int |
|
violations |
int | None |
継承: BaseModel
失敗ケース
| 属性 | 型 | 説明 |
|---|---|---|
case_id |
str |
|
input |
str |
入力(PIIマスキング済み) |
expected |
str | None |
期待値 |
actual |
str |
実際の出力(PIIマスキング済み) |
reason |
str |
|
category |
str |
|
severity |
Literal[low, medium, high, critical] |
継承: BaseModel
違反情報
| 属性 | 型 | 説明 |
|---|---|---|
violation_id |
str |
|
rule |
str |
|
description |
str |
|
severity |
Literal[low, medium, high, critical] |
|
evidence |
str |
証跡(PIIマスキング済み) |
すべての例外は GenFluxError を基底クラスとしています。
| 例外 | 継承元 | HTTP ステータス | 説明 |
|---|---|---|---|
GenFluxError |
Exception |
— | 基底例外クラス |
APIError |
GenFluxError |
— | API リクエスト失敗(基底) |
AuthenticationError |
APIError |
401 | API Key が無効または未設定 |
NotFoundError |
APIError |
404 | リソースが見つからない |
ValidationError |
APIError |
400, 422 | リクエストパラメータが不正 |
RateLimitError |
APIError |
429 | レート制限超過 |
TimeoutError |
GenFluxError |
— | ジョブのタイムアウト |
JobFailedError |
GenFluxError |
— | ジョブ実行の失敗 |
ConfigNotFoundError |
GenFluxError |
— | 指定した Config が存在しない |
ResourceNotFoundError |
GenFluxError |
— | リソースが見つからない |
Note:
APIError系は HTTP レスポンスに起因する例外です。status_code属性でステータスコードを取得できます。TimeoutError/JobFailedErrorはジョブ実行に起因する例外で、HTTP ステータスコードはありません。
from genflux import GenFlux
from genflux.exceptions import (
AuthenticationError,
RateLimitError,
TimeoutError,
JobFailedError,
)
client = GenFlux()
evaluator = client.evaluation()
try:
result = evaluator.faithfulness(
question="What is Python?",
answer="Python is a programming language.",
contexts=["Python is a high-level programming language."],
)
except AuthenticationError:
# API Key が無効または未設定
pass
except RateLimitError as e:
# レート制限。e.retry_after 秒後にリトライ
pass
except TimeoutError:
# ジョブがタイムアウト
pass
except JobFailedError as e:
# ジョブ実行失敗。e.error_message で詳細を確認
passターミナル出力用のシンプルなプログレスバー。
| 属性 | 型 | 説明 |
|---|---|---|
total |
int |
(default: 100) |
width |
int |
(default: 50) |
prefix |
str |
(default: 'Progress') |
suffix |
str |
(default: 'Complete') |
decimals |
int |
(default: 1) |
fill |
str |
(default: '█') |
print_end |
str |
(default: '\r') |
file |
TextIO |
(default: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'>) |
プログレスバーを更新します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
current |
int |
Yes | Current progress value (0 to total) |
message |
str | None |
No | Optional status message |
indeterminate |
bool |
No | When True, show "Processing..." instead of percentage (for single-metric or initial state) |
Jobオブジェクトからプログレスバーを更新します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
job |
Job |
Yes | Job object with progress information |
job.wait()用のプログレスコールバックを作成します。
パラメータ:
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
enable |
Yes | Whether to enable progress display (default: True) |
戻り値: Callback function for job.wait()
例:
from genflux import GenFlux
from genflux.progress import create_progress_callback
client = GenFlux(api_key="pk_xxx")
job = client.jobs.create(...)
# With progress bar
callback = create_progress_callback(enable=True)
result = client.jobs.wait(job.id, callback=callback)- README.md - セットアップ方法
- QUICKSTART.md - 簡単な使い方
- WORKFLOW.md - 本格的なワークフロー
Auto-generated at 2026-03-23 07:15 UTC by scripts/generate_api_reference.py