2023-10-26 20:37:41 +02:00
|
|
|
import factory
|
|
|
|
import os
|
|
|
|
|
|
|
|
from database.models import (
|
|
|
|
KhojUser,
|
2023-10-26 21:33:03 +02:00
|
|
|
KhojApiUser,
|
2023-11-02 18:43:27 +01:00
|
|
|
ChatModelOptions,
|
2023-10-26 20:37:41 +02:00
|
|
|
OfflineChatProcessorConversationConfig,
|
|
|
|
OpenAIProcessorConversationConfig,
|
2023-11-02 18:43:27 +01:00
|
|
|
UserConversationConfig,
|
2023-10-26 20:37:41 +02:00
|
|
|
Conversation,
|
2023-11-11 07:38:28 +01:00
|
|
|
Subscription,
|
2023-10-26 20:37:41 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class UserFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = KhojUser
|
|
|
|
|
|
|
|
username = factory.Faker("name")
|
|
|
|
email = factory.Faker("email")
|
|
|
|
password = factory.Faker("password")
|
|
|
|
uuid = factory.Faker("uuid4")
|
|
|
|
|
|
|
|
|
2023-10-26 21:33:03 +02:00
|
|
|
class ApiUserFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = KhojApiUser
|
|
|
|
|
|
|
|
user = None
|
|
|
|
name = factory.Faker("name")
|
|
|
|
token = factory.Faker("password")
|
|
|
|
|
|
|
|
|
2023-11-02 18:43:27 +01:00
|
|
|
class ChatModelOptionsFactory(factory.django.DjangoModelFactory):
|
2023-10-26 20:37:41 +02:00
|
|
|
class Meta:
|
2023-11-02 18:43:27 +01:00
|
|
|
model = ChatModelOptions
|
2023-10-26 20:37:41 +02:00
|
|
|
|
|
|
|
max_prompt_size = 2000
|
|
|
|
tokenizer = None
|
2023-11-03 06:44:25 +01:00
|
|
|
chat_model = "mistral-7b-instruct-v0.1.Q4_0.gguf"
|
2023-11-02 18:43:27 +01:00
|
|
|
model_type = "offline"
|
|
|
|
|
|
|
|
|
|
|
|
class UserConversationProcessorConfigFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = UserConversationConfig
|
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
|
|
|
setting = factory.SubFactory(ChatModelOptionsFactory)
|
2023-10-26 20:37:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
class OfflineChatProcessorConversationConfigFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = OfflineChatProcessorConversationConfig
|
|
|
|
|
2023-11-02 18:43:27 +01:00
|
|
|
enabled = True
|
2023-10-26 20:37:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
class OpenAIProcessorConversationConfigFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = OpenAIProcessorConversationConfig
|
|
|
|
|
|
|
|
api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
|
|
class ConversationFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Conversation
|
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
2023-11-11 07:38:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
class SubscriptionFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Subscription
|
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
|
|
|
type = "trial"
|
|
|
|
is_recurring = False
|