#!/usr/bin/env python3
import os
import sys
import io
from typing import List, Dict, Any, Optional, Tuple
from pydantic import BaseModel


# 请求模型
class TextInferenceRequest(BaseModel):
    user_prompt: str
    max_tokens: int = 200
    temperature: float = 0.7
    top_p: float = 0.95
    system_prompt: Optional[str] = None
    stop: Optional[List[str]] = None
    json_schema: Optional[Dict[str, Any]] = None  # JSON Schema 用于约束输出格式

class MultimodalInferenceRequest(BaseModel):
    user_prompt: str
    image_data: List[str]  # base64编码的图像数据列表
    max_tokens: int = 300
    temperature: float = 0.7
    top_p: float = 0.95
    system_prompt: Optional[str] = None
    stop: Optional[List[str]] = None

class InferenceRequest(BaseModel):
    user_prompt: str
    image_data: Optional[List[str]]=None  # base64编码的图像数据列表
    max_tokens: int = 300
    temperature: float = 0.7
    top_p: float = 0.95
    system_prompt: Optional[str] = None
    stop: Optional[List[str]] = None
    json_schema: Optional[Dict[str, Any]] = None  # JSON Schema 用于约束输出格式


# 响应模型定义
class InferenceResponse(BaseModel):
    result: str
    metadata: Dict[str, Any]

class HealthResponse(BaseModel):
    status: str
    model_loaded: bool
    process_id: int
    load_time: float
    model_path: str