carrot model
Browse files1460 unmodified lines14611462146314641465146614671468146914701471152 unmodified lines16241625162616221627162816291630140 unmodified lines1771177217731774177517761777177817791780178117821783178417851786178717881789179020 unmodified lines1811181218131814181518161817181818191820182118221823182418251826182718283366 unmodified lines519551965197516751985199520052011 unmodified line520352045205517552065207520852091 unmodified line5211521252135183521452155216521761 unmodified lines52795280528152825283528452515285528652875288335 unmodified lines5624562556265593562756285629563023 unmodified lines565456555656562356575658565956601460 unmodified lines "id": "kimi-k2-turbo-preview", "description": "Moonshot AI Kimi K2 Turbo via OpenAI-compatible API" }, { "name": "Carrot", "id": "stealth-model-1", "description": "High-performance AI model for code generation and complex reasoning tasks" }, { "name": "DeepSeek V3", "id": "deepseek-ai/DeepSeek-V3-0324",152 unmodified lines]
# Default model selectionDEFAULT_MODEL_NAME = "Qwen3-Coder-480B-A35B-Instruct"DEFAULT_MODEL_NAME = "Carrot"DEFAULT_MODEL = Nonefor _m in AVAILABLE_MODELS: if _m.get("name") == DEFAULT_MODEL_NAME:140 unmodified lines api_key=os.getenv("MOONSHOT_API_KEY"), base_url="https://api.moonshot.ai/v1", ) elif model_id == "stealth-model-1": # Use stealth model with generic configuration api_key = os.getenv("STEALTH_MODEL_1_API_KEY") if not api_key: raise ValueError("STEALTH_MODEL_1_API_KEY environment variable is required for Carrot model") base_url = os.getenv("STEALTH_MODEL_1_BASE_URL") if not base_url: raise ValueError("STEALTH_MODEL_1_BASE_URL environment variable is required for Carrot model") return OpenAI( api_key=api_key, base_url=base_url, ) elif model_id == "openai/gpt-oss-120b": provider = "groq" elif model_id == "openai/gpt-oss-20b":20 unmodified lines bill_to="huggingface" )
# Helper function to get real model ID for stealth modelsdef get_real_model_id(model_id: str) -> str: """Get the real model ID, checking environment variables for stealth models""" if model_id == "stealth-model-1": # Get the real model ID from environment variable real_model_id = os.getenv("STEALTH_MODEL_1_ID") if not real_model_id: raise ValueError("STEALTH_MODEL_1_ID environment variable is required for Carrot model") return real_model_id return model_id
# Type definitionsHistory = List[Tuple[str, str]]Messages = List[Dict[str, str]]3366 unmodified lines # Generate search/replace instructions if _current_model.get('type') == 'openai': response = client.chat.completions.create( model=_current_model['id'], model=get_real_model_id(_current_model['id']), messages=messages, max_tokens=4000, temperature=0.11 unmodified line changes_text = response.choices[0].message.content elif _current_model.get('type') == 'mistral': response = client.chat.complete( model=_current_model['id'], model=get_real_model_id(_current_model['id']), messages=messages, max_tokens=4000, temperature=0.11 unmodified line changes_text = response.choices[0].message.content else: # Hugging Face or other completion = client.chat.completions.create( model=_current_model['id'], model=get_real_model_id(_current_model['id']), messages=messages, max_tokens=4000, temperature=0.161 unmodified lines update_gradio_system_prompts()
# Choose system prompt based on context # Special case: If user is asking about model identity, use neutral prompt if query and any(phrase in query.lower() for phrase in ["what model are you", "who are you", "identify yourself", "what ai are you", "which model"]): system_prompt = "You are a helpful AI assistant. Please respond truthfully about your identity and capabilities." if has_existing_content: elif has_existing_content: # Use follow-up prompt for modifying existing content if language == "transformers.js": system_prompt = TransformersJSFollowUpSystemPrompt335 unmodified lines # Handle Mistral API method difference if _current_model["id"] in ("codestral-2508", "mistral-medium-2508"): completion = client.chat.stream( model=_current_model["id"], model=get_real_model_id(_current_model["id"]), messages=messages, max_tokens=16384 )23 unmodified lines ) else: completion = client.chat.completions.create( model=_current_model["id"], model=get_real_model_id(_current_model["id"]), messages=messages, stream=True, max_tokens=16384app.py+41-7