akhaliq HF Staff commited on
Commit
05189c4
·
1 Parent(s): 31e58b5

carrot model

Browse files
Files changed (1) hide show
  1. app.py +41 -7
app.py CHANGED
@@ -1461,6 +1461,11 @@ AVAILABLE_MODELS = [
1461
  "id": "kimi-k2-turbo-preview",
1462
  "description": "Moonshot AI Kimi K2 Turbo via OpenAI-compatible API"
1463
  },
 
 
 
 
 
1464
  {
1465
  "name": "DeepSeek V3",
1466
  "id": "deepseek-ai/DeepSeek-V3-0324",
@@ -1619,7 +1624,7 @@ AVAILABLE_MODELS = [
1619
  ]
1620
 
1621
  # Default model selection
1622
- DEFAULT_MODEL_NAME = "Qwen3-Coder-480B-A35B-Instruct"
1623
  DEFAULT_MODEL = None
1624
  for _m in AVAILABLE_MODELS:
1625
  if _m.get("name") == DEFAULT_MODEL_NAME:
@@ -1766,6 +1771,20 @@ def get_inference_client(model_id, provider="auto"):
1766
  api_key=os.getenv("MOONSHOT_API_KEY"),
1767
  base_url="https://api.moonshot.ai/v1",
1768
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1769
  elif model_id == "openai/gpt-oss-120b":
1770
  provider = "groq"
1771
  elif model_id == "openai/gpt-oss-20b":
@@ -1792,6 +1811,18 @@ def get_inference_client(model_id, provider="auto"):
1792
  bill_to="huggingface"
1793
  )
1794
 
 
 
 
 
 
 
 
 
 
 
 
 
1795
  # Type definitions
1796
  History = List[Tuple[str, str]]
1797
  Messages = List[Dict[str, str]]
@@ -5164,7 +5195,7 @@ Generate the exact search/replace blocks needed to make these changes."""
5164
  # Generate search/replace instructions
5165
  if _current_model.get('type') == 'openai':
5166
  response = client.chat.completions.create(
5167
- model=_current_model['id'],
5168
  messages=messages,
5169
  max_tokens=4000,
5170
  temperature=0.1
@@ -5172,7 +5203,7 @@ Generate the exact search/replace blocks needed to make these changes."""
5172
  changes_text = response.choices[0].message.content
5173
  elif _current_model.get('type') == 'mistral':
5174
  response = client.chat.complete(
5175
- model=_current_model['id'],
5176
  messages=messages,
5177
  max_tokens=4000,
5178
  temperature=0.1
@@ -5180,7 +5211,7 @@ Generate the exact search/replace blocks needed to make these changes."""
5180
  changes_text = response.choices[0].message.content
5181
  else: # Hugging Face or other
5182
  completion = client.chat.completions.create(
5183
- model=_current_model['id'],
5184
  messages=messages,
5185
  max_tokens=4000,
5186
  temperature=0.1
@@ -5248,7 +5279,10 @@ Generate the exact search/replace blocks needed to make these changes."""
5248
  update_gradio_system_prompts()
5249
 
5250
  # Choose system prompt based on context
5251
- if has_existing_content:
 
 
 
5252
  # Use follow-up prompt for modifying existing content
5253
  if language == "transformers.js":
5254
  system_prompt = TransformersJSFollowUpSystemPrompt
@@ -5590,7 +5624,7 @@ This will help me create a better design for you."""
5590
  # Handle Mistral API method difference
5591
  if _current_model["id"] in ("codestral-2508", "mistral-medium-2508"):
5592
  completion = client.chat.stream(
5593
- model=_current_model["id"],
5594
  messages=messages,
5595
  max_tokens=16384
5596
  )
@@ -5620,7 +5654,7 @@ This will help me create a better design for you."""
5620
  )
5621
  else:
5622
  completion = client.chat.completions.create(
5623
- model=_current_model["id"],
5624
  messages=messages,
5625
  stream=True,
5626
  max_tokens=16384
 
1461
  "id": "kimi-k2-turbo-preview",
1462
  "description": "Moonshot AI Kimi K2 Turbo via OpenAI-compatible API"
1463
  },
