37 lines
1.8 KiB
Python
37 lines
1.8 KiB
Python
# Copyright 2026 zhaoxi826
|
||
#
|
||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||
# you may not use this file except in compliance with the License.
|
||
# You may obtain a copy of the License at
|
||
#
|
||
# http://www.apache.org/licenses/LICENSE-2.0
|
||
#
|
||
# Unless required by applicable law or agreed to in writing, software
|
||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
# See the License for the specific language governing permissions and
|
||
# limitations under the License.
|
||
|
||
from typing import Dict, Any, Literal
|
||
from pydantic import BaseModel, Field
|
||
|
||
# --- 1. 给 Individual (LLM/Agent) 的具体需求 ---
|
||
class IndividualDemand(BaseModel):
|
||
role_prompt: str = Field(..., description="赋予该个体的角色定义")
|
||
task_goal: str = Field(..., description="该个体的具体执行目标")
|
||
expected_output: str = Field(..., description="期望产出的数据结构或格式描述")
|
||
|
||
# --- 2. 给 Tool (插件/函数调用) 的具体需求 ---
|
||
class ToolDemand(BaseModel):
|
||
method: str = Field(..., description="插件调用的具体方法名")
|
||
args: Dict[str, Any] = Field(default_factory=dict, description="传递给插件的参数")
|
||
|
||
# --- 3. 给 System (系统/物理资源) 的具体需求 ---
|
||
class SystemDemand(BaseModel):
|
||
operation: Literal["allocate_resource", "docker_manage", "file_io", "network"]
|
||
params: Dict[str, Any] = Field(..., description="操作所需的物理参数,如 GPU 核心数、路径等")
|
||
|
||
# --- 4. 统一需求入口 (裁判官协议体) ---
|
||
class DemandProtocol(BaseModel):
|
||
variety: Literal["individual", "tool", "system"]
|
||
name: str = Field(..., description="目标名称(如:python_expert, pytest_tool, docker_engine)") |