diff --git a/docs/API_REFERENCE.md b/docs/API_REFERENCE.md index d0973dd..07d9ead 100644 --- a/docs/API_REFERENCE.md +++ b/docs/API_REFERENCE.md @@ -1,6 +1,6 @@ - + # GENFLUX Python SDK - API Reference @@ -96,7 +96,7 @@ graph TB ### 2.1 `Genflux` -Genflux APIクライアント。 +GENFLUX APIクライアント。 #### 属性 @@ -112,7 +112,7 @@ Genflux APIクライアント。 | パラメータ | 型 | 必須 | 説明 | |---|---|---|---| | `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. | +| `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) | @@ -1011,6 +1011,16 @@ APIレスポンスの辞書からJobを作成します。 | `engine` | `str` | | | `execution_time_seconds` | `float \| None` | (default: None) | +#### コンストラクタパラメータ + +| パラメータ | 型 | 必須 | 説明 | +|---|---|---|---| +| `metric` | `str` | **Yes** | 評価メトリック名(例: "faithfulness", "answer_relevancy")。 | +| `score` | `float` | **Yes** | 評価スコア(0.0〜1.0)。 | +| `reason` | `str \| None` | **Yes** | 評価理由の説明文。メトリックによっては None。 | +| `engine` | `str` | **Yes** | 評価エンジン識別子。現在は ``"genflux"`` が返される。 | +| `execution_time_seconds` | `float \| None` | No | 評価の実行時間(秒)。取得できない場合は None。 | + ### 3.12 `Report` *継承:* `BaseModel` @@ -1296,6 +1306,6 @@ result = client.jobs.wait(job.id, callback=callback) --- -*Auto-generated at 2026-03-23 07:15 UTC by `scripts/generate_api_reference.py`* +*Auto-generated at 2026-04-10 14:02 UTC by `scripts/generate_api_reference.py`* - + diff --git a/docs/DEVELOPER_API_REFERENCE.md b/docs/DEVELOPER_API_REFERENCE.md index 92268ee..5f8c199 100644 --- a/docs/DEVELOPER_API_REFERENCE.md +++ b/docs/DEVELOPER_API_REFERENCE.md @@ -1,6 +1,6 @@ - + # GENFLUX Python SDK - Developer API Reference @@ -13,7 +13,7 @@ ## 📋 目次 -- [Genflux クライアント](#genflux-1) +- [GENFLUX クライアント](#genflux-1) - [BaseClient(内部)](#baseclient) - [ConfigClient](#configclient) - [JobsClient](#jobsclient) @@ -28,7 +28,7 @@ ### `Genflux` -Genflux APIクライアント。 +GENFLUX APIクライアント。 #### 属性 @@ -44,7 +44,7 @@ Genflux APIクライアント。 | パラメータ | 型 | 必須 | 説明 | |---|---|---|---| | `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. | +| `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) | @@ -200,7 +200,7 @@ result = evaluator.faithfulness( ### `BaseClient` -Genflux API用の基底HTTPクライアント。 +GENFLUX API用の基底HTTPクライアント。 #### メソッド @@ -1368,6 +1368,16 @@ APIレスポンスの辞書からJobを作成します。 | `engine` | `str` | | | `execution_time_seconds` | `float \| None` | (default: None) | +#### コンストラクタパラメータ + +| パラメータ | 型 | 必須 | 説明 | +|---|---|---|---| +| `metric` | `str` | **Yes** | 評価メトリック名(例: "faithfulness", "answer_relevancy")。 | +| `score` | `float` | **Yes** | 評価スコア(0.0〜1.0)。 | +| `reason` | `str \| None` | **Yes** | 評価理由の説明文。メトリックによっては None。 | +| `engine` | `str` | **Yes** | 評価エンジン識別子。現在は ``"genflux"`` が返される。 | +| `execution_time_seconds` | `float \| None` | No | 評価の実行時間(秒)。取得できない場合は None。 | + ### `Report` *継承:* `BaseModel` @@ -1637,6 +1647,6 @@ job.wait()用のプログレスコールバックを作成します。 --- -*Auto-generated at 2026-03-23 07:15 UTC by `scripts/generate_api_reference.py`* +*Auto-generated at 2026-04-10 14:02 UTC by `scripts/generate_api_reference.py`* - + diff --git a/docs/evaluation/EVALUATION_METRICS.md b/docs/evaluation/EVALUATION_METRICS.md new file mode 100644 index 0000000..ba881fe --- /dev/null +++ b/docs/evaluation/EVALUATION_METRICS.md @@ -0,0 +1,51 @@ +# 評価メトリクス + +GENFLUX の評価機能で返される `MetricResult` のフィールド仕様を説明します。 + +--- + +## MetricResult + +評価メソッド(`faithfulness()`, `answer_relevancy()` 等)の戻り値です。 + +```python +from genflux.models.job import MetricResult +``` + +### フィールド一覧 + +| フィールド | 型 | 説明 | +|---|---|---| +| `metric` | `str` | 評価メトリック名(例: `"faithfulness"`, `"answer_relevancy"`) | +| `score` | `float` | 評価スコア(0.0〜1.0) | +| `reason` | `str \| None` | 評価理由の説明文。メトリックによっては `None` | +| `engine` | `str` | 評価エンジン識別子(下記参照) | +| `execution_time_seconds` | `float \| None` | 評価の実行時間(秒)。取得できない場合は `None` | + +### engine フィールド + +評価エンジンの識別子を表す文字列です。 + +| 値 | 説明 | +|---|---| +| `"genflux"` | GENFLUX 標準評価エンジン | + +### 使用例 + +```python +from genflux import GENFLUX + +client = GENFLUX(api_key="your-api-key") + +result = client.evaluation.faithfulness( + question="日本の首都はどこですか?", + answer="東京です。", + contexts=["日本の首都は東京である。"], +) + +print(result.metric) # "faithfulness" +print(result.score) # 0.95 +print(result.reason) # "回答はコンテキストに基づいています" +print(result.engine) # "genflux" +print(result.execution_time_seconds) # 2.34 +``` diff --git a/src/genflux/models/job.py b/src/genflux/models/job.py index 11d922c..d446a9e 100644 --- a/src/genflux/models/job.py +++ b/src/genflux/models/job.py @@ -100,7 +100,15 @@ def is_pending(self) -> bool: @dataclass class MetricResult: - """単一メトリックの評価結果。""" + """単一メトリックの評価結果。 + + Attributes: + metric: 評価メトリック名(例: "faithfulness", "answer_relevancy")。 + score: 評価スコア(0.0〜1.0)。 + reason: 評価理由の説明文。メトリックによっては None。 + engine: 評価エンジン識別子。現在は ``"genflux"`` が返される。 + execution_time_seconds: 評価の実行時間(秒)。取得できない場合は None。 + """ metric: str score: float