169 lines
3.5 KiB
Python
169 lines
3.5 KiB
Python
from datetime import datetime
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class ProviderBase(BaseModel):
|
|
name: str
|
|
code: str
|
|
provider_type: str = "openai_compatible"
|
|
base_url: str = ""
|
|
api_key: str = ""
|
|
status: str = "enabled"
|
|
|
|
|
|
class ProviderOut(ProviderBase):
|
|
id: str
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ModelBase(BaseModel):
|
|
provider_id: str
|
|
name: str
|
|
display_name: str = ""
|
|
context_length: int = 8192
|
|
supports_streaming: bool = True
|
|
supports_function_call: bool = False
|
|
default_temperature: float = 0.7
|
|
default_max_tokens: int = 2048
|
|
status: str = "enabled"
|
|
|
|
|
|
class ModelOut(ModelBase):
|
|
id: str
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class AgentBase(BaseModel):
|
|
name: str
|
|
code: str
|
|
description: str = ""
|
|
avatar: str = ""
|
|
status: str = "draft"
|
|
persona: dict[str, Any] = {}
|
|
system_prompt: str = ""
|
|
model_id: str | None = None
|
|
temperature: float = 0.7
|
|
max_tokens: int = 2048
|
|
tools: list[Any] = []
|
|
knowledge_base_ids: list[str] = []
|
|
enable_memory: bool = True
|
|
memory_window: int = 10
|
|
|
|
|
|
class AgentOut(AgentBase):
|
|
id: str
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ChatIn(BaseModel):
|
|
message: str
|
|
conversation_id: str | None = None
|
|
|
|
|
|
class ConversationOut(BaseModel):
|
|
id: str
|
|
agent_id: str
|
|
title: str
|
|
total_tokens: int = 0
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class MessageOut(BaseModel):
|
|
id: str
|
|
conversation_id: str
|
|
role: str
|
|
content: str
|
|
status: str
|
|
total_tokens: int = 0
|
|
elapsed_time: int = 0
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class WorkflowBase(BaseModel):
|
|
name: str
|
|
code: str
|
|
description: str = ""
|
|
status: str = "draft"
|
|
definition: dict[str, Any] = {}
|
|
input_variables: list[Any] = []
|
|
output_variables: list[Any] = []
|
|
|
|
|
|
class WorkflowOut(WorkflowBase):
|
|
id: str
|
|
version: int
|
|
published_version: int | None = None
|
|
published_definition: dict[str, Any] = {}
|
|
run_count: int = 0
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class WorkflowRunIn(BaseModel):
|
|
inputs: dict[str, Any] = {}
|
|
|
|
|
|
class WorkflowRunOut(BaseModel):
|
|
id: str
|
|
workflow_id: str
|
|
status: str
|
|
inputs: dict[str, Any]
|
|
outputs: dict[str, Any]
|
|
execution_log: list[Any]
|
|
error_message: str = ""
|
|
total_tokens: int = 0
|
|
elapsed_time: int = 0
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class KnowledgeBaseIn(BaseModel):
|
|
name: str
|
|
code: str
|
|
description: str = ""
|
|
status: str = "enabled"
|
|
|
|
|
|
class KnowledgeBaseOut(KnowledgeBaseIn):
|
|
id: str
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class TeamBase(BaseModel):
|
|
name: str
|
|
code: str
|
|
description: str = ""
|
|
mode: str = "sequential"
|
|
members: list[dict[str, Any]] = []
|
|
status: str = "enabled"
|
|
|
|
|
|
class TeamOut(TeamBase):
|
|
id: str
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class CollaborationRunIn(BaseModel):
|
|
task: str
|
|
|
|
|
|
class CollaborationRunOut(BaseModel):
|
|
id: str
|
|
team_id: str
|
|
task: str
|
|
status: str
|
|
messages: list[Any]
|
|
final_answer: str
|
|
elapsed_time: int
|
|
created_at: datetime
|
|
model_config = ConfigDict(from_attributes=True)
|