1464
+ {
1465
+ "name": "Carrot",
1466
+ "id": "stealth-model-1",
1467
+ "description": "High-performance AI model for code generation and complex reasoning tasks"
1468
+ },
1469
  {
1470
  "name": "DeepSeek V3",
1471
  "id": "deepseek-ai/DeepSeek-V3-0324",
 
1624
  ]
1625
 
1626
  # Default model selection
1627
+ DEFAULT_MODEL_NAME = "Carrot"
1628
  DEFAULT_MODEL = None
1629
  for _m in AVAILABLE_MODELS:
1630
  if _m.get("name") == DEFAULT_MODEL_NAME:
 
1771
  api_key=os.getenv("MOONSHOT_API_KEY"),
1772
  base_url="https://api.moonshot.ai/v1",
1773
  )
1774
+ elif model_id == "stealth-model-1":
1775
+ # Use stealth model with generic configuration
1776
+ api_key = os.getenv("STEALTH_MODEL_1_API_KEY")
1777
+ if not api_key:
1778
+ raise ValueError("STEALTH_MODEL_1_API_KEY environment variable is required for Carrot model")
1779
+
1780
+ base_url = os.getenv("STEALTH_MODEL_1_BASE_URL")
1781
+ if not base_url:
1782
+ raise ValueError("STEALTH_MODEL_1_BASE_URL environment variable is required for Carrot model")
1783
+
1784
+ return OpenAI(
1785
+ api_key=api_key,
1786
+ base_url=base_url,
1787
+ )
1788
  elif model_id == "openai/gpt-oss-120b":
1789
  provider = "groq"
1790
  elif model_id == "openai/gpt-oss-20b":
 
1811
  bill_to="huggingface"
1812
  )
1813
 
1814
+ # Helper function to get real model ID for stealth models
1815
+ def get_real_model_id(model_id: str) -> str:
1816
+ """Get the real model ID, checking environment variables for stealth models"""
1817
+ if model_id == "stealth-model-1":
1818
+ # Get the real model ID from environment variable
1819
+ real_model_id = os.getenv("STEALTH_MODEL_1_ID")
1820
+ if not real_model_id:
1821
+ raise ValueError("STEALTH_MODEL_1_ID environment variable is required for Carrot model")
1822
+
1823
+ return real_model_id
1824
+ return model_id
1825
+
1826
  # Type definitions
1827
  History = List[Tuple[str, str]]
1828
  Messages = List[Dict[str, str]]
 
5195
  # Generate search/replace instructions
5196
  if _current_model.get('type') == 'openai':
5197
  response = client.chat.completions.create(
5198
+ model=get_real_model_id(_current_model['id']),
5199
  messages=messages,
5200
  max_tokens=4000,
5201
  temperature=0.1
 
5203
  changes_text = response.choices[0].message.content
5204
  elif _current_model.get('type') == 'mistral':
5205
  response = client.chat.complete(
5206
+ model=get_real_model_id(_current_model['id']),
5207
  messages=messages,
5208
  max_tokens=4000,
5209
  temperature=0.1
 
5211
  changes_text = response.choices[0].message.content
5212
  else: # Hugging Face or other
5213
  completion = client.chat.completions.create(
5214
+ model=get_real_model_id(_current_model['id']),
5215
  messages=messages,
5216
  max_tokens=4000,
5217
  temperature=0.1
 
5279
  update_gradio_system_prompts()
5280
 
5281
  # Choose system prompt based on context
5282
+ # Special case: If user is asking about model identity, use neutral prompt
5283
+ 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"]):
5284
+ system_prompt = "You are a helpful AI assistant. Please respond truthfully about your identity and capabilities."
5285
+ elif has_existing_content:
5286
  # Use follow-up prompt for modifying existing content
5287
  if language == "transformers.js":
5288
  system_prompt = TransformersJSFollowUpSystemPrompt
 
5624
  # Handle Mistral API method difference
5625
  if _current_model["id"] in ("codestral-2508", "mistral-medium-2508"):
5626
  completion = client.chat.stream(
5627
+ model=get_real_model_id(_current_model["id"]),
5628
  messages=messages,
5629
  max_tokens=16384
5630
  )
 
5654
  )
5655
  else:
5656
  completion = client.chat.completions.create(
5657
+ model=get_real_model_id(_current_model["id"]),
5658
  messages=messages,
5659
  stream=True,
5660
  max_tokens=16384