agentscope.classifierOpenAIClassifierModel
class OpenAIClassifierModel(ClassifierModelBase)
agentscope/classifier/_openai/_model.py:125–224OpenAI 分类器模型,与模型服务通信并返回生成或向量化结果。位于 agentscope.classifier 包,继承自 ClassifierModelBase。
Requires openai>=3.26.0. Binary questions map to predicates; choice
and score questions retain their alternatives and ordered levels.
When instructions are omitted, the question name is used instead.
Binary criteria are appended to the instructions as true/false outcomes.
Refusals are returned as :class:RefusalAnswer for the affected question,
alongside any other answers from the same request.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Parameters | 类class | 参数,与模型服务通信并返回生成或向量化结果。 Provider-specific classifier parameters. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(credential: OpenAICredential, model: str = 'gpt-6-luna', parameters: 'OpenAIClassifierModel.Parameters | N… | 初始化 `OpenAIClassifierModel` 实例。 Initialize the classifier and its reusable OpenAI client. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def __call__(state: str | dict | list[TextBlock | DataBlock], questions: Mapping[str, ClassifierQuestion], **kwar…async | 以可调用对象方式执行。 Evaluate questions about text, JSON, or inline images. |
构造器详情Constructor Detail
OpenAIClassifierModel
def __init__(credential: OpenAICredential, model: str = 'gpt-6-luna', parameters: 'OpenAIClassifierModel.Parameters | None' = None, timeout: float = 30.0, max_retries: int = 2) -> None
初始化 OpenAIClassifierModel 实例。
Initialize the classifier and its reusable OpenAI client.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
credential | OpenAICredential | 凭证对象(类型 `OpenAICredential`)。API key, optional organization and custom endpoint. |
model默认default 'gpt-6-luna' | str | 模型实例(类型 `str`)。The model name accepted by the Decisions endpoint. |
parameters默认default None | 'OpenAIClassifierModel.Parameters | None' | 参数(类型 `'OpenAIClassifierModel.Parameters | None'`)。Provider-specific classifier parameters. |
timeout默认default 30.0 | float | 超时时间(类型 `float`)。Per-request timeout in seconds. |
max_retries默认default 2 | int | 最大重试次数(类型 `int`)。Maximum retries after the initial request, handled by the SDK. |
agentscope/classifier/_openai/_model.py:142–176方法详情Method Detail
__call__
async def __call__(state: str | dict | list[TextBlock | DataBlock], questions: Mapping[str, ClassifierQuestion], **kwargs: Any) -> ClassifierResponse
以可调用对象方式执行。
Evaluate questions about text, JSON, or inline images.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | str | dict | list[TextBlock | DataBlock] | 状态对象(类型 `str | dict | list[TextBlock | DataBlock]`)。Shared evidence. Dictionaries are serialized as JSON text. Content lists preserve order and support text plus image blocks with :class:`Base64Source`. URL sources and other media types are not supported. |
questions | Mapping[str, ClassifierQuestion] | questions(类型 `Mapping[str, ClassifierQuestion]`)。Typed questions keyed by their names. |
kwargs | Any | 关键字参数(类型 `Any`)。The kwargs. |
agentscope/classifier/_openai/_model.py:178–224嵌套类详情Nested Class Detail
Parameters
class Parameters参数,与模型服务通信并返回生成或向量化结果。位于 agentscope.classifier 包,继承自 ClassifierModelBase.Parameters。
Provider-specific classifier parameters. Declared in agentscope.classifier. Extends ClassifierModelBase.Parameters.