38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
|
|
"""Pydantic-Schema für hardcoded Agents.
|
||
|
|
|
||
|
|
Beispiel:
|
||
|
|
# agents/recherche.py
|
||
|
|
from agents.base import BaseAgent, AgentConfig
|
||
|
|
|
||
|
|
class RechercheAgent(BaseAgent):
|
||
|
|
config = AgentConfig(
|
||
|
|
id="recherche",
|
||
|
|
name="Recherche-Assistent",
|
||
|
|
description="Recherchiert Themen und fasst zusammen.",
|
||
|
|
system_prompt="Du bist ein Recherche-Assistent...",
|
||
|
|
allowed_tools=["http_get"],
|
||
|
|
)
|
||
|
|
"""
|
||
|
|
from abc import ABC
|
||
|
|
from typing import List, Optional
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class AgentConfig(BaseModel):
|
||
|
|
"""Type-safe Definition eines hardcoded Agents."""
|
||
|
|
id: str = Field(..., pattern=r'^[a-z0-9_-]+$', min_length=1, max_length=64)
|
||
|
|
name: str = Field(..., min_length=1)
|
||
|
|
description: str = ""
|
||
|
|
system_prompt: str = Field(..., min_length=1)
|
||
|
|
allowed_tools: List[str] = []
|
||
|
|
enabled: bool = True
|
||
|
|
|
||
|
|
model: Optional[str] = None
|
||
|
|
temperature: float = Field(default=0.7, ge=0.0, le=2.0)
|
||
|
|
max_tokens: int = Field(default=2000, ge=100, le=32000)
|
||
|
|
|
||
|
|
|
||
|
|
class BaseAgent(ABC):
|
||
|
|
"""Marker-Base für Code-Agents. Setze `config` als Class-Variable."""
|
||
|
|
config: AgentConfig
|