Update api/provider/gizai.py
Browse files12344567891011121313141516171819202122232425262728293031323334351415161734 unmodified lines525354555657586 unmodified lines656667888968697071import uuidfrom datetime import datetimeimport jsonfrom typing import Any, Dict, Optionalfrom typing import Any, Dict
import httpxfrom fastapi import HTTPExceptionfrom api.models import ChatRequestfrom api.logger import setup_loggerfrom api.config import MODEL_MAPPING, GIZAI_API_ENDPOINT, GIZAI_HEADERS
logger = setup_logger(__name__)
# Base URL for giz.aiGIZAI_BASE_URL = "https://app.giz.ai"GIZAI_API_ENDPOINT = f"{GIZAI_BASE_URL}/api/data/users/inferenceServer.infer"
# Headers for giz.aiGIZAI_HEADERS = { 'Accept': 'application/json, text/plain, */*', 'Accept-Language': 'en-US,en;q=0.9', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Origin': 'https://app.giz.ai', 'Pragma': 'no-cache', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36', 'sec-ch-ua': '"Not?A_Brand";v="99", "Chromium";v="130"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Linux"'}
# List of models supported by giz.ai# List of models supported by GizAIGIZAI_CHAT_MODELS = [ 'chat-gemini-flash', 'chat-gemini-pro',34 unmodified lines}
def get_gizai_model(model: str) -> str: model = MODEL_MAPPING.get(model, model) if model in GIZAI_MODELS: return model elif model in GIZAI_MODEL_ALIASES:6 unmodified lines return model in GIZAI_IMAGE_MODELS
async def process_streaming_response(request: ChatRequest): # giz.ai does not support streaming # So we can raise an error or process as non-streaming # GizAI does not support streaming; handle as non-streaming return await process_non_streaming_response(request)
async def process_non_streaming_response(request: ChatRequest):api/provider/gizai.py+5-26