Update api/provider/gizai.py
Browse files123456789101112131415161718192021222324252627282930313233343536373834 unmodified lines7374757677786 unmodified lines8586878889909192import uuidfrom datetime import datetimeimport jsonfrom typing import Any, Dict, Optionalimport httpxfrom fastapi import HTTPExceptionfrom api.models import ChatRequestfrom api.logger import setup_loggerlogger = 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.aiGIZAI_CHAT_MODELS = ['chat-gemini-flash','chat-gemini-pro',34 unmodified lines}def get_gizai_model(model: str) -> str:if model in GIZAI_MODELS:return modelelif model in GIZAI_MODEL_ALIASES:6 unmodified linesreturn model in GIZAI_IMAGE_MODELSasync def process_streaming_response(request: ChatRequest):# giz.ai does not support streaming# So we can raise an error or process as non-streamingreturn await process_non_streaming_response(request)async def process_non_streaming_response(request: ChatRequest):123456789101112131415161734 unmodified lines525354555657586 unmodified lines65666768697071import uuidfrom datetime import datetimeimport jsonfrom typing import Any, Dictimport httpxfrom fastapi import HTTPExceptionfrom api.models import ChatRequestfrom api.logger import setup_loggerfrom api.config import MODEL_MAPPING, GIZAI_API_ENDPOINT, GIZAI_HEADERSlogger = setup_logger(__name__)# 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 modelelif model in GIZAI_MODEL_ALIASES:6 unmodified linesreturn model in GIZAI_IMAGE_MODELSasync def process_streaming_response(request: ChatRequest):# GizAI does not support streaming; handle as non-streamingreturn await process_non_streaming_response(request)async def process_non_streaming_response(request: ChatRequest):
api/provider/gizai.py+5-26