270 lines
No EOL
15 KiB
Python
270 lines
No EOL
15 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import List, Dict, Any, Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class Label(BaseModel):
|
|
"""Label für ein Attribut oder eine Klasse mit Unterstützung für mehrere Sprachen"""
|
|
default: str
|
|
translations: Dict[str, str] = {}
|
|
|
|
def get_label(self, language: str = None):
|
|
"""Gibt das Label in der angegebenen Sprache zurück, oder den Standardwert wenn nicht verfügbar"""
|
|
if language and language in self.translations:
|
|
return self.translations[language]
|
|
return self.default
|
|
|
|
|
|
class Agent(BaseModel):
|
|
"""Datenmodell für einen Agenten"""
|
|
id: int = Field(description="Eindeutige ID des Agenten")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
name: str = Field(description="Name des Agenten")
|
|
type: str = Field(description="Typ des Agenten")
|
|
workspace_id: int = Field(description="ID des zugehörigen Workspaces")
|
|
capabilities: Optional[str] = Field(None, description="Fähigkeiten des Agenten")
|
|
description: Optional[str] = Field(None, description="Beschreibung des Agenten")
|
|
instructions: Optional[str] = Field(None, description="Anweisungen für den Agenten")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Agent", translations={"en": "Agent", "fr": "Agent"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"name": Label(default="Name", translations={"en": "Name", "fr": "Nom"}),
|
|
"type": Label(default="Typ", translations={"en": "Type", "fr": "Type"}),
|
|
"workspace_id": Label(default="Workspace-ID", translations={"en": "Workspace ID", "fr": "ID d'espace de travail"}),
|
|
"capabilities": Label(default="Fähigkeiten", translations={"en": "Capabilities", "fr": "Capacités"}),
|
|
"description": Label(default="Beschreibung", translations={"en": "Description", "fr": "Description"}),
|
|
"instructions": Label(default="Anweisungen", translations={"en": "Instructions", "fr": "Instructions"})
|
|
}
|
|
|
|
|
|
class DataObject(BaseModel):
|
|
"""Datenmodell für ein Datenobjekt"""
|
|
id: int = Field(description="Eindeutige ID des Datenobjekts")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
name: str = Field(description="Name des Datenobjekts")
|
|
type: str = Field(description="Typ des Datenobjekts ('document', 'image', etc.)")
|
|
size: Optional[str] = Field(None, description="Größe des Datenobjekts")
|
|
upload_date: Optional[str] = Field(None, description="Datum des Hochladens")
|
|
content_type: Optional[str] = Field(None, description="Content-Type des Datenobjekts")
|
|
path: Optional[str] = Field(None, description="Pfad zum Datenobjekt")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Datenobjekt", translations={"en": "Data Object", "fr": "Objet de données"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"name": Label(default="Name", translations={"en": "Name", "fr": "Nom"}),
|
|
"type": Label(default="Typ", translations={"en": "Type", "fr": "Type"}),
|
|
"size": Label(default="Größe", translations={"en": "Size", "fr": "Taille"}),
|
|
"upload_date": Label(default="Upload-Datum", translations={"en": "Upload date", "fr": "Date de téléchargement"}),
|
|
"content_type": Label(default="Content-Type", translations={"en": "Content type", "fr": "Type de contenu"}),
|
|
"path": Label(default="Pfad", translations={"en": "Path", "fr": "Chemin"})
|
|
}
|
|
|
|
|
|
class Prompt(BaseModel):
|
|
"""Datenmodell für einen Prompt"""
|
|
id: int = Field(description="Eindeutige ID des Prompts")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
content: str = Field(description="Inhalt des Prompts")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Prompt", translations={"en": "Prompt", "fr": "Invite"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"content": Label(default="Inhalt", translations={"en": "Content", "fr": "Contenu"}),
|
|
}
|
|
|
|
|
|
class Workspace(BaseModel):
|
|
"""Datenmodell für einen Workspace"""
|
|
id: int = Field(description="Eindeutige ID des Workspaces")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
name: str = Field(description="Name des Workspaces")
|
|
prompts: List[Prompt] = Field(default=[], description="Liste der Prompts im Workspace")
|
|
agents: List[Agent] = Field(default=[], description="Liste der Agenten im Workspace")
|
|
dataObjectReferences: List[int] = Field(default=[], description="Referenzen zu Datenobjekten")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Workspace", translations={"en": "Workspace", "fr": "Espace de travail"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"name": Label(default="Name", translations={"en": "Name", "fr": "Nom"}),
|
|
"prompts": Label(default="Prompts", translations={"en": "Prompts", "fr": "Invites"}),
|
|
"agents": Label(default="Agenten", translations={"en": "Agents", "fr": "Agents"}),
|
|
"dataObjectReferences": Label(default="Datenobjekte", translations={"en": "Data Objects", "fr": "Objets de données"})
|
|
}
|
|
|
|
|
|
class WorkflowRequest(BaseModel):
|
|
"""Anforderung zur Ausführung eines Workflows"""
|
|
id: int = Field(description="Eindeutige ID der Anforderung")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
workspace_id: int = Field(description="ID des zugehörigen Workspaces")
|
|
prompt: str = Field(description="Zu verwendender Prompt")
|
|
agents: List[int] = Field(description="Liste von Agent-IDs")
|
|
files: List[int] = Field(description="Liste von Datei-IDs")
|
|
workflow_name: Optional[str] = Field(None, description="Name des Workflows")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Workflow-Anforderung", translations={"en": "Workflow Request", "fr": "Demande de workflow"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"workspace_id": Label(default="Workspace-ID", translations={"en": "Workspace ID", "fr": "ID d'espace de travail"}),
|
|
"prompt": Label(default="Prompt", translations={"en": "Prompt", "fr": "Invite"}),
|
|
"agents": Label(default="Agenten", translations={"en": "Agents", "fr": "Agents"}),
|
|
"files": Label(default="Dateien", translations={"en": "Files", "fr": "Fichiers"}),
|
|
"workflow_name": Label(default="Workflow-Name", translations={"en": "Workflow name", "fr": "Nom du workflow"})
|
|
}
|
|
|
|
|
|
class WorkflowResponse(BaseModel):
|
|
"""Antwort nach dem Start eines Workflows"""
|
|
workflow_id: int = Field(description="ID des gestarteten Workflows")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
status: str = Field(description="Status des Workflows")
|
|
message: str = Field(description="Statusnachricht")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Workflow-Antwort", translations={"en": "Workflow Response", "fr": "Réponse de workflow"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"workflow_id": Label(default="Workflow-ID", translations={"en": "Workflow ID", "fr": "ID de workflow"}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"status": Label(default="Status", translations={"en": "Status", "fr": "État"}),
|
|
"message": Label(default="Nachricht", translations={"en": "Message", "fr": "Message"})
|
|
}
|
|
|
|
|
|
class LogEntry(BaseModel):
|
|
"""Protokolleintrag während der Workflow-Ausführung"""
|
|
id: int = Field(description="Eindeutige ID des Protokolleintrags")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
message: str = Field(description="Protokollnachricht")
|
|
type: str = Field(description="Typ des Eintrags ('info', 'error', 'start', 'complete', 'success')")
|
|
timestamp: str = Field(description="Zeitstempel des Eintrags")
|
|
agent_id: Optional[int] = Field(None, description="ID des zugehörigen Agenten")
|
|
agent_name: Optional[str] = Field(None, description="Name des zugehörigen Agenten")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Protokolleintrag", translations={"en": "Log Entry", "fr": "Entrée de journal"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"message": Label(default="Nachricht", translations={"en": "Message", "fr": "Message"}),
|
|
"type": Label(default="Typ", translations={"en": "Type", "fr": "Type"}),
|
|
"timestamp": Label(default="Zeitstempel", translations={"en": "Timestamp", "fr": "Horodatage"}),
|
|
"agent_id": Label(default="Agent-ID", translations={"en": "Agent ID", "fr": "ID d'agent"}),
|
|
"agent_name": Label(default="Agent-Name", translations={"en": "Agent name", "fr": "Nom d'agent"})
|
|
}
|
|
|
|
|
|
class Result(BaseModel):
|
|
"""Ergebnis eines Agenten während der Workflow-Ausführung"""
|
|
id: int = Field(description="Eindeutige ID des Ergebnisses")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
title: str = Field(description="Titel des Ergebnisses")
|
|
agent_id: int = Field(description="ID des zugehörigen Agenten")
|
|
agent_name: str = Field(description="Name des zugehörigen Agenten")
|
|
type: str = Field(description="Typ des Ergebnisses ('text', 'chart', 'image', etc.)")
|
|
content: str = Field(description="Inhalt des Ergebnisses")
|
|
timestamp: str = Field(description="Zeitstempel der Erstellung")
|
|
metadata: Optional[Dict[str, Any]] = Field(None, description="Zusätzliche Metadaten")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Ergebnis", translations={"en": "Result", "fr": "Résultat"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"title": Label(default="Titel", translations={"en": "Title", "fr": "Titre"}),
|
|
"agent_id": Label(default="Agent-ID", translations={"en": "Agent ID", "fr": "ID d'agent"}),
|
|
"agent_name": Label(default="Agent-Name", translations={"en": "Agent name", "fr": "Nom d'agent"}),
|
|
"type": Label(default="Typ", translations={"en": "Type", "fr": "Type"}),
|
|
"content": Label(default="Inhalt", translations={"en": "Content", "fr": "Contenu"}),
|
|
"timestamp": Label(default="Zeitstempel", translations={"en": "Timestamp", "fr": "Horodatage"}),
|
|
"metadata": Label(default="Metadaten", translations={"en": "Metadata", "fr": "Métadonnées"})
|
|
}
|
|
|
|
|
|
class WorkflowStatus(BaseModel):
|
|
"""Status eines Workflows"""
|
|
id: int = Field(description="Eindeutige ID des Workflow-Status")
|
|
mandate_id: int = Field(description="ID des zugehörigen Mandanten")
|
|
user_id: int = Field(description="ID des Erstellers")
|
|
name: Optional[str] = Field(None, description="Name des Workflows")
|
|
status: str = Field(description="Status des Workflows ('running', 'completed', 'failed')")
|
|
progress: float = Field(description="Fortschritt (0.0 - 1.0)")
|
|
started_at: str = Field(description="Startzeitpunkt")
|
|
completed_at: Optional[str] = Field(None, description="Abschlusszeitpunkt")
|
|
agent_statuses: Optional[Dict[str, str]] = Field(None, description="Status der einzelnen Agenten")
|
|
|
|
label: Label = Field(
|
|
default=Label(default="Workflow-Status", translations={"en": "Workflow Status", "fr": "État du workflow"}),
|
|
description="Label für die Klasse"
|
|
)
|
|
|
|
# Labels für Attribute
|
|
field_labels: Dict[str, Label] = {
|
|
"id": Label(default="ID", translations={}),
|
|
"mandate_id": Label(default="Mandanten-ID", translations={"en": "Mandate ID", "fr": "ID de mandat"}),
|
|
"user_id": Label(default="Benutzer-ID", translations={"en": "User ID", "fr": "ID d'utilisateur"}),
|
|
"name": Label(default="Name", translations={"en": "Name", "fr": "Nom"}),
|
|
"status": Label(default="Status", translations={"en": "Status", "fr": "État"}),
|
|
"progress": Label(default="Fortschritt", translations={"en": "Progress", "fr": "Progrès"}),
|
|
"started_at": Label(default="Gestartet am", translations={"en": "Started at", "fr": "Démarré le"}),
|
|
"completed_at": Label(default="Abgeschlossen am", translations={"en": "Completed at", "fr": "Terminé le"}),
|
|
"agent_statuses": Label(default="Agent-Status", translations={"en": "Agent status", "fr": "État des agents"})
|
|
} |