Spaces:
Runtime error
Runtime error
add gemini 3
Browse filesFiles changed (5)
57 unmodified lines585960616263649 unmodified lines7475767778798021 unmodified lines10210310410510610710810 unmodified lines11912012112212312412512612712812957 unmodified lines1. **Backend**:```bashexport HF_TOKEN="your_huggingface_token"export GEMINI_API_KEY="your_gemini_api_key"python backend_api.py```
9 unmodified lines### Using start script:```bashexport HF_TOKEN="your_token"export GEMINI_API_KEY="your_gemini_api_key"./start_fullstack.sh```
21 unmodified lines
## 🤖 Available Models
- **Gemini 3 Pro Preview** (Default) - Google's latest with deep thinking & Google Search- MiniMax M2 (via HF router with Novita)- DeepSeek V3/V3.1- DeepSeek R110 unmodified lines## 🛠️ Environment Variables
- `HF_TOKEN` - HuggingFace API token (required)- `GEMINI_API_KEY` - Google Gemini API key (required for Gemini 3 Pro Preview)- `POE_API_KEY` - Poe API key (optional, for GPT-5 and Claude models)- `DASHSCOPE_API_KEY` - DashScope API key (optional, for Qwen models)- `OPENROUTER_API_KEY` - OpenRouter API key (optional, for Sherlock models)- `MISTRAL_API_KEY` - Mistral API key (optional, for Mistral models)
## 📦 Tech Stack
46 unmodified lines474849505152535455565799 unmodified lines15715815915516016116216346 unmodified lines
# Available Models ConfigurationAVAILABLE_MODELS = [ { "name": "Gemini 3 Pro Preview", "id": "gemini-3-pro-preview", "description": "Google Gemini 3 Pro Preview with deep thinking, Google Search integration, and advanced reasoning" }, { "name": "DeepSeek V3.2-Exp", "id": "deepseek-ai/DeepSeek-V3.2-Exp",99 unmodified linesk2_model_name_tag = "moonshotai/Kimi-K2-Thinking"
# Default model selectionDEFAULT_MODEL_NAME = "Sherlock Dash Alpha"DEFAULT_MODEL_NAME = "Gemini 3 Pro Preview"DEFAULT_MODEL = Nonefor _m in AVAILABLE_MODELS: if _m.get("name") == DEFAULT_MODEL_NAME:419 unmodified lines42042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645742445845946046151 unmodified lines513514515516517518519482520521522523419 unmodified lines messages.append({'role': 'user', 'content': enhanced_query}) try: # Handle Gemini 3 Pro Preview with native SDK if _current_model["id"] == "gemini-3-pro-preview": # Convert messages to Gemini format from google.genai import types contents = [] for msg in messages: if msg['role'] != 'system': # Gemini doesn't use system role the same way contents.append( types.Content( role="user" if msg['role'] == 'user' else "model", parts=[types.Part.from_text(text=msg['content'])] ) ) # Add system prompt as first user message if exists if messages and messages[0]['role'] == 'system': system_content = messages[0]['content'] contents.insert(0, types.Content( role="user", parts=[types.Part.from_text(text=f"System instructions: {system_content}")] )) tools = [types.Tool(googleSearch=types.GoogleSearch())] generate_content_config = types.GenerateContentConfig( thinkingConfig=types.ThinkingConfig(thinkingLevel="HIGH"), tools=tools, max_output_tokens=16384 ) completion = client.models.generate_content_stream( model="gemini-3-pro-preview", contents=contents, config=generate_content_config, ) # Handle Mistral API method difference if _current_model["id"] in ("codestral-2508", "mistral-medium-2508"): elif _current_model["id"] in ("codestral-2508", "mistral-medium-2508"): completion = client.chat.stream( model=get_real_model_id(_current_model["id"]), messages=messages,51 unmodified lines for chunk in completion: # Handle different response formats for Mistral vs others chunk_content = None if _current_model["id"] == "gemini-3-pro-preview": # Gemini native SDK format: chunk.text if hasattr(chunk, 'text') and chunk.text: chunk_content = chunk.text if _current_model["id"] in ("codestral-2508", "mistral-medium-2508"): elif _current_model["id"] in ("codestral-2508", "mistral-medium-2508"): # Mistral format: chunk.data.choices[0].delta.content if ( hasattr(chunk, "data") and chunk.data and10 unmodified lines11121314151617183 unmodified lines2223242526272829233031323310 unmodified linesfrom openai import OpenAIfrom mistralai import Mistralimport dashscopefrom google import genaifrom google.genai import types
from .config import HF_TOKEN, AVAILABLE_MODELS
3 unmodified lines
def get_inference_client(model_id, provider="auto"): """Return an InferenceClient with provider based on model_id and user selection.""" if model_id == "gemini-3-pro-preview": # Use native Google GenAI client for Gemini 3 Pro Preview return genai.Client( api_key=os.getenv("GEMINI_API_KEY"), ) if model_id == "qwen3-30b-a3b-instruct-2507": elif model_id == "qwen3-30b-a3b-instruct-2507": # Use DashScope OpenAI client return OpenAI( api_key=os.getenv("DASHSCOPE_API_KEY"),11 unmodified lines12131415151611 unmodified lineshtml2textopenaimistralaidashscopedashscopegoogle-genaiREADME.md+8
anycoder_app/config.py+6-1
anycoder_app/deploy.py+40-2
anycoder_app/models.py+8-1
requirements.txt+2-1