AI4SE_Practices/AI4SE-survey/api/schemas/tool.py

142 lines
3.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
工具相关的数据模型
"""
from datetime import datetime
from typing import List, Optional, Dict, Any
from enum import Enum
from pydantic import BaseModel, Field, HttpUrl
class ToolType(str, Enum):
"""工具类型枚举"""
REQUIREMENTS_ANALYSIS = "requirements-analysis"
ARCHITECTURE_DESIGN = "architecture-design"
CODE_GENERATION = "code-generation"
DEBUGGING = "debugging"
REFACTORING = "refactoring"
TEST_GENERATION = "test-generation"
DOCUMENTATION = "documentation"
CODE_REVIEW = "code-review"
PROJECT_MANAGEMENT = "project-management"
DEVOPS_CI_CD = "devops-ci-cd"
LOCAL_MODELS = "local-models"
FULL_FLOW = "full-flow"
class PricingType(str, Enum):
"""定价类型"""
FREE = "free"
PAID = "paid"
OPEN_SOURCE = "open-source"
FREEMIUM = "freemium"
class DeploymentType(str, Enum):
"""部署类型"""
CLOUD = "cloud"
LOCAL = "local"
HYBRID = "hybrid"
class LanguageSupport(BaseModel):
"""语言支持"""
python: Optional[bool] = False
javascript: Optional[bool] = False
typescript: Optional[bool] = False
java: Optional[bool] = False
go: Optional[bool] = False
rust: Optional[bool] = False
cpp: Optional[bool] = False
other: Optional[List[str]] = []
class VersionInfo(BaseModel):
"""版本信息"""
version: str
release_date: Optional[str] = None
last_updated: Optional[str] = None
class PricingInfo(BaseModel):
"""定价信息"""
type: PricingType
free_tier: Optional[str] = None
paid_tier: Optional[str] = None
price: Optional[str] = None
open_source_license: Optional[str] = None
class WebsiteInfo(BaseModel):
"""网站信息"""
official: Optional[HttpUrl] = None
github: Optional[HttpUrl] = None
docs: Optional[HttpUrl] = None
class ToolBase(BaseModel):
"""工具基础模型"""
name: str = Field(..., description="工具名称")
type: ToolType = Field(..., description="工具类型")
category: str = Field(..., description="工具分类")
description: str = Field(..., description="工具简介")
website: Optional[WebsiteInfo] = None
pricing: Optional[PricingInfo] = None
model_base: Optional[str] = Field(None, description="底层模型如GPT-4、CodeLlama等")
model_version: Optional[str] = None
language_support: Optional[LanguageSupport] = None
deployment: Optional[DeploymentType] = None
version: Optional[VersionInfo] = None
features: Optional[List[str]] = []
suitable_scenarios: Optional[List[str]] = []
unsuitable_scenarios: Optional[List[str]] = []
class ToolOverview(ToolBase):
"""工具概览"""
id: str = Field(..., description="工具ID")
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
class ToolDetail(ToolOverview):
"""工具详细信息"""
setup_guide: Optional[str] = None
test_results: Optional[List[Dict[str, Any]]] = []
pros: Optional[List[str]] = []
cons: Optional[List[str]] = []
screenshots: Optional[List[str]] = []
class ToolListResponse(BaseModel):
"""工具列表响应"""
total: int
tools: List[ToolOverview]
page: int = 1
page_size: int = 20
class ToolFilter(BaseModel):
"""工具筛选条件"""
type: Optional[ToolType] = None
category: Optional[str] = None
pricing_type: Optional[PricingType] = None
deployment: Optional[DeploymentType] = None
language: Optional[str] = None
search: Optional[str] = None
class ToolCreate(ToolBase):
"""创建工具请求"""
pass
class ToolUpdate(BaseModel):
"""更新工具请求"""
name: Optional[str] = None
description: Optional[str] = None
version: Optional[VersionInfo] = None
features: Optional[List[str]] = None
pros: Optional[List[str]] = None
cons: Optional[List[str]] = None