@@ -151,16 +151,10 @@ class Chatgpt(SimpleService): 'presence_penalty': info.pop('presence', 0), 'top_p': info.pop('top_p', 0.5), } - if model_name in ( - 'gpt-4', - 'gpt-4o', - 'gpt-4o-mini', - 'o1-preview', - 'o1-mini', - 'o3-mini', - 'gpt-4.5-preview', - ): - self.llm.tiktoken_model_name = 'gpt-4' + self.llm.tiktoken_model_name = 'gpt-4' + if self.llm.model_name not in self.TOKENS_COST.keys(): + self.llm.model_name = 'gpt-4o' + model_name = 'gpt-4o' chat_history = self.get_chat_history() conversation = RunnableWithMessageHistory( runnable=self.llm, @@ -28,7 +28,11 @@ class Claude(SimpleService): 'input': Decimal('3000'), 'output': Decimal('3000'), 'input_imgs': Decimal('960'), - }, # 1M tokens + }, + 'claude-3.5-haiku': { + 'input': Decimal('800'), + 'output': Decimal('800'), + }, # 1M tokens } def calculate_price( @@ -1,5 +1,6 @@ import sys +from django.utils.translation import gettext_lazy as _ from rest_framework.exceptions import APIException from rest_framework.response import Response from rest_framework.views import APIView @@ -47,7 +48,7 @@ class BaseGenerationView(APIView): key = APIKey.objects.get(key=request.headers.get('Authorization', '')) if key.token_limit is not None and (key.token_limit > balance or key.token_limit < 0): return Response({'error': 'Not enough tokens on balance or key limit'}, 403) - store, _ = APIStore.objects.get_or_create(user=user) + store, created = APIStore.objects.get_or_create(user=user) model: NeuronModel = NeuronModelSelector(store.user).get_model_by_slug(slug=model_slug) if model.blocked: raise APIException(