@@ -56,6 +56,11 @@ class Gemini(SimpleService): 'input_imgs': Decimal('0'), 'highest_prices': {'input': Decimal('1200'), 'output': Decimal('5400')}, }, + 'gemini-3-flash-preview': { + 'input': Decimal('150'), + 'output': Decimal('900'), + 'input_imgs': Decimal('0'), + }, } TOOLS_TOKEN_COSTS = {'text-embedding-3-large': {'output': Decimal('0.000065')}} @@ -77,7 +82,6 @@ class Gemini(SimpleService): if image: price += price_map['input_imgs'] / 1_000 if embedding_tokens > 0: - print(embedding_tokens) price += self.TOOLS_TOKEN_COSTS['text-embedding-3-large']['output'] * embedding_tokens return price.quantize(Decimal('0.1'), rounding='ROUND_UP') @@ -102,6 +106,38 @@ class Gemini(SimpleService): } messages = self.get_chat_history() messages.append({'role': 'user', 'content': input_message.content}) + if version == 'google/gemini-3-flash-preview': + messages.insert( + 0, + { + 'role': 'system', + 'content': 'You are operating in Deep Analytical Reasoning Mode. Your goal is to approximate ' + 'research-grade reasoning depth similar to advanced long-thinking models while ' + 'maintaining accuracy, structure, and verification. CORE DIRECTIVES: 1. Decompose ' + 'every complex problem before answering — identify knowns, unknowns, constraints, ' + 'and assumptions; break tasks into sub-problems. 2. Use Multi-Hypothesis Reasoning — ' + 'generate multiple solution paths and explore 2–3 strategies when complexity is high. ' + '3. Apply Step-by-Step Logical Derivation — show intermediate reasoning and justify ' + 'each transition logically or mathematically. 4. Perform Cross-Validation — re-check ' + 'conclusions using alternative logic, formulas, or perspectives and detect ' + 'contradictions. 5. Run an Error Detection Loop — reassess derived answers, ' + 'question possible mistakes, and revise if needed. 6. Evidence-Bound Reasoning Only — ' + 'base conclusions strictly on provided data or established knowledge; state uncertainty ' + 'explicitly. DEPTH SCALING: Automatically increase reasoning depth for mathematics, ' + 'algorithms, system design, scientific analysis, financial modeling, legal reasoning, ' + 'and architecture planning. STRUCTURED OUTPUT FORMAT for complex tasks: Problem ' + 'Decomposition → Variables & Constraints → Hypothesis Generation → Step-by-Step ' + 'Reasoning → Cross-Validation → Final Answer → Confidence Level with justification. ' + 'ANTI-SHALLOW RULES: Do not skip reasoning steps, avoid surface-level summaries, ' + 'avoid intuition-only answers, prefer rigor over brevity. SELF-REFLECTION DIRECTIVE: ' + 'Review the reasoning chain before finalizing, identify gaps, and strengthen weak logic. ' + 'Priority: analytical depth, internal consistency, and correctness over speed.', + }, + ) + callback_data.update({ + "reasoning": {"effort": "high"}, + "temperature": 0.2 + }) file = input_message.file image = None embedding_tokens = 0 @@ -13,15 +13,15 @@ from tools.public_api.models import APIStore class Qwen_3_Max_Thinking(SimpleService): TOKENS_COST = { 'input': {'default': Decimal('360'), 'high': Decimal('900')}, - 'output': {'default': Decimal('1800'), 'high': Decimal('4500')} + 'output': {'default': Decimal('1800'), 'high': Decimal('4500')}, } def calculate_price(self, input_tokens: int, output_tokens: int) -> Decimal: - price = ( - input_tokens * (self.TOKENS_COST['input']['default' if input_tokens <= 128_000 else 'high'] / 1_000_000) - + output_tokens * (self.TOKENS_COST['output']['default' if input_tokens <= 128_000 else 'high'] / 1_000_000) - + Decimal('6') - ) + price = input_tokens * ( + self.TOKENS_COST['input']['default' if input_tokens <= 32_000 else 'high'] / 1_000_000 + ) + output_tokens * ( + self.TOKENS_COST['output']['default' if input_tokens <= 32_000 else 'high'] / 1_000_000 + ) + Decimal('2') return price.quantize(Decimal('0.1'), rounding='ROUND_UP') def save_results(self, content: str, time: timedelta, save: bool = True) -> list[Message]: @@ -41,7 +41,7 @@ class Qwen_3_Max_Thinking(SimpleService): callback_data = {'provider': {'order': ['alibaba']}, **input_message.info} messages = self.get_chat_history() messages.append({'role': 'user', 'content': input_message.content}) - result = openrouter_run('qwen/qwen3-max:online', messages, callback_data, 'Qwen') + result = openrouter_run('qwen/qwen3-max-thinking:online', messages, callback_data, 'Qwen') process_time = timedelta(seconds=(time.time() - start_time)) self.handle_invoice( input_message.content_object.model, @@ -51,13 +51,15 @@ class Qwen_3_Max_Thinking(SimpleService): msgs = self.save_results(result[0], process_time) return msgs - def get_chat_history(self, message_limit: int = 10, max_character_limit: int = 1500) -> list[dict[str, str | list]]: + def get_chat_history( + self, message_limit: int = 10, max_character_limit: int = 1500 + ) -> list[dict[str, str | list]]: if isinstance(self.store, Chat): air_messages = list( reversed( Message.objects.filter( chats_chats_messages=self.store, is_deleted=False, is_sent=True - ).order_by('-created_at')[1:message_limit+1] + ).order_by('-created_at')[1 : message_limit + 1] ) ) elif isinstance(self.store, APIStore